拿到app,先在模拟器里跑一下:
需要的权限挺多,点击Continue,进入主界面:
两个编辑框已经有默认的内容,直接点击登录:
进到这个界面就不动了。修改编辑框的字符串,效果一样。
先静态分析一下,用dex2jar反编译:
用jd-gui打开,先看MainActivity。
在构造函数中,将自己注册成了点击事件处理类:
this.a.setOnClickListener(this);
所以点击按钮的处理函数为MainActivity的onClick。
onClick
看onClick函数,该函数先判断点击的是不是“登录”按钮:
switch (paramView.getId()) {
default:
return;
case 2131165187:
break;
}
然后检测两个编辑框内容是否为空,有一个为空就报错:
if (this.c.getText().length() == 0 || this.d.getText().length() == 0) {
Toast.makeText((Context)this, "不能为空", 1).show();
return;
}
然后基于SecondActivity类创建一个Intent:
Intent intent = new Intent((Context)this, SecondActivity.class);
通过putExtra将输入的两个字符串传递给SecondActivity:
intent.putExtra("ili", str1);
intent.putExtra("lil", str2);
最后启动SecondActivity:
startActivity(intent);
我们看看SecondActivity。
SecondActivity
在构造函数里,通过getStringExtra获取输入的两个字符串:
Intent intent = getIntent();
String str1 = intent.getStringExtra("ili");
String str2 = intent.getStringExtra("lil");
下面是一个关键的if,将两个字符串拼接起来并进行加密,比较加密后的内容是否为“VEIzd/V2UPYNdn/bxH3Xig==”。
如果相同,则创建并启动MonitorInstallService。
最后将输入则字符串存储到SharedPreferences中。
if (Encryto.doRawData(this, str1 + str2).equals("VEIzd/V2UPYNdn/bxH3Xig==")) {
intent.setAction("android.test.action.MoniterInstallService");
intent.setClass((Context)this, MoniterInstallService.class);
intent.putExtra("company", "tencent");
intent.putExtra("name", "hacker");
intent.putExtra("age", 18);
startActivity(intent);
startService(intent);
}
SharedPreferences.Editor editor = getSharedPreferences("test", 0).edit();
editor.putString("ilil", str1);
editor.putString("lili", str2);
editor.commit();
看看负责加密的Encryto类。
Encryto
可以看到是个JNI类,我们去lib目录中找:
public class Encryto {
static {
System.loadLibrary("JNIEncrypt");
}
... ...
}
只有三个处理器结构的,选择熟悉的x86:
在IDA中找到doRawData 函数,明显看到是个AES128,密钥是“thisisatestkey==”:
int __cdecl doRawData(int a1, int a2, int a3, int a4)
{
... ...
strcpy(v10, "thisisatestkey==");
v4 = (char *)(*(int (__cdecl **)(int, int, _DWORD))(*(_DWORD *)a1 + 676))(a1, a4, 0);
v8 = AES_128_ECB_PKCS5Padding_Encrypt(v4, (int)v10);
... ...
}
在解密网站http://tool.chacuo.net/cryptaes解密结果为:aimagetencent:
猜测两字符分别为aimage和tecent,但是不对。试了几种字符串组合都不对。
柳暗花明
一度找不到思路,所幸程序不大,就想回到反编译的java代码看看,发现另一个Acitivity类:FileDataActivity,里面有如下代码:
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(2130903042);
this.c = (TextView)findViewById(2131165184);
this.c.setText(Encryto.decode(this, "9YuQ2dk8CSaCe7DTAmaqAA=="));
}
在解密网站使用相同的密钥对这个串解密得到:Cas3_0f_A_CAK3。
这就是结果了。
很意外。考点在要全面地阅读代码?或者是我遗漏了什么,如果大家发现什么玄机,麻烦留言告诉我~~~
欢迎关注我的微博:大雄_RE。专注软件逆向,分享最新的好文章、好工具,追踪行业大佬的研究成果。