Smalidea无源码调试 android 应用

smalidea是一款 IntelliJ IDEA/Android Studio的 smali 插件

已有功能


安装


开启应用调试


要调试一个apk里面的dex代码,必须满足以下两个条件中的任何一个:

可选方案:

个人觉得改 boot.img和二次打包比较麻烦,所以这里采用 hook 方式达到开启所有应用调试的目的,xposed 插件代码如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
public class Debug implements IXposedHookLoadPackage {
    public boolean debugApps = true ;
    public static final int DEBUG_ENABLE_DEBUGGER = 0x1;
    public String tag = "IDG";
    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
        if(lpparam.appInfo == null ||
                (lpparam.appInfo.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) !=0){
            return;
        }
        tag = tag + lpparam.packageName;
        XposedBridge.hookAllMethods(Process.class, "start", new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                int id = 5;
                int flags = (Integer) param.args[id];
                Log.d(tag,"flags is : "+flags);
                if (debugApps) {
                    if ((flags & DEBUG_ENABLE_DEBUGGER) == 0) {
                        flags |= DEBUG_ENABLE_DEBUGGER;
                    }
                }
                param.args[id] = flags;
                Log.d(tag,"flags changed : "+flags);
            }
        });
    }
}

效果如下图

如果遇到如下错误
[crayon-5a184bf598d21743560040/]
可以使用重启 adb server 来解决
[crayon-5a184bf598d2b887654548/]

调试应用


注意:IDEA 14.1及以上版本才支持单步调试

reference


http://www.kanxue.com/bbs/showthread.php?p=1338639

https://github.com/JesusFreke/smali/wiki/smalidea

https://github.com/pylerSM/XInstaller

转载自:http://drops.wooyun.org/tips/7181    原文作者:瘦蛟舞