-
-
[原创]CTF2018第一题分析(qwertyaa)
-
发表于: 2018-6-16 12:13 2169
-
首先下载打开,发现为命令行界面,猜测关键代码很可能直接写在main函数内,于是直接拖入IDA进行分析。
在IDA中直接按F5(Hex-Rays)进行分析,看到如下代码:
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 | int __cdecl main( int argc, const char * * argv, const char * * envp) { signed int v3; / / ebx char v4; / / al int result; / / eax int v6; / / [esp + 0h ] [ebp - 70h ] int v7; / / [esp + 0h ] [ebp - 70h ] char v8; / / [esp + 12h ] [ebp - 5Eh ] char v9[ 20 ]; / / [esp + 14h ] [ebp - 5Ch ] char v10; / / [esp + 28h ] [ebp - 48h ] __int16 v11; / / [esp + 48h ] [ebp - 28h ] char v12; / / [esp + 4Ah ] [ebp - 26h ] char v13; / / [esp + 4Ch ] [ebp - 24h ] strcpy(&v13, "437261636b4d654a757374466f7246756e" ); while ( 1 ) { memset(&v10, 0 , 0x20u ); v11 = 0 ; v12 = 0 ; sub_40134B(aPleaseInputYou, v6); scanf(aS, v9); if ( strlen(v9) > 17 ) break ; v3 = 0 ; do { v4 = v9[v3]; if ( !v4 ) break ; sprintf(&v8, asc_408044, v4); strcat(&v10, &v8); + + v3; } while ( v3 < 17 ); if ( !strcmp(&v10, &v13) ) sub_40134B(aSuccess, v7); else sub_40134B(aWrong, v7); } sub_40134B(aWrong, v7); result = stru_408090._cnt - - - 1 ; if ( stru_408090._cnt < 0 ) return _filbuf(&stru_408090); + + stru_408090._ptr; return result; } |
可以看出,这段代码将读入内容检查长度不会超过17字符后进行转换,将转换结果与字符串437261636b4d654a757374466f7246756e
比对,相同就会提示success
,否则提示wrong
。并且不知处于什么原因,这段代码会循环执行直至存在非法输入。
进一步的,我们分析转换的内容,很容易得出,转换是在同过sprintf("%x",input[i]);
将输入内容的二进制内容用HEX串表示出来。
于是我们编写php程序来解码字符串437261636b4d654a757374466f7246756e
。
1 2 | <?php echo hex2bin( '437261636b4d654a757374466f7246756e' ); |
得到输出CrackMeJustForFun
即为本题flag。
最后于 2018-6-16 12:13
被qwertyaa编辑
,原因:
赞赏
他的文章
赞赏
雪币:
留言: