首先将题目下载下来
拖入雷电模拟器,了解基本操作
拖到jadx-gui分析程序流程,查看主页面代码
package com.ctf.test.ctf_100;
import android.os.Bundle;
import android.os.Debug;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.Random;
public class MainActivity extends AppCompatActivity {
public int has_gone_int;
public int to_reach_int;
public native String get_flag(int i);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView((int) R.layout.activity_main);
((Button) findViewById(R.id.button2)).setClickable(false);
this.has_gone_int = 0;
Random random = new Random();
this.to_reach_int = random.nextInt();
while (true) {
if (this.to_reach_int < 0) {
this.to_reach_int *= -1;
}
if (5 < this.to_reach_int) {
this.to_reach_int %= 32;
this.to_reach_int *= 16384;
((TextView) findViewById(R.id.data_to_reach)).setText("" + this.to_reach_int);
((TextView) findViewById(R.id.tvResult)).setText("");
return;
}
this.to_reach_int = random.nextInt();
}
}
public void Btn_up_onclick(View v) {
this.has_gone_int++;
((TextView) findViewById(R.id.data_has_gone)).setText("" + this.has_gone_int);
if (this.to_reach_int <= this.has_gone_int) {
((Button) findViewById(R.id.button2)).setClickable(true);
}
}
public void btn2_onclick(View v) {
((TextView) findViewById(R.id.tvResult)).setText("{Flag:" + get_flag(this.to_reach_int) + "}");
}
static {
if (!Debug.isDebuggerConnected()) {
System.loadLibrary("ctf");
}
}
}
发现:
楼梯数是程序启动时随机生成的,并且程序初始化的时候将getflag的按钮设置成不可操作,除非爬的楼梯数大于楼梯数才能按getflag的按钮,作为懒人,怎么可能真的点击那么多次,所以
拖到KALI里进行解包
在进行解包的时候加上-r命令,不对资源文件进行解包,因为在我打包的时候发现资源文件有问题,打包不了(知道详情的大佬可以告诉小弟)
接下来,我们对程序中关键跳转进行修改(此题做法不唯一),让程序无论如何都可以按getflag按钮
找到smali文件夹下的com/ctf/test/ctf_100/MainActivity.smali,直接搜索
Btn_up_onclick方法,找到关键跳转,修改成相反的就行将if-gt 修改成if-le后打包
完成打包后签名
当出现
说明签名成功,再次拖入模拟器安装运行,爬一层,使爬到了,看flag按钮能够使用后,按爬到了,看flag按钮即可发现flag
android CTF Jarvis OJ CFF_100 Android reverse
本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!