2021 ciscn Re部分wp
glass
java层没什么多余的调用,直接native调用checkflag
1 | bool __fastcall Java_com_ciscn_glass_MainActivity_checkFlag(int a1, int a2, int a3) |
长度检查,密钥拷贝,进行三步操作之后和已知结果比较,前两个显然是进行rc4加密,最后一个函数三个一组,相互异或,最后再逐位和密钥异或,逆运算即可
1 | target = [0xA3, 0x1A, 0xE3, 0x69, 0x2F, 0xBB, 0x1A, 0x84, 0x65, 0xC2, 0xAD, 0xAD, 0x9E, 0x96, 0x05, 0x02, 0x1F, 0x8E, 0x36, |
little_evil
程序本身解压squashfs,得到里面ruby环境和需要执行的rb代码,binwalk跑一下解压出来,得到一个混淆过后的ruby代码
1 | $l1Il="";$l1lI="";def llIl()$lI1lll=$lI1lll|7;end;def l1lll()$lI1lll=10;end;def llI1l()$lI1lll=$lI1lll|4;end;def lIlI()$lI1lll=$lI1lll+3;end;def l111()$lI1lll=$lI1lll%3;end;def lI1IlI()$lI1lll=$lI1lll|3;end;def ll1l1()$lI1lll=$lI1lll*8;end;def l1lI()$lI1lll=$lI1lll-3;end;def lI1lII()$lI1lll=$lI1lll%1;end;def lIlIl()$lI1lll=$lI1lll&10;end;def lIll()$lI1lll=$lI1lll-4;end;def lII1()$lI1lll=$lI1lll%2;end;def l1III()$lI1lll=$lI1lll|1;end;def l1l111()$lI1lll=$lI1lll|5;end;def l1IIII()$lI1lll=$lI1lll%10;end;def l11I()$l1Il=$l1Il+$lI1lll.chr;end;def lIlll()$lI1lll=$lI1lll*9;end;def l11IlI()$lI1lll=$lI1lll-8;end;def lI1I1()$lI1lll=$lI1lll+5;end;def ll11lI()$lI1lll=$lI1lll&9;end;def lII1l1()send($l1Il[0,4], $l1Il[4,$l1Il.length]);end;l1lll;lIlI;ll1l1;l1lI;l11I;l1lll;llI1l;lIlll;l11IlI;l11I;l1lll;lIlll;llI1l;lIlI;l11I;l1lll;llIl;l1lI;lIlll;l11I;l1lll;llI1l;l1IIII;lIlll;l11I;l1lll;llIl;l1lI;lIlll;l11I;l1lll;llIl;l1lI;lIlll;l11I;l1lll;llIl;l1lI;lIlll;l11I;l1lll;llIl;l1lI... |
发现进行了许多赋值和字符串拼接,没有输入输出等操作,因此将send改为puts输出最终结果,可以看到使用eval执行了另一段代码
1 | $llll=""; |
同样的方法改成puts之后输出
1 | begin $_=$$/$$; |
虚拟机,按指令运行,5和6之间进行循环,读取一下指令
1 | op='3351635164300000000540000000003164073000000540000003164070070000071730000000541111111131641175160343516445163530440316354031643451634235163516000000054000000000003164344354131645335163435164444516333530444403331635403164344451665163423516351600000054000000000316413443541316453351634351644445163335304444033316354031643444516651634235163516000000005400000000000316403443541316453351634351644445163335304444033316354031643444516651634235163516000000005400000000000031640344354131645335163435164444516333530444403331635403164344451665163423516351600000540000000000031643443541316453351634351644445163335304444033316354031643444516651635164453030441633544033164533516351643000000005400000000003164171111744516644' |
之后分析解析的指令,使用这种方式进行输出
1 | stack[idx]+=8 |
前几段代码输出Input:
之后进行输入并验证,验证方法时进行循环,如果循环可以正常结束则最终会输出ok,如果不能则异常结束,没有输出
1 | stack[idx]=getch() |
每一个循环都这样处理,循环本身是跑不出来的,所以成功的条件就是ch-77为0,不会进入循环,对于每一个循环都会得到一个数,一共5个输入,得到M5Ya7,测试成功,计算md5即可
Comments