Jarvis OJ - 爬楼梯 -Writeup
Jarvis OJ - 爬楼梯 -Writeup
本来是想逆一下算法的,后来在学长的指导下发现可以直接修改关键函数,这个题做完有种四两拨千斤的感觉,记录在这里
题目:

分析:
先看apk的外部特征,在模拟器中安装apk,如下:

每次点击爬一层楼按钮以爬的楼层会加1,爬到了,看FLAG按钮点击无效,于是猜测需要爬到指定的楼层才可以看到flag。
首先大致浏览apk的java代码(这里使用的是dex2jar+jd-jui的方法),代码的命名和逻辑都很清晰,MainActivity的代码如下:
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; static
{
if (!Debug.isDebuggerConnected()) {
System.loadLibrary("ctf");
}
} public void Btn_up_onclick(View paramView)
{
this.has_gone_int += 1;
paramView = "" + this.has_gone_int;
((TextView)findViewById(2131492948)).setText(paramView);
if (this.to_reach_int <= this.has_gone_int) {
((Button)findViewById(2131492950)).setClickable(true);#第一个setClickable
}
} public void btn2_onclick(View paramView)
{
((TextView)findViewById(2131492951)).setText("{Flag:" + get_flag(this.to_reach_int) + "}");
} public native String get_flag(int paramInt); protected void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
setContentView(2130968601);
((Button)findViewById(2131492950)).setClickable(false);#第二个setClickable
this.has_gone_int = 0;
paramBundle = new Random();
for (this.to_reach_int = paramBundle.nextInt();; this.to_reach_int = paramBundle.nextInt())
{
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(2131492947)).setText("" + this.to_reach_int);
((TextView)findViewById(2131492951)).setText("");
return;
}
}
}
}
可以看到有这样一段:

结合之前的分析,可以推测该段代码的作用即为当以爬的楼层(has_gone_int)大于要爬的楼层(to_reach_int)时,设置爬到了,看FLAG按钮的属性为可以点击的(setClickable),于此对应的还有:

于是我们可以设想修改setClickable的属性永为ture,这样就不用管以爬的楼层(has_gone_int)是否大于了要爬的楼层(to_reach_int)
步骤:
先用APKTOOL BOX反编译apk:

打开反编译后的文件夹,删除整个unknown文件夹(听学长说这个和之后生成apk之后的签名有关),在CFF100\CFF100\smali\com\ctf\test\ctf_100中找到MainActivity.smali,即为MainActivity函数的smali
smali之于java就如同汇编之于C语言,因此我们只需要修改smali就可以修改app
用记事本打开,搜索关键字setClickable,找到了两处,刚好和java代码中的两处对应:


对比两处,推测V5和V3即为true或false的标记位,第一张图中的v3又永为0x1,因此只需要修改v5为1,找到V5的定义部分,修改其为0x1

保存,整个文件夹拖到APKTOOL BOX中,回编译APK

安装APK,会发现修改已经完成了,无论楼层是多少都可以直接拿到flag

于是flag即为268796A5E68A25A1
需要先卸载没修改的程序才能安装修改后的程序,否则会报错
附一片smali的学习连接http://blog.csdn.net/u012573920/article/details/44034397
Jarvis OJ - 爬楼梯 -Writeup的更多相关文章
- Jarvis OJ - [XMAN]level1 - Writeup
Jarvis OJ - [XMAN]level1 - Writeup M4x原创,转载请表明出处http://www.cnblogs.com/WangAoBo/p/7594173.html 题目: 分 ...
- jarvis OJ WEB题目writeup
0x00前言 发现一个很好的ctf平台,题目感觉很有趣,学习了一波并记录一下 https://www.jarvisoj.com 0x01 Port51 题目要求是用51端口去访问该网页,注意下,要用具 ...
- Jarvis OJ - [XMAN]level3 - Writeup——ret2libc尝试
这次除了elf程序还附带一个动态链接库 先看一下,很一般的保护 思路分析 在ida中查看,可以确定通过read函数输入buf进行溢出,但是并没有看到合适的目标函数 但是用ida打开附带的链接库,可以看 ...
- Jarvis OJ - [XMAN]level2 - Writeup
简单利用"/bin/sh"夺权 简单看一下 放到ida中发现了"/bin/sh"串,和system函数,可以利用== 所以只要在vuln函数返回时跳转到syst ...
- Jarvis OJ - [XMAN]level1 - Writeup——简单shellcode利用
100分的pwn 简单查看一下,果然还是比较简单的 放到ida中查看一下,有明显的溢出函数,并且在函数中打印出了字符串的地址,并且字符串比较长,没有NX保护 所以我们很容易想到构造shellcode, ...
- Jarvis OJ - [XMAN]level0 - Writeup
差不多最简单的pwn了吧,不过本菜鸟还是要发出来镇楼 分析一下,checksec 查看程序的各种保护机制 没有金丝雀,没有pie 执行时输出Hello,World,在进行输入,溢出嘛 开工 丢到id ...
- Jarvis OJ - class10 -Writeup
Jarvis OJ - class10 -Writeup 转载请注明出处:http://www.cnblogs.com/WangAoBo/p/7552266.html 题目: Jarivs OJ的一道 ...
- Jarvis OJ - 栈系列部分pwn - Writeup
最近做了Jarvis OJ的一部分pwn题,收获颇丰,现在这里简单记录一下exp,分析过程和思路以后再补上 Tell Me Something 此题与level0类似,请参考level0的writeu ...
- Jarvis OJ - 软件密码破解-1 -Writeup
Jarvis OJ - 软件密码破解-1 -Writeup 转载请标明出处http://www.cnblogs.com/WangAoBo/p/7243801.html 记录这道题主要是想记录一下动态调 ...
随机推荐
- 深入浅出Mybatis系列八-mapper映射文件配置之select、resultMap
注:本文转载自南轲梦 注:博主 Chloneda:个人博客 | 博客园 | Github | Gitee | 知乎 上篇<深入浅出Mybatis系列(七)---mapper映射文件配置之inse ...
- unrecognized import path "golang.org/x/*"的解决办法
由于国内网络原因,因此访问https://golang.org/网站会被限制.所以在go get下载其他第三方包的时候,如果这个第三方包又引用了https://golang.org/x/下的包,通常会 ...
- docker部署mysql Navicat远程连接
docker部署mysql Navicat远程连接 docker search mysql 查看mysql镜像(是去dockerHub网站搜素镜像,遇到问题可以去该网站查看官方文档,纯英文文档估计 ...
- eclipse如何查看源码
方式一: Source not found The JAR file X:\xxxx\xxxx\xxxx\xx has no source attachment. 没有源附件. You can att ...
- java mail发送html格式的邮件
// 获取系统属性 Properties properties = System.getProperties(); // 设置邮件服务器 properties.setProperty("ma ...
- IntelliJ WebStorm 最新版 安装永久破解教程【最强,可用至2099年】
IntelliJ WebStorm 2018.3.6安装永久破解[最强] 一. 在官网下载WebStorm安装包 链接:http://www.jetbrains.com/webstorm/down ...
- 开班信息CSS实现
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 二分-A - Cable master
A - Cable master Inhabitants of the Wonderland have decided to hold a regional programming contest. ...
- 10.pandas的替换和部分替换(replace)
在处理数据的时候,很多时候会遇到批量替换的情况,如果一个一个去修改效率过低,也容易出错.replace()是很好的方法. 源数据 1.替换全部或者某一行 replace的基本结构是:df.repl ...
- numpy Array[:,]的取值方法