加入收藏 | 设为首页 | 会员中心 | 我要投稿 威海站长网 (https://www.0631zz.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长资讯 > 评论 > 正文

分析黑客 | 实用技巧之“抢火车票、红包技术”,防止上当受骗

发布时间:2019-01-26 18:13:11 所属栏目:评论 来源:Jayson
导读:一、抢火车票 1、抢火车票软件的技术原理 目前主流的抢票软件是安装在浏览器上的插件,像猎豹、360浏览器等,用于在12306网站上抢票。 常规情况下,使用12306网站订票时,如果刷新页面就需要再次填写个人信息,这就耽误了不少时间。这一耽误,可能需要秒杀

(二)实现功能:

  1. 锁屏抢红包(不可以有密码或者图案之类的锁屏)
  2. 口令红包,自动输入口令并且发送
  3. 抢完红包后,自动回复感谢语,可在红包设置里自行设置内容
  4. 其他的功能就没继续往下做了,知道方法,其他都可能慢慢研究出来。

(三)利用抢红包辅助功能类完成QQ抢红包,类中有用到QQConstant类,代码如下:

  1. /** 
  2.  * 描述:QQ抢红包服务 
  3.  */ 
  4. public class EnvelopeService extends BaseAccessibilityService { 
  5.   
  6.  //锁屏、解锁相关 
  7.  private KeyguardManager.KeyguardLock kl; 
  8.   
  9.  //唤醒屏幕相关 
  10.  private PowerManager.WakeLock wl = null; 
  11.   
  12.  private long delayTime = 0;//延迟抢的时间 
  13.   
  14.  /** 
  15.  * 描述:所有事件响应的时候会回调 
  16.  */ 
  17.  @Override 
  18.  public void onAccessibilityEvent(AccessibilityEvent event) { 
  19.   
  20.  //验证抢红包的开关 
  21.  if (!invalidEnable()) { 
  22.  return; 
  23.  } 
  24.   
  25.  //事件类型 
  26.  int eventType = event.getEventType(); 
  27.   
  28.  //获取包名 
  29.  CharSequence packageName = event.getPackageName(); 
  30.  if (TextUtils.isEmpty(packageName)) { 
  31.  return; 
  32.  } 
  33.   
  34.  switch (eventType) { 
  35.   
  36.  //状态栏变化 
  37.  case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED: 
  38.   
  39.  if (QQConstant.QQ_PACKAGE_NAME.equals(packageName)) { 
  40.  //处理状态栏上QQ的消息,如果是红包就跳转过去 
  41.  progressQQStatusBar(event); 
  42.  } 
  43.  break; 
  44.   
  45.  //窗口切换的时候回调 
  46.  case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: 
  47.  case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: 
  48.  if (QQConstant.QQ_PACKAGE_NAME.equals(packageName)) { 
  49.  //处理正在QQ聊天窗口页面,有其他群或者人有新的红包提醒,跳转过去。 
  50.  progressNewMessage(event); 
  51.  //处理聊天页面的红包 
  52.  progressQQChat(event); 
  53.  } 
  54.   
  55.  break; 
  56.  } 
  57.   
  58.   
  59.  } 
  60.   
  61.  /** 
  62.  * 描述:处理新消息 
  63.  */ 
  64.  private void progressNewMessage(AccessibilityEvent event) { 
  65.   
  66.  if (event == null) { 
  67.  return; 
  68.  } 
  69.  AccessibilityNodeInfo source = event.getSource(); 
  70.  if (source == null) { 
  71.  return; 
  72.  } 
  73.  //根据event的source里的text,来判断这个消息是否包含[QQ红包]的字眼,有的话就跳转过去 
  74.  CharSequence text = source.getText(); 
  75.  if (!TextUtils.isEmpty(text) && text.toString().contains(QQConstant.QQ_ENVELOPE_KEYWORD)) { 
  76.  performViewClick(source); 
  77.  } 
  78.  } 
  79.   
  80.  /** 
  81.  * 描述:验证抢红包是否开启 
  82.  */ 
  83.  private boolean invalidEnable() { 
  84.  return SettingConfig.getInstance().getReEnable(); 
  85.  } 
  86.   
  87.   
  88.  /** 
  89.  * 描述:处理QQ状态栏 
  90.  */ 
  91.  public void progressQQStatusBar(AccessibilityEvent event) { 
  92.  List<CharSequence> text = event.getText(); 
  93.  //开始检索界面上是否有QQ红包的文本,并且他是通知栏的信息 
  94.  if (text != null && text.size() > 0) { 
  95.  for (CharSequence charSequence : text) { 
  96.  if (charSequence.toString().contains(QQConstant.QQ_ENVELOPE_KEYWORD)) { 
  97.  //说明存在红包弹窗,马上进去 
  98.  if (event.getParcelableData() != null && event.getParcelableData() instanceof Notification) { 
  99.  Notification notification = (Notification) event.getParcelableData(); 
  100.  if (notification == null) { 
  101.  return; 
  102.  } 
  103.  PendingIntent pendingIntent = notification.contentIntent; 
  104.  if (pendingIntent == null) { 
  105.  return; 
  106.  } 
  107.  try { 
  108.  //要跳转之前,先进行解锁屏幕,然后再跳转,有可能你现在屏幕是锁屏状态,先进行解锁,然后打开页面,有密码的可能就不行了 
  109.  wakeUpAndUnlock(MyApp.context); 
  110.  //跳转 
  111.  pendingIntent.send(); 
  112.  } catch (PendingIntent.CanceledException e) { 
  113.  e.printStackTrace(); 
  114.  } 
  115.  } 
  116.  } 
  117.  } 
  118.  } 
  119.  } 
  120.   
  121.  /** 
  122.  * 描述:处理QQ聊天红包 
  123.  */ 
  124.  public void progressQQChat(AccessibilityEvent event) { 
  125.   
  126.  if (TextUtils.isEmpty(event.getClassName())) { 
  127.  return; 
  128.  //如果当前页面是聊天页面或者当前的描述信息是"返回消息界面",就肯定是对话页面 
  129.  } 
  130.   
  131.  //验证当前事件是否符合查询页面上的红包 
  132.  if (!invalidEnvelopeUi(event)) { 
  133.  return; 
  134.  } 
  135.   
  136.  //延迟点击红包,防止被检测到开了抢红包,不过感觉还是感觉会被检测到,应该有的效果吧... 
  137.  try { 
  138.  Thread.sleep(delayTime); 
  139.  } catch (InterruptedException e) { 
  140.  e.printStackTrace(); 
  141.  } 
  142.   
  143.  //普通红包,检索点击拆开的字眼。 
  144.  List<AccessibilityNodeInfo> envelope = findViewListByText(QQConstant.QQ_CLICK_TAKE_APART, false); 
  145.  //处理普通红包 
  146.  progressNormal(envelope); 
  147.   
  148.  //口令红包,检索口令红包的字眼。 
  149.  List<AccessibilityNodeInfo> passwordList = findViewListByText(QQConstant.QQ_CLICK_PASSWORD_DIALOG, false); 
  150.  //处理口令红包 
  151.  progressPassword(passwordList); 
  152.  } 
  153.   
  154.   
  155.  /** 
  156.  * 描述:验证是否现在是在聊天页面,可以进行抢红包处理 
  157.  * @param event 
  158.  */ 
  159.   
  160.  public boolean invalidEnvelopeUi(AccessibilityEvent event) { 
  161.   
  162.  //判断类名是否是聊天页面 
  163.  if (!QQConstant.QQ_IM_CHAT_ACTIVITY.equals(event.getClassName().toString())) { 
  164.  return true; 
  165.  } 
  166.   
  167.  //判断页面中的元素是否有点击拆开的文本,有就返回可以进行查询了 
  168.  int recordCount = event.getRecordCount(); 
  169.  if (recordCount > 0) { 
  170.  for (int i = 0; i < recordCount; i++) { 
  171.  AccessibilityRecord record = event.getRecord(i); 
  172.  if (record == null) { 
  173.  break; 
  174.  } 
  175.  List<CharSequence> text = record.getText(); 
  176.  if (text != null && text.size() > 0 && text.contains(QQConstant.QQ_CLICK_TAKE_APART)) { 
  177.  //如果文本中有点击拆开的字眼,就返回可以进行查询了 
  178.  return true; 
  179.  } 
  180.  } 
  181.  } 
  182.  return false; 
  183.  } 
  184.   
  185.  /** 
  186.  * 回到系统桌面 
  187.  */ 
  188.  private void back2Home(int time) { 
  189.  try { 
  190.  Thread.sleep(time); 
  191.  } catch (InterruptedException e) { 
  192.  e.printStackTrace(); 
  193.  } 
  194.  Intent home = new Intent(Intent.ACTION_MAIN); 
  195.  home.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
  196.  home.addCategory(Intent.CATEGORY_HOME); 
  197.  startActivity(home); 
  198.  } 
  199.   
  200.  /** 
  201.  * 描述:处理普通红包 
  202.  */ 
  203.  public void progressNormal(List<AccessibilityNodeInfo> passwordList) { 
  204.  if (passwordList != null && passwordList.size() > 0) { 
  205.  for (AccessibilityNodeInfo accessibilityNodeInfo : passwordList) { 
  206.  if (accessibilityNodeInfo != null && !TextUtils.isEmpty(accessibilityNodeInfo.getText()) && QQConstant.QQ_CLICK_TAKE_APART.equals(accessibilityNodeInfo.getText().toString())) { 
  207.   
  208.  //点击拆开红包 
  209.  performViewClick(accessibilityNodeInfo); 
  210.   
  211.  //回复感谢信息,根据配置文件中配置的回复信息回复 
  212.  String reReplyMessage = SettingConfig.getInstance().getReReplyMessage(); 
  213.  if (!TextUtils.isEmpty(reReplyMessage)) { 
  214.  replyMessage(reReplyMessage); 
  215.  } 
  216.  } 
  217.  } 
  218.  //最后延迟事件触发返回事件,关闭红包页面 
  219.  performBackClick(1200); 
  220.  } 
  221.  } 
  222.   
  223.  /** 
  224.  * 描述:处理口令红包 
  225.  * @param passwordList 
  226.  */ 
  227.  public void progressPassword(List<AccessibilityNodeInfo> passwordList) { 
  228.  if (passwordList != null && passwordList.size() > 0) { 
  229.  for (AccessibilityNodeInfo accessibilityNodeInfo : passwordList) { 
  230.  if (accessibilityNodeInfo != null && !TextUtils.isEmpty(accessibilityNodeInfo.getText()) && QQConstant.QQ_CLICK_PASSWORD_DIALOG.equals(accessibilityNodeInfo.getText().toString())) { 
  231.  //如果口令红包存在,就在输入框中进行输入,然后发送 
  232.  AccessibilityNodeInfo parent = accessibilityNodeInfo.getParent(); 
  233.  if (parent != null) { 
  234.  CharSequence contentDescription = parent.getContentDescription(); 
  235.  if (!TextUtils.isEmpty(contentDescription)) { 
  236.  //1. 获取口令 
  237.  String key = (String) contentDescription; 
  238.  if (key.contains(",") && key.contains("口令:")) { 
  239.  key = key.substring(key.indexOf("口令:") + 3, key.lastIndexOf(",")); 
  240.  } 
  241.  Log.e("口令", key); 
  242.   
  243.  //2. 填写口令到编辑框上然后进行发送 
  244.  replyMessage(key); 
  245.   
  246.  //返回,关闭红包页面 
  247.  performBackClick(1200); 
  248.  } 
  249.  } 
  250.  } 
  251.  } 
  252.  } 
  253.  } 
  254.   
  255.   
  256.  /** 
  257.  * 唤醒屏幕并解锁权限 
  258.  * <uses-permission android:name="android.permission.WAKE_LOCK" /> 
  259.  */ 
  260.  @SuppressLint("Wakelock") 
  261.  @SuppressWarnings("deprecation") 
  262.  public void wakeUpAndUnlock(Context context) { 
  263.  // 点亮屏幕 
  264.  wl.acquire(); 
  265.  // 释放 
  266.  wl.release(); 
  267.  // 解锁 
  268.  kl.disableKeyguard(); 
  269.  } 
  270.   
  271.  /** 
  272.  * 描述:回复消息,无延迟 
  273.  */ 
  274.  public void replyMessage(String key) { 
  275.  replyMessage(key, 0); 
  276.  } 
  277.   
  278.  /** 
  279.  * 描述:回复消息 
  280.  */ 
  281.  public void replyMessage(String key, int time) { 
  282.   
  283.  //延迟 
  284.  if (time > 0) { 
  285.  try { 
  286.  Thread.sleep(time); 
  287.  } catch (InterruptedException e) { 
  288.  e.printStackTrace(); 
  289.  } 
  290.  } 
  291.   
  292.  //获取QQ聊天页面输入框 
  293.  AccessibilityNodeInfo chat_edit = findViewByID(QQConstant.QQ_CHAT_MESSAGE_INPUT); 
  294.  if (chat_edit != null) { 
  295.   
  296.  //把口令粘贴到输入框中 
  297.  pastaText(chat_edit, MyApp.context, key); 
  298.   
  299.  //获取QQ聊天页面发送消息按钮 
  300.  AccessibilityNodeInfo sendMessage = findViewByID(QQConstant.QQ_CHAT_MESSAGE_SEND); 
  301.   
  302.  //然后就按下发送按钮 
  303.  if (sendMessage != null && Button.class.getName().equals(sendMessage.getClassName())) { 
  304.  performViewClick(sendMessage); 
  305.  } 
  306.  } 
  307.   
  308.  } 
  309.   
  310.  @Override 
  311.  public void onInterrupt() { 
  312.  } 
  313.   
  314.   
  315.  @Override 
  316.  protected void onServiceConnected() { 
  317.  super.onServiceConnected(); 
  318.   
  319.  // 获取电源管理器对象 
  320.  PowerManager pm = (PowerManager) MyApp.context 
  321.  .getSystemService(Context.POWER_SERVICE); 
  322.  // 获取PowerManager.WakeLock对象,后面的参数|表示同时传入两个值,最后的是调试用的Tag 
  323.  wl = pm.newWakeLock( 
  324.  PowerManager.ACQUIRE_CAUSES_WAKEUP 
  325.  | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright"); 
  326.   
  327.  KeyguardManager km = (KeyguardManager) MyApp.context.getSystemService(Context.KEYGUARD_SERVICE); 
  328.  kl = km.newKeyguardLock("unLock"); 
  329.   
  330.  //初始化屏幕的监听 
  331.  ScreenListener screenListener = new ScreenListener(MyApp.context); 
  332.  screenListener.begin(new ScreenListener.ScreenStateListener() { 
  333.  @Override 
  334.  public void onScreenOn() { 
  335.  Log.e("ScreenListener", "屏幕打开了"); 
  336.  } 
  337.   
  338.  @Override 
  339.  public void onScreenOff() { 
  340.  //在屏幕关闭的时候,进行锁屏,不执行的话,锁屏就失效了,因为要实现锁屏状态下也可以进行抢红包。 
  341.  Log.e("ScreenListener", "屏幕关闭了"); 
  342.  if (kl != null) { 
  343.  kl.disableKeyguard(); 
  344.  kl.reenableKeyguard(); 
  345.  } 
  346.  } 
  347.   
  348.  @Override 
  349.  public void onUserPresent() { 
  350.  Log.e("ScreenListener", "解锁了"); 
  351.  } 
  352.  }); 
  353.  } 
  354.   
  355.  @Override 
  356.  public void onDestroy() { 
  357.  super.onDestroy(); 
  358.  } 

(编辑:威海站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读