这道题异常复杂仅有5人做出来。在参看大牛们的wp和自己的一些心得后特撰写此文。
初步跟踪程序时,发现到了sub_404A60就会中断退出
00401589 call handler_404A60
用ida插件FindCrypt发现程序可能使用了CRC32算法,据此可定位到函数sub_401320,而该函数刚好被sub_404A60调用。
sub_404A60被多次调用,主要功能为对一段代码进行CRC32校验,然后根据校验值获取函数地址执行跳转,或者作为sub_404A60返回值。当在程序某条指令下软件断点或修改某些关键数据时,程序将执行错误流程。这也是为什么当初跟踪程序时老是提示错误,指示内存地址2DEBF382不可读。所以用软件断点的调试方法在这里行不通,需要使用硬件断点。
下面来对程序逻辑进行说明:
获取输入flag
0040152D call _fgets
执行sub_404A60时将调用sub_4013C0对输入flag进行校验:要求字符集为0-9, a-z, A-Z
00401589 E8 D2340000 call 00404A60
将输入flag转换为62进制数
004015FE . E8 7D320000 call 00404880
此时执行sub_404A60将返回0x100
0040165D . E8 FE330000 call 00404A60
初始化为一个62进制的数据1
0040168D . E8 4E0E0000 call 004024E0
在这里,可以看到IDA F5出的伪码,显示很多函数传递了几十个参数,而动态跟踪时却发现其实没有这么多参数,有可能是传递了一个大数。
根据多次调试,确定了各函数的对应功能
给257个大数结构分配空间,并进行初始化
004016B1 . 50 push eax
004016B2 . E8 E6360000 call 00404D9D
004016D8 > /8B4D E0 mov ecx, dword ptr [ebp-0x20]
004016DB . |E8 600D0000 call 00402440
004016E0 . |8B4D E0 mov ecx, dword ptr [ebp-0x20]
004016E3 . |8B45 EC mov eax, dword ptr [ebp-0x14]
004016E6 . |81C1 10020000 add ecx, 0x210
004016EC . |48 dec eax
004016ED . |894D E0 mov dword ptr [ebp-0x20], ecx
004016F0 . |8945 EC mov dword ptr [ebp-0x14], eax
004016F3 .^\75 E3 jnz short 004016D8
再给另外257个大数结构分配空间,并调用sub_4049D0进行初始化
0040170D . 51 push ecx
0040170E . E8 8A360000 call 00404D9D
00401713 . 83C4 04 add esp, 0x4
00401716 . 8945 EC mov dword ptr [ebp-0x14], eax
00401719 . 85C0 test eax, eax
0040171B . C745 FC 01000>mov dword ptr [ebp-0x4], 0x1
00401722 . 74 18 je short 0040173C
00401724 . 68 40244000 push 00402440 ; 入口地址
00401729 . 56 push esi
0040172A . 8BD0 mov edx, eax
0040172C . 68 10020000 push 0x210
00401731 . 52 push edx
00401732 . E8 99320000 call 004049D0
生成了一个0-256的表,存0-256这些数字作为62进制、256进制大整数分别存到上述两个大数结构中
00401776 > /8B45 C8 mov eax, dword ptr [ebp-0x38]
00401779 . |81EC 10020000 sub esp,0x210
0040177F . |B9 84000000 mov ecx, 0x84
00401784 . |8DB5 20F9FFFF lea esi,dword ptr [ebp-0x6E0]
0040178A . |8BFC mov edi, esp
0040178C . |8D95 F0F2FFFF lea edx,dword ptr [ebp-0xD10]
00401792 . |F3:A5 rep movs dword ptr es:[edi], dword p>
00401794 . |52 push edx
00401795 . |8D0C18 lea ecx, dword ptr [eax+ebx]
00401798 . |E8 030E0000 call 004025A0
0040179D . |8B7D E0 mov edi, dword ptr [ebp-0x20]
004017A0 . |B9 84000000 mov ecx, 0x84
004017A5 . |8BF0 mov esi, eax
004017A7 . |81EC 10020000 sub esp,0x210
004017AD . |F3:A5 rep movs dword ptr es:[edi], dword p>
004017AF . |8D8B 10020000 lea ecx, dword ptr [ebx+0x210]
004017B5 . |8DB5 00F5FFFF lea esi,dword ptr [ebp-0xB00]
004017BB . |894D C0 mov dword ptr [ebp-0x40], ecx
004017BE . |B9 84000000 mov ecx, 0x84
004017C3 . |8BFC mov edi, esp
004017C5 . |8D95 C0ECFFFF lea edx, dword ptr [ebp-0x1340]
004017CB . |F3:A5 rep movs dword ptr es:[edi], dword p>
004017CD . |52 push edx
004017CE . |8BCB mov ecx, ebx
004017D0 . |E8 CB0D0000 call 004025A0
004017D5 . |8B5D C0 mov ebx, dword ptr [ebp-0x40]
004017D8 . |B9 84000000 mov ecx, 0x84
004017DD . |8BF0 mov esi, eax
004017DF . |8B45 EC mov eax, dword ptr [ebp-0x14]
004017E2 . |8BFB mov edi, ebx
004017E4 . |F3:A5 rep movs dword ptr es:[edi], dword p>
004017E6 . |8B4D E0 mov ecx, dword ptr [ebp-0x20]
004017E9 . |81C1 10020000 add ecx,0x210
004017EF . |48 dec eax
004017F0 . |894D E0 mov dword ptr [ebp-0x20], ecx
004017F3 . |8945 EC mov dword ptr [ebp-0x14], eax
004017F6 .^\0F85 7AFFFFFF jnz 00401776
经过多次调试,发现程序中操作的大数结构,实际是一个任意进制大整数的对象,定义如下
__int32 base; //进制
__int32 is_invalid; //是否正常,是则0
__int32 length; //长度
__int8 is_negative; //是否是负数,是则1
__int8 buf[0x200]; //内容
要求flag>0
00401845 . E8 C60F0000 call 00402810
将flag由62进制转换为256进制
00401852 . 8B45 D8 mov eax, dword ptr [ebp-0x28]
00401855 . 8B55 E4 mov edx, dword ptr [ebp-0x1C]
00401858 . 8BC8 mov ecx, eax
0040185A . C1E1 05 shl ecx, 0x5
0040185D . 03C8 add ecx, eax
0040185F . C1E1 04 shl ecx, 0x4
00401862 . 03CA add ecx, edx
00401864 . 894D EC mov dword ptr [ebp-0x14], ecx
00401867 > 8B75 EC mov esi, dword ptr [ebp-0x14]
0040186A . 81EC 10020000 sub esp, 0x210
00401870 . B9 84000000 mov ecx, 0x84
00401875 . 8BFC mov edi, esp
00401877 . F3:A5 rep movs dword ptr es:[edi], dword p>
00401879 . 8D85 E0F0FFFF lea eax, dword ptr [ebp-0xF20]
0040187F . 8D8D 40FDFFFF lea ecx, dword ptr [ebp-0x2C0]
00401885 . 50 push eax
00401886 . E8 C5130000 call 00402C50
0040188B . 8B45 D8 mov eax, dword ptr [ebp-0x28]
0040188E . 33DB xor ebx, ebx
00401890 . 85C0 test eax, eax
00401892 . 0F86 0E010000 jbe 004019A6
00401898 . 8B4D E4 mov ecx, dword ptr [ebp-0x1C]
0040189B . 894D E0 mov dword ptr [ebp-0x20], ecx
0040189E > 8B75 E0 mov esi, dword ptr [ebp-0x20]
004018A1 . 81EC 10020000 sub esp, 0x210
004018A7 . B9 84000000 mov ecx, 0x84
004018AC . 8BFC mov edi, esp
004018AE . F3:A5 rep movs dword ptr es:[edi], dword p>
004018B0 . 8D8D E0F0FFFF lea ecx, dword ptr [ebp-0xF20]
004018B6 . E8 550F0000 call 00402810
004018BB . 85C0 test eax, eax
004018BD . 74 19 je short 004018D8
004018BF . 8B4D E0 mov ecx, dword ptr [ebp-0x20]
004018C2 . 8B45 D8 mov eax, dword ptr [ebp-0x28]
004018C5 . 43 inc ebx
004018C6 . 81C1 10020000 add ecx, 0x210
004018CC . 3BD8 cmp ebx, eax
004018CE . 894D E0 mov dword ptr [ebp-0x20], ecx
004018D1 .^ 72 CB jb short 0040189E
004018D3 . E9 CE000000 jmp 004019A6
004018D8 > 8B7D D0 mov edi, dword ptr [ebp-0x30]
004018DB . 8BF3 mov esi, ebx
004018DD . C1E6 05 shl esi, 0x5
004018E0 . 03F3 add esi, ebx
004018E2 . B9 84000000 mov ecx, 0x84
004018E7 . C1E6 04 shl esi, 0x4
004018EA . 03F7 add esi, edi
004018EC . 8DBD D0EEFFFF lea edi, dword ptr [ebp-0x1130]
004018F2 . F3:A5 rep movs dword ptr es:[edi], dword p>
004018F4 . 81EC 10020000 sub esp, 0x210
004018FA . B9 84000000 mov ecx, 0x84
004018FF . 8DB5 E0F0FFFF lea esi, dword ptr [ebp-0xF20]
00401905 . 8BFC mov edi, esp
00401907 . F3:A5 rep movs dword ptr es:[edi], dword p>
00401909 . 8D95 F0F2FFFF lea edx, dword ptr [ebp-0xD10]
0040190F . 8D8D 40FDFFFF lea ecx, dword ptr [ebp-0x2C0]
00401915 . 52 push edx
00401916 . E8 950F0000 call 004028B0
0040191B . B9 84000000 mov ecx, 0x84
00401920 . 8BF0 mov esi, eax
00401922 . 8DBD 40FDFFFF lea edi, dword ptr [ebp-0x2C0]
00401928 . 81EC 10020000 sub esp, 0x210
0040192E . F3:A5 rep movs dword ptr es:[edi], dword p>
00401930 . 8B75 EC mov esi, dword ptr [ebp-0x14]
00401933 . B9 84000000 mov ecx, 0x84
00401938 . 8BFC mov edi, esp
0040193A . 8D85 C0ECFFFF lea eax, dword ptr [ebp-0x1340]
00401940 . F3:A5 rep movs dword ptr es:[edi], dword p>
00401942 . 50 push eax
00401943 . 8D8D 40FDFFFF lea ecx, dword ptr [ebp-0x2C0]
00401949 . E8 521A0000 call 004033A0
0040194E . B9 84000000 mov ecx, 0x84
00401953 . 8BF0 mov esi, eax
00401955 . 8DBD 40FDFFFF lea edi, dword ptr [ebp-0x2C0]
0040195B . F3:A5 rep movs dword ptr es:[edi], dword p>
0040195D . 8B75 C8 mov esi, dword ptr [ebp-0x38]
00401960 . 8D8D D0EEFFFF lea ecx, dword ptr [ebp-0x1130]
00401966 . 56 push esi
00401967 . E8 D4110000 call 00402B40
0040196C . 46 inc esi
0040196D . 81EC 10020000 sub esp, 0x210
00401973 . 8975 C8 mov dword ptr [ebp-0x38], esi
00401976 . B9 84000000 mov ecx, 0x84
0040197B . 8DB5 D0EEFFFF lea esi, dword ptr [ebp-0x1130]
00401981 . 8BFC mov edi, esp
00401983 . F3:A5 rep movs dword ptr es:[edi], dword p>
00401985 . 8D8D B0EAFFFF lea ecx, dword ptr [ebp-0x1550]
0040198B . 51 push ecx
0040198C . 8D8D 30FBFFFF lea ecx, dword ptr [ebp-0x4D0]
00401992 . E8 090C0000 call 004025A0
00401997 . B9 84000000 mov ecx, 0x84
0040199C . 8BF0 mov esi, eax
0040199E . 8DBD 30FBFFFF lea edi, dword ptr [ebp-0x4D0]
004019A4 . F3:A5 rep movs dword ptr es:[edi], dword p>
004019A6 > 8B75 E4 mov esi, dword ptr [ebp-0x1C]
004019A9 . 81EC 10020000 sub esp, 0x210
004019AF . B9 84000000 mov ecx, 0x84
004019B4 . 8BFC mov edi, esp
004019B6 . F3:A5 rep movs dword ptr es:[edi], dword p>
004019B8 . 8D8D 40FDFFFF lea ecx, dword ptr [ebp-0x2C0]
004019BE . E8 4D0E0000 call 00402810
004019C3 . 85C0 test eax, eax
004019C5 .^ 0F85 9CFEFFFF jnz 00401867
004019CB . 8B5D D4 mov ebx, dword ptr [ebp-0x2C]
004019CE > 8A55 DE mov dl, byte ptr [ebp-0x22]
004019D1 . B9 84000000 mov ecx, 0x84
004019D6 . 8DB5 30FBFFFF lea esi, dword ptr [ebp-0x4D0]
004019DC . 8BFB mov edi, ebx
004019DE . F3:A5 rep movs dword ptr es:[edi], dword p>
004019E0 . 8853 0C mov byte ptr [ebx+0xC], dl
将转换为256进制数拷贝到另一个缓冲区
00401A10 . F3:A5 rep movs dword ptr es:[edi], dword ptr [esi]
检查头4个字节,判断范围在(1, 0x18),且bytes[0] + 4 == bytes[1]
00401A19 . 8A02 mov al, byte ptr [edx]
00401A1B . 3C 01 cmp al, 0x1
00401A1D . 0F82 C3090000 jb 004023E6
00401A23 . 3C 18 cmp al, 0x18
00401A25 . 0F87 BB090000 ja 004023E6
00401A2B . 8A4A 01 mov cl, byte ptr [edx+0x1]
00401A2E . 80F9 01 cmp cl, 0x1
00401A31 . 884D EC mov byte ptr [ebp-0x14], cl
00401A34 . 0F82 AC090000 jb 004023E6
00401A3A . 80F9 18 cmp cl, 0x18
00401A3D . 0F87 A3090000 ja 004023E6
00401A43 . 8A5A 02 mov bl, byte ptr [edx+0x2]
00401A46 . 80FB 01 cmp bl, 0x1
00401A49 . 0F82 97090000 jb 004023E6
00401A4F . 80FB18 cmp bl, 0x18
00401A52 . 0F87 8E090000 ja 004023E6
00401A58 . 8A4A 03 mov cl, byte ptr [edx+0x3]
00401A5B . 80F9 01 cmp cl, 0x1
00401A5E . 0F82 82090000 jb 004023E6
00401A64 . 80F9 18 cmp cl, 0x18
00401A67 . 0F87 79090000 ja 004023E6
00401A6D . 8B75 EC mov esi, dword ptr [ebp-0x14]
00401A70 . 25 FF000000 and eax, 0xFF
00401A75 . 81E6 FF000000 and esi, 0xFF
00401A7B . 8D50 04 lea edx, dword ptr [eax+0x4]
00401A7E . 3BD6 cmp edx, esi
bytes[0] + bytes[2] + bytes[3] + 8 == 总长度
00401A86 . 81E1 FF000000 and ecx, 0xFF
00401A8C . 81E3 FF000000 and ebx, 0xFF
00401A92 . 03C1 add eax, ecx
00401A94 . 8B4DD4 mov ecx, dword ptr [ebp-0x2C]
00401A97 . 8B51 08 mov edx, dword ptr [ecx+0x8]
00401A9A . 8D4403 08 lea eax, dword ptr [ebx+eax+0x8]
00401A9E . 3BC2 cmp eax, edx
此时sub_404A60返回0x400
00401ABA . E8 A12F0000 call 00404A60
给大数a分配空间
00401ACD . E8 CB320000 call 00404D9D
给大数a拷贝数据,len=bytes[0]
00401B18 . C1E9 02 shr ecx, 0x2
00401B1B . F3:A5 rep movs dword ptr es:[edi], dword ptr [esi]
00401B1D . 8BCA mov ecx, edx
00401B1F . 83E1 03 and ecx, 0x3
00401B22 . F3:A4 rep movs byte ptr es:[edi], byte ptr [esi]
00401B24 . 8BCB mov ecx, ebx
检查大数a的有效性
00401B26 . E8 350A0000 call 00402560
给大数b分配空间
00401B55 . E8 43320000 call 00404D9D
类似地,检查大数b的有效性,赋值
给大数c分配空间
00401BE1 . E8 B7310000 call 00404D9D
给大数d分配空间
00401C76 . E8 22310000 call 00404D9D
总结:把256进制数按顺序读4段,并放到4个大整数对象中,稍微整理下可得到这样的结构:
struct data{
char a_len; //bytes[0]
char b_len; //bytes[1]
char c_len; //bytes[2]
char d_len; //bytes[3]
char a[a_len];
char pad[4];
char c[c_len];
char d[d_len];
}
将”welcome to bbs.pediy.com.”转换为64进指数
00401D2B . E8 502B0000 call 00404880
将” Author by Lookhc”转换为64进制数
00401D61 . E8 1A2B0000 call 00404880
将大数a转换为36进制
00401DBB . E8 20240000 call 004041E0
对转换为36进制的大数a进行检查,要求返回1
00401E14 . E8 87F2FFFF call 004010A0
sub_4010A0这个函数很诡异,比较懵圈。刚开始将每个36进制字节重新解码为数字,然后拆分为低位和高位,分别扔到那个case里操作,要求验证0x1F次全部成功完成,且v6的值为0。这个东东实际是一个汉罗塔小游戏。
如何发现是汉罗塔呢?
由于该函数的返回值必须为1才能进行后续操作,遍历函数发现仅有1处返回1
发现最后*v6必须为0,刚开始时*v6为0x1f,每次获取参数后,模6分为2部分,传入swith结构,对*v6进行加与减。*v6减多少,别的数据就加多少,有点像把一个东西移到另一个地方
知道了是5层汉罗塔就好解决了。A BC分别为3根柱子,权值小的放在权值大的上面,0x1F刚好是(11111),最少的移动次序正好是31次。用0-5表示6种移动:即:A->B A->C B->A B->C C->A C->B,分别对应0,1,2,3,4,5
5层汉罗塔其中一种解法:
1→C,2→B,1→B,3→C,1→A,2→C,1→C,4→B;
1→B,2→A,1→A,3→B,1→C,2→B,1→B,5→C;
1→A,2→C,1→C,3→A,1→B,2→A,1→A,4→C;
1→C,2→B,1→B,3→C,1→A,2→C,1→C
上述解法对应
[1,0,5,1,2,3,1,0,5,4,2,5,1,0,5,1,2,3,1,2,5,4,2,3,1,0,5,1,2,3,1](6进制)
合并相邻的两个操作:(最后多余的一个必须是0)
[1, 11, 20, 1, 29, 32, 1, 11, 20, 13, 29,20, 1, 11, 20, 1](10进制)
转为36进制bytes:
blub36blun3ublub
转换为16进制,这个就是a
3dd7c4ddec9ae7c5e8c1(16进制)
即对256进制数据进行CRC32校验,必须返回0
00401E3F . E8 1C2C0000 call 00404A60
计算b^3
00401F42 > /8B45 D4 mov eax, dword ptr [ebp-0x2C]
00401F45 . |8D48 FF lea ecx, dword ptr [eax-0x1]
00401F48 . |3BD9 cmp ebx, ecx
00401F4A . |73 36 jnb short 00401F82
00401F4C . |8B75 E0 mov esi, dword ptr [ebp-0x20]
00401F4F . |81EC 10020000 sub esp,0x210
00401F55 . |B9 84000000 mov ecx, 0x84
00401F5A . |8BFC mov edi, esp
00401F5C . |F3:A5 rep movs dword ptr es:[edi], dword ptr[esi>
00401F5E . |8D95 50DEFFFF lea edx,dword ptr [ebp-0x21B0]
00401F64 . |8D8D 30FBFFFF lea ecx,dword ptr [ebp-0x4D0]
00401F6A . |52 push edx
00401F6B . |E8 B01C0000 call 00403C20
00401F70 . |B9 84000000 mov ecx, 0x84
00401F75 . |8BF0 mov esi, eax
00401F77 . |8DBD 30FBFFFF lea edi,dword ptr [ebp-0x4D0]
00401F7D . |43 inc ebx
00401F7E . |F3:A5 rep movs dword ptr es:[edi], dword ptr[esi>
00401F80 .^\EB C0 jmp short 00401F42
计算d^3
00401FDD > /8B45 D4 mov eax, dword ptr [ebp-0x2C]
00401FE0 . |8D48 FF lea ecx, dword ptr [eax-0x1]
00401FE3 . |3BD9 cmp ebx, ecx
00401FE5 . |73 36 jnb short 0040201D
00401FE7 . |8B75 E4 mov esi, dword ptr [ebp-0x1C]
00401FEA . |81EC 10020000 sub esp,0x210
00401FF0 . |B9 84000000 mov ecx, 0x84
00401FF5 . |8BFC mov edi, esp
00401FF7 . |F3:A5 rep movs dword ptr es:[edi], dword ptr[esi>
00401FF9 . |8D95 20D8FFFF lea edx,dword ptr [ebp-0x27E0]
00401FFF . |8D8D 40FDFFFF lea ecx,dword ptr [ebp-0x2C0]
00402005 . |52 push edx
00402006 . |E8 151C0000 call 00403C20
0040200B . |B9 84000000 mov ecx, 0x84
00402010 . |8BF0 mov esi, eax
00402012 . |8DBD 40FDFFFF lea edi,dword ptr [ebp-0x2C0]
00402018 . |43 inc ebx
00402019 . |F3:A5 rep movs dword ptr es:[edi], dword ptr[esi>
0040201B .^\EB C0 jmp short 00401FDD
计算c^3
00402070 > /8B45 D4 mov eax, dword ptr [ebp-0x2C]
00402073 . |48 dec eax
00402074 . |3BD8 cmp ebx, eax
00402076 . |73 36 jnb short 004020AE
00402078 . |8B75 C0 mov esi, dword ptr [ebp-0x40]
0040207B . |81EC 10020000 sub esp,0x210
00402081 . |B9 84000000 mov ecx, 0x84
00402086 . |8BFC mov edi, esp
00402088 . |F3:A5 rep movs dword ptr es:[edi], dword ptr[esi>
0040208A . |8D8D 40DCFFFF lea ecx,dword ptr [ebp-0x23C0]
00402090 . |51 push ecx
00402091 . |8D8D E0F0FFFF lea ecx,dword ptr [ebp-0xF20]
00402097 . |E8 841B0000 call 00403C20
0040209C . |B9 84000000 mov ecx, 0x84
004020A1 . |8BF0 mov esi, eax
004020A3 . |8DBD E0F0FFFF lea edi,dword ptr [ebp-0xF20]
004020A9 . |43 inc ebx
004020AA . |F3:A5 rep movs dword ptr es:[edi], dword ptr[esi>
004020AC .^\EB C2 jmp short 00402070
c^3+d^3
004020E3 . E8 B8040000 call 004025A0
c^3+d^3==b^3
004020FF . E8 0C070000 call 00402810
x ^ n + y^ n = z^ n (n>2,x,y>0) 无整数解(费马大定理)
显而易见,此处无整数解
如果前面的步骤全部正确,这个eax必须为0,从而触发异常
004022E9 > \8B45 C4 mov eax, dword ptr [ebp-0x3C]
看一看Exception Handler结构体,发现是跳到这里
显然这是为下面的lpMen=2创造条件
计算c+(-d)
00402178 . 8885 2CF9FFFF mov byte ptr [ebp-0x6D4], al //给d添加负号
0040217E . F3:A5 rep movs dword ptr es:[edi], dword ptr [esi>
00402180 . 8D8D C0ECFFFF lea ecx,dword ptr [ebp-0x1340]
00402186 . 51 push ecx
00402187 . 8BCB mov ecx, ebx
00402189 . E8 12040000 call 004025A0
c-d==”Author by Lookhc”
004021BB . E8 50060000 call 00402810
2c+4d
0040225F . E8 3C030000 call 004025A0
把64进制” welcome to bbs.pediy.com.”转换为256进制
0040228D . E8 4E1F0000 call 004041E0
” welcome to bbs.pediy.com.”与2c+4d的符号位是否一致?
0040229B . 3AC8 cmp cl, al
2c+4d==” welcome to bbs.pediy.com.”
将”Author by …”由64进制转换为10进制
13479427470606219437251685094
将"welcome ..."由64进制转换为10进制
1307640379757893473170432799524731441641106494
总结起来,即为求解大数二元一次方程
c-d=13479427470606219437251685094
2c+4d=1307640379757893473170432799524731441641106494
== >
c=217940063292982254514690446991601531774641145 (10)
d=217940063292982241035262976385382094522956051 (10)
c = 09c5d44875c2a969b2d8d6e76abd1b81a123f9(16)
d = 09c5d44875c2a93e24ed0b8784c9260ed63913(16)
由结构data可知,还需求出4字节pad
struct data{
char a_len; //bytes[0]
char b_len; //bytes[1]
char c_len; //bytes[2]
char d_len; //bytes[3]
char a[a_len];
char pad[4];
char c[c_len];
char d[d_len];
}
而根据之前分析的sub_404A60可以,data结构的CRC32校验值为0
00401E3F . E8 1C2C0000 call 00404A60
在网上找了段C语言CRC32的代码爆破得到填充的字节为0xA7,0x1C,0x2F,0x2C
全部连起来得到数字
0x09c5d44875c2a93e24ed0b8784c9260ed6391309c5d44875c2a969b2d8d6e76abd1b81a123f92c2f1ca73dd7c4ddec9ae7c5e8c113130e0a
转为62进制,即为Flag(http://ctf.ssleye.com/jinzhi.html)
6OqTbC16uYclIp3aqSoJuSpYO4I9JodXMs1oaaI40wwzue79rqVxXflyoZeLxs3Q1yxO1yUoz06
收获:
1. 此题用到了汉诺塔求解,费马大定理,大数二元一次方程,CRC32校验等算法
2. 大数的任意进制转换
3. 需要识别出大数间各种计算函数,修改F5出的代码
4. 只能设置硬件断点进行跟踪,如果采用软件断点则会退出程序
网友评论