By: riusksk (quange)
Blog: http://riusksk.blogbus.com
When the revc function is disconnected, we track and analyze it step by step and come:
00401DE0>/$56 PUSH ESI
00401DE1 |. 8BF1 mov esi, ECX
00401DE3 |. B9 00040000 mov ecx, 400
00401DE8 |. 6A 00 PUSH 0;/Flags = 0
00401DEA |. 8B46 18 mov eax, dword ptr ds: [ESI + 18]; |
00401DED |. 8B56 14 mov edx, dword ptr ds: [ESI + 14]; |
00401DF0 |. 2BC8 sub ecx, EAX; |
00401DF2 |. 03D0 add edx, EAX; |
00401DF4 |. 8B06 mov eax, dword ptr ds: [ESI]; |
00401DF6 |. 51 push ecx; | BufSize = 400 (1024 .)
00401DF7 |. 52 push edx; | Buffer = 013C1820
00401DF8 |. 50 push eax; | Socket
00401DF9 |. E8 6E190000 CALL <JMP. & WS2_32. #16>; ecv
00401DFE |. 85C0 test eax, EAX; Determine whether the number of received bytes is null
00401E00 |. 74 14 je short FTPServe.00401E16
00401E02 |. 83F8 ff cmp eax,-1; Determine whether to receive failed
00401E05 |. 74 0F je short FTPServe.00401E16
00401E07 |. 8B4E 18 mov ecx, dword ptr ds: [ESI + 18]; ecx = 0
00401E0A |. 03C8 add ecx, EAX; ecx = eax = number of bytes received
00401E0C |. B8 01000000 mov eax, 1
00401E11 |. 894E 18 mov dword ptr ds: [ESI + 18], ECX
00401E14 |. 5E POP ESI
00401E15 |. C3 RETN
00401E16 |> 33C0 xor eax, EAX
00401E18 |. 5E POP ESI
00401E19. C3 RETN
Continue the analysis:
004021FA |> 6A 05 PUSH 5
004021FC |. 68 68A44000 PUSH FTPServe.0040A468; ASCII "USER"
00402201 |. 57 PUSH EDI
00402202 |. E8 691B0000 CALL FTPServe.00403D70
00402207 |. 83C4 0C add esp, 0C
0040220A |. 85C0 test eax, EAX
0040220C |. 0F85 A3000000 JNZ FTPServe.004022B5
00402212 |. 83C9 ff or ecx, FFFFFFFF
00402215 |. 83C7 05 add edi, 5
00402218 |. F2: AE REPNE SCAS BYTE PTR ES: [EDI]
0040221A |. F7D1 NOT ECX
0040221C |. 2BF9 sub edi, ECX
0040221E |. 8D5D 1C lea ebx, dword ptr ss: [EBP + 1C]
00402221 |. 8BC1 mov eax, ECX
00402223 |. 8BF7 mov esi, EDI
00402225 |. C1E9 02 shr ecx, 2
00402228 |. 8BFB mov edi, EBX
0040222A |. 8D95 2C050000 lea edx, dword ptr ss: [EBP + 52C]
00402230 |. F3: A5 rep movs dword ptr es: [EDI], dword ptr ds: [ESI]
00402232 |. 8BC8 mov ecx, EAX
00402234 |. 33C0 xor eax, EAX
00402236 |. 83E1 03 and ecx, 3
00402239 |. 52 PUSH EDX
0040223A |. F3: A4 REP MOVS