1. 下载并安装apk,提示要输入密码
2. apk拖入到jadx中看一下
this.login.setOnClickListener(new View.OnClickListener() { // from class: com.example.test.ctf02.MainActivity.1
@Override // android.view.View.OnClickListener
public void onClick(View v) {
String str = MainActivity.this.passWord.getText().toString();
Check check = new Check();
if (check.checkPassword(str)) {
Toast.makeText(MainActivity.this, "Good,Please go on!", 0).show();
Intent intent = new Intent(MainActivity.this, MainActivity2.class);
MainActivity.this.startActivity(intent);
MainActivity.this.finish();
return;
}
Toast.makeText(MainActivity.this, "Failed", 0).show();
}
});
关键在 check.checkPassword(str)方法这里
public class Check {
public boolean checkPassword(String str) {
char[] pass = str.toCharArray();
if (pass.length != 12) {
return false;
}
for (int len = 0; len < pass.length; len++) {
pass[len] = (char) (((255 - len) - 100) - pass[len]);
if (pass[len] != '0' || len >= 12) {
return false;
}
}
return true;
}
}
这里其实可以通过hook绕过去,但是担心这个密码就是flag,所以还原一下这个算法
python 还原算法
keys = []
for len in range(0, 12):
keys.append(chr( 107 - len))
print(''.join(keys))
日志
kjihgfedcba`
adb shell input text "kjihgfedcba`" 成功进入下一关
3. 提示要输入显示码,看看反编译代码
this.button.setOnClickListener(new View.OnClickListener() { // from class: com.example.test.ctf02.MainActivity2.1
@Override // android.view.View.OnClickListener
public void onClick(View v) {
String str = MainActivity2.this.editText.getText().toString();
Intent intent = new Intent(str);
MainActivity2.this.sendBroadcast(intent);
}
});
从代码可得,输入的内容作为了Intent的内容并发送广播,直接看AndroidManifest.xml 看看有哪个广播接收器
<receiver android:name="com.example.test.ctf02.GetAndChange" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="android.is.very.fun"/>
</intent-filter>
</receiver>
输入 android.is.very.fun 点击确认,图片上就有flag了
标签:攻防,len,MainActivity,Intent,str,pass,Android,android,View From: https://www.cnblogs.com/gradyblog/p/17223253.html