2018-04-25
DDCTF re1:(baby_MIPS) 参照夜影大佬和henryZhao的wp.
1. 利用qemu运行MIPS程序:
baby_mips是MIPS指令集上的程序,IDA只能静态分析,不能debug。采取的方法是在linux机上安装qemu模拟器,利用qemu来运行MIPS指令程序。经尝试,baby_mips是小字端程序,使用指令,运行程序。运行效果是输入16个变量,然后报错非法指令。
如果要利用IDA调试,使用指令,监控23946端口,原理:qemu -g port指令开启一个gdbserver。port另一端可以由IDA或gdb连接调试。
2. 花指令的识别和去除:
上述遇到了非法指令,查看IDA反编译代码发现大都在EB02开头的指令处触发非法指令错误。并且有很多未解析的代码段数据,考虑花指令。写idc脚本去除EB02开头指令,以下代码来自夜影大佬:
1 #include2 3 static matchBytes(StartAddr,Match) 4 { 5 auto Len,i,PatSub,SrcSub; 6 Len = strlen(Match); 7 8 while(i
对于idc的编写不熟,附上一个链接:
其包含一些常用的函数便于查找。
去除完花指令,IDC中AnalyzeArea似乎没有没有起作用,还是没有完全将其识别为整一个函数体。Edit function 将其设置为一个函数后,通过函数跳转图可以看到大概逻辑,但是还是无法F5大法。
3. JEB2-mips(反编译MIPS):
嗯,夜影大佬的清洗代码看不动,就看了Web大佬henryZhao的re题解,菜哭/(ㄒoㄒ)/~~,知道了jeb2新增了mips反编译功能,下载支持mips的jeb2试用版,试图反编译mips。得到下图,
可以看出是一个方程组求解问题,手敲数据写python解方程组。
1 import numpy as np 2 from scipy.linalg import solve 3 A=[ 4 [-56251,64497,-61787,29993,-16853,2147,-51990,-36278,-34108,-1148,1798,-43452,-16150,-56087,-17677,-41752], 5 [-39354,63754,50513,2396,-37448,43585,19468,-4688,-62869,-20663,41173,61113,30862,38224,-601,53899], 6 [26798,-58888,14929,-21751,-12385,55961,-20714,24897,40045,9805,25147,39173,-21952,-42840,37937,-8559], 7 [-2789,53359,16747,54195,-30020,39916,-32582,60338,13971,27307,-30484,47826,37554,64914,-1745,27669], 8 [40374,6523,13380,-53413,-1194,7796,-31815,-51866,-40252,-56883,57811,23278,-5785,61525,-6984,-7335], 9 [-57052,-64573,-62351,2628,21493,12939,-60006,435,15009,-4091,22743,4901,48803,-43203,5263,-32994],10 [54760,41053,22537,-56473,46316,19787,-40180,2088,2044,26575,-5207,31098,-23838,21642,46750,13706],11 [-40176,-43382,48718,-25423,21452,-36714,-24119,-13231,-52192,49742,54709,-32636,20233,21460,48733,15155],12 [38446,-880,-2443,50487,-46973,-56178,-37138,-9079,-19096,-60988,-1823,-21538,43896,-4141,-19370,-47796],13 [5176,18400,-53852,36119,-32120,47724,17154,5390,-29717,14471,8755,1432,-45518,-8148,-56623,-48254],14 [30203,-50712,-27560,-16075,3618,590,44305,20581,33442,-7743,-43075,-16234,45723,-44899,42321,49264],15 [42705,-32299,-19156,5594,28870,8059,58103,-60723,-32112,-7128,45985,-24915,63910,18427,-51408,22619],16 [-57517,20738,-32286,55995,26666,37550,-51489,13733,32455,-2897,-39622,-54523,50733,-24649,-17849,-62326],17 [-15716,-38264,64476,-37524,-61551,13536,12920,1407,-63767,-55105,-46543,-36562,-20712,2063,-6668,9074],18 [47490,18611,52416,3107,32177,-41780,11008,7223,5652,881,26719,-28444,46077,-272,-32475,-9432],19 [-58938,-35689,35708,44689,45902,36614,38550,731,49990,6727,61526,-35587,-39199,-43886,-56409,-25519],20 ]21 B=[-24232262,17175305,8705731,26962228,-6384428,-15459013,19554563,-188243,-19590071,-12754495,6442406,-2869966,-4805280,-18964176,8938201,3896470]22 23 a = np.array(A)24 b = np.array(B)25 x =solve(a,b)26 print(x)
最终得到flag:
总结:
花指令的识别,花指令的清洗(idc脚本),
MIPS程序的反编译(JEB2),
方程组的python求解(scipy.linalg)。(注意:scipy.linalg求出来的解感觉是近似解,最后的输入都是取得solve结果的四舍五入解。)
Android xss的调研:
发现几个比较好的文章,看了一些,先贴上,还没有实践,实践后再写。
其他:
今天还看了一下DDCTF的re2黑盒测试,试着自己做了做,没做出来,还是要看夜影大佬的wp。学习一下分析数据结构的手段和习惯吧。明天复现了写。
明日预计:
黑盒测试复现完,总结。
做android webview实验。