当前位置:操作系统 > 安卓/Android >>

android手机root后的安全问题 (二)

360和和金山手机卫士都有一个让广大android开发者比较蛋疼的一个功能:那就是检查广告通知!
当有通知栏有广告的时候,运行360执行检查,它会告诉你是哪个应用程序的广告(当然,这里并不局限于广告,他们是获得所有通知,然后过滤),然后他会让用户选择:不处理;关闭通知(实际上是把这个进程kill掉,整个软件停止运行);卸载此软件。
 
虽然我没有发布过android应用,但是我知道,靠软件赚钱的各位,本来收入已经够尴尬的了,再加上这些操蛋的软件提供这些操蛋的功能……哎
大家不喜欢收费软件那咱们就免费,点点广告支持一下总行吧,就是不点,你就放在那呗(当然,有的软件发起广告来没玩没了也挺操蛋)
 
说了这么多废话,我们就来看看那些所谓的杀毒软件是如何对付大家的
到了关键的地方,实际也就那么一行代码……又让大家失望了。。。
Shell代码 
adb shell dumpsys notification 
比如,我现在在我机器上面执行一下,输出的结果为
Log代码 
Current Notification Manager state: 
  Notification List: 
    NotificationRecord{41453c70 pkg=com.zdworks.android.toolbox id=7f090092 tag=null pri=0} 
      icon=0x0 / <name unknown> 
      contentIntent=null 
      deleteIntent=null 
      tickerText=null 
      contentView=null 
      defaults=0x0 
      flags=0x62 
      sound=null 
      vibrate=null 
      ledARGB=0x0 ledOnMS=0 ledOffMS=0 
    NotificationRecord{415f48e8 pkg=com.zdworks.android.toolbox id=7f090080 tag=null pri=100} 
      icon=0x7f0200fd / com.zdworks.android.toolbox:drawable/barttery_notify_icon 
      contentIntent=PendingIntent{41949028: PendingIntentRecord{412e3c20 com.zdworks.android.toolbox startActivity}} 
      deleteIntent=null 
      tickerText=电量提示 
      contentView=android.widget.RemoteViews@416e7b90 
      defaults=0x0 
      flags=0x22 
      sound=null 
      vibrate=null 
      ledARGB=0x0 ledOnMS=0 ledOffMS=0 
    NotificationRecord{416db3e0 pkg=android id=1040414 tag=null pri=100} 
      icon=0x10804f5 / android:drawable/stat_sys_adb 
      contentIntent=PendingIntent{41275de8: PendingIntentRecord{416dade8 android startActivity}} 
      deleteIntent=null 
      tickerText=USB 调试已连接 
      contentView=android.widget.RemoteViews@416daf40 
      defaults=0x0 
      flags=0x2 
      sound=null 
      vibrate=null 
      ledARGB=0x0 ledOnMS=0 ledOffMS=0 
    NotificationRecord{41790de8 pkg=com.htc.android.psclient id=7f020010 tag=null pri=100} 
      icon=0x7f020010 / com.htc.android.psclient:drawable/usb_to_pc_notify 
      contentIntent=PendingIntent{416c3e38: PendingIntentRecord{417bc968 com.htc.android.psclient startActivity}} 
      deleteIntent=null 
      tickerText=null 
      contentView=android.widget.RemoteViews@4169d128 
      defaults=0x0 
      flags=0x2 
      sound=null 
      vibrate=null 
      ledARGB=0x0 ledOnMS=0 ledOffMS=0 
   
  mSoundNotification=null 
  mSound=com.android.server.NotificationPlayer@413e73b8 
  mVibrateNotification=null 
  mDisabledNotifications=0x0 
  mSystemReady=true 
现在大家知道了吧,这么简单就把咱们给搞定了
下面的事情就简单
1.想办法获取这段log
2.提取包名
3.根据数据库中的黑名单白名单不同处理
4.你的应用很可能在黑名单中,最后的结果也基本是进程被杀死
(这里就不演示3、4部分了,只演示1、2)
 
Java代码 
testButton = (Button)findViewById(R.id.exec); 
testButton.setOnClickListener(new View.OnClickListener() { 
    public void onClick(View v) { 
        String[] commands = {"dumpsys notification"}; 
        Process process = null; 
        DataOutputStream dataOutputStream = null; 
 
        try { 
            process = Runtime.getRuntime().exec("su"); 
            dataOutputStream = new DataOutputStream(process.getOutputStream()); 
            int length = commands.length; 
            for (int i = 0; i < length; i++) { 
                Log.e(TAG, "commands[" + i + "]:" + commands[i]); 
                dataOutputStream.writeBytes(commands[i] + "\n"); 
            } 
            dataOutputStream.writeBytes("exit\n"); 
            dataOutputStream.flush(); 
             
            process.waitFor(); 
             
            BufferedReader reader = null; 
            reader = new BufferedReader(new InputStreamReader(process.getInputStream()));   
            String line = ""; 
            List<String> lineList = new ArrayList<String>(); 
            final StringBuilder log = new StringBuilder();   
            String separator = System.getProperty("line.separator"); 
            Pattern pattern = Pattern.compile("pkg=[^\\s]+"); 
            while ((line = reader.readLine()) != null) { 
   &
补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,