FILE缓冲区溢出漏洞的解决方案(2)

在00b526f1函数位置,会调用php_tidy的一个函数,单步步过时,可以看到加载了一系列dll,比如DNSAPI,mswsock,可以猜测这个函数的主要功能应该是和第一个参数的服务器建立连接,观察一下这个call函数的参数。

0:000> bp 00b526f1
*** WARNING: Unable to verify checksum for C:\php\ext\php_tidy.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\php\ext\php_tidy.dll -
0:000> g
Breakpoint 1 hit
eax=00a10001 ebx=00a1e358 ecx=00a1d928 edx=00a1e2e0 esi=00000000 edi=003b3bc8
eip=00b526f1 esp=0012fac4 ebp=00a1e2e0 iopl=0         nv up ei pl nz ac po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000212
php_tidy!get_module+0x16f1:
00b526f1 e8ca010000      call    php_tidy!get_module+0x18c0 (00b528c0)
0:000> dd esp
0012fac4  00a1d928 00a10001 003b3bc8 00a1e2e0
0:000> dc 00a1d928
00a1d928  70747468 772f2f3a 622e7777 75646961 
00a1d938  6d6f632e baadf000 abababab abababab  .com............

第一个参数的内容就是tidy_parse_file函数的第一个参数,果然没错,这个函数执行完毕后继续单步跟踪。

0:000> p
eax=00a1e420 ebx=00a1e358 ecx=00a1da80 edx=00a1e3e8 esi=00a1d8b8 edi=003b3bc8
eip=00b5287e esp=0012fae0 ebp=00a1e2e0 iopl=0         nv up ei pl zr na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246
php_tidy!get_module+0x187e:
00b5287e 50              push    eax
0:000> p
eax=00a1e420 ebx=00a1e358 ecx=00a1da80 edx=00a1e3e8 esi=00a1d8b8 edi=003b3bc8
eip=00b5287f esp=0012fadc ebp=00a1e2e0 iopl=0         nv up ei pl zr na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246
php_tidy!get_module+0x187f:
00b5287f e83c260000      call    php_tidy!get_module+0x3ec0 (00b54ec0)

程序执行到00b5287f地址位置,这里再次调用了一个call函数,来看一下参数情况。

0:000> dd esp
0012fadc  00a1e420 00a1da80 003b3bc8 0012fb88

0:000> dd 00a1da80
00a1da80  41414141 41414141 41414141 41414141
00a1da90  41414141 41414141 41414141 41414141
00a1daa0  41414141 41414141 41414141 41414141
00a1dab0  41414141 41414141 41414141 41414141
00a1dac0  41414141 41414141 41414141 41414141
00a1dad0  41414141 41414141 41414141 41414141
00a1dae0  41414141 41414141 41414141 41414141
00a1daf0  41414141 41414141 41414141 41414141

终于接收到了畸形字符串,作为第二个参数传入。查看一下这个函数的IDA pro伪代码。

signed int __cdecl sub_10004EC0(int a1, int a2) { signed int result; // eax@2 if ( a1 ) result = sub_1000AC30(a1, a2); else result = -22; return result; }

很简单的函数逻辑,第二个参数会作为内部参数再次传递,调用sub_1000AC30,或者直接返回-22,单步跟踪。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/cb369e93158f3a99d63a181b59322190.html