Android 安全相关技巧 --正确使用ADB

来源:互联网 发布:java数组的使用 编辑:程序博客网 时间:2024/06/16 05:10

有很多事情其实都可以用adb shell来完成的,比如...


media server alloc size detect(on userdebug only):

adb shell setprop libc.debug.malloc 1restartdumpsys media.player -m

adb 查看当前Android版本的权限列表

<span style="white-space:pre"></span>adb shell pm list permissions -d -g

adb 查看当前屏幕显示的归属Activity:
<span style="white-space:pre"></span>adb dumpsys activity activities |grep -A -6 "Running activities"

adb 查看当前屏幕显示的归属组件及其次序:
<span style="white-space:pre"></span>adb shell dumpsys window w | findstr \/ | findstr name=

adb 启动某一个Fragment:
am start -n package_name/.activity_name -e android:show_fragment fragment_name

adb shell 查看手机打开的端口以及对应的进程:

<span style="white-space:pre"></span>netstat

或者

cat /proc/net/tcp//ipv4   cat /proc/net/tcp6//ipv6
里面有uid,且地址端口和状态码(st)都是16进制的,而且为小端格式
<span style="white-space:pre"></span>dumpsys activity|grep uid

adb shell 查找安装路径信息:
dumpsys meminfo package_name or pid
说起网络相关,有一篇关于Android转包的文章还不错
tcpdump至wireshark:
见url:http://www.freebuf.com/articles/wireless/11175.html方法四.

关于android service :

获得当前系统的service(注册在ServiceManager的)

adb shell service service list

向对应的service发送service call

adb shell service call servicename codeUsage: service [-h|-?]service listservice check SERVICEservice call SERVICE CODE [i32 N | i64 N | f N | d N | s16 STR ] ...Options:\n"i32: Write the 32-bit integer N into the send parceli64: Write the 64-bit integer N into the send parcelf:   Write the 32-bit single-precision number N into the send parceld:   Write the 64-bit double-precision number N into the send parcels16: Write the UTF-16 string STR into the send parcelintent: Write and Intent int the send parcel. ARGS can beaction=STR data=STR type=STR launchFlags=INT component=STR categories=STR[,STR,..]


说一个小bug,adb shell有时候与logcat不能并存:
因为使用的adb client版本不同。。。一般是因为由于adb版本不同导致的,可以使用对应AOSP编译环境中的adb 。


Android logcat过滤:
<span style="white-space:pre"></span>adb logcat|grep -i "DEBUG"

Android bugreport:
<span style="white-space:pre"></span>adb bugreport

0 0