Function at 0x407781
Capabilities:
Connect socket
Receive data
Receive data on socket
Send data
Send data on socket

Disassembly:
mov edi, edi
push ebp
mov ebp, esp
sub esp, 0x338
mov eax, dword [0x40e2a4]
xor eax, ebp
mov dword [ebp - 8], eax
mov eax, dword [ebp + 8]
push ebx
push esi
push edi
xor esi, esi
mov dword [ebp - 0x318], eax
push 0x100
lea eax, [ebp - 0x10c]
mov dword [ebp - 0x338], ecx
mov ebx, edx
mov dword [ebp - 0x31c], esi
push esi
push eax
mov dword [ebp - 0x334], ebx
mov dword [ebp - 0x324], esi
mov dword [ebp - 0x32c], esi
mov dword [ebp - 0x328], esi
call sub.msvcrt.dll_memset
add esp, 0xc
mov dword [ebp - 0x320], esi
lea eax, [ebp - 0x30c]
mov edx, 0xfc
mov ecx, ebx
push dword [0x40e3bc]
push 0x200
push eax
call fcn.0040a7e0
mov ebx, eax
test ebx, ebx
jns 0x407825
test byte [0x40e3c8], 2
je 0x407c78
push 0xcd
push 2
call fcn.0040b1f1
pop ecx
jmp 0x407879
mov eax, dword [0x411bf0]
mov edi, dword [eax + 8]
test edi, edi
jne 0x407839
mov eax, dword [eax + 0xc]
mov eax, dword [eax]
mov edi, dword [eax + 8]
add edi, 0x20
mov ecx, 0x3500
push 2
pop edx
movzx eax, word [edi]
cmp ax, dx
jne 0x407850
mov word [edi + 2], cx
cmp eax, 0x17
jne 0x407859
mov word [edi + 2], cx
push 0
push 1
push eax
call dword [sym.imp.WS2_32.dll_socket]
mov dword [0x40e2b0], eax
cmp eax, 0xffffffff
jne 0x40787f
push 0x40314c
call dword [sym.imp.msvcrt.dll_perror]
pop ecx
jmp 0x407c78
push dword [edi + 0x20]
push edi
push eax
call dword [sym.imp.WS2_32.dll_connect]
or edi, 0xffffffff
cmp eax, edi
jne 0x4078b6
call dword [sym.imp.WS2_32.dll_WSAGetLastError]
cmp eax, 0x274d
jne 0x4078a5
push 0xfffffffffffffffb
jmp 0x40796f
push 0x403158
call dword [sym.imp.msvcrt.dll_perror]
pop ecx
jmp 0x40796d
push ebx
call dword [sym.imp.WS2_32.dll_htons]
push 0
mov word [ebp - 0x310], ax
lea eax, [ebp - 0x310]
push 2
push eax
push dword [0x40e2b0]
call dword [sym.imp.WS2_32.dll_send]
cmp eax, edi
je 0x407c5a
push 0
push ebx
lea eax, [ebp - 0x30c]
push eax
push dword [0x40e2b0]
call dword [sym.imp.WS2_32.dll_send]
cmp eax, edi
je 0x407c5a
mov ecx, dword [0x411bf0]
cmp dword [ecx + 8], esi
jne 0x407911
mov eax, dword [ecx + 0xc]
mov ecx, dword [eax]
push dword [ecx]
push 0x403170
push 1
call fcn.0040ccf9
pop ecx
push eax
call dword [sym.imp.msvcrt.dll_fprintf]
mov ebx, dword [ebp - 0x318]
add esp, 0xc
test ebx, ebx
jne 0x407943
push 1
call fcn.0040ccf9
pop ecx
mov dword [0x412300], eax
jmp 0x4079bf
push ecx
lea edx, [ebp - 0x10c]
mov ecx, ebx
call fcn.0040b4c8
mov dword [0x412300], eax
test eax, eax
jne 0x407989
lea eax, [ebp - 0x10c]
push eax
push 0xc
push 2
call fcn.0040b1f1
add esp, 0xc
push 0xfffffffffffffffd
pop esi
push dword [0x40e2b0]
call dword [sym.imp.WS2_32.dll_closesocket]
mov dword [0x40e2b0], edi
mov eax, esi
jmp 0x407c7b
push ebx
push 0x403178
push eax
call dword [sym.imp.msvcrt.dll_fprintf]
mov ecx, dword [0x411bf0]
add esp, 0xc
cmp dword [ecx + 8], esi
jne 0x4079a9
mov eax, dword [ecx + 0xc]
mov ecx, dword [eax]
push dword [ecx]
push 0x403170
push dword [0x412300]
call dword [sym.imp.msvcrt.dll_fprintf]
add esp, 0xc
mov ebx, 0x402b38
cmp dword [0x411bf4], esi
jne 0x407b3d
push 2
lea esi, [ebp - 0x330]
pop ebx
push 0
push ebx
push esi
push dword [0x40e2b0]
call dword [sym.imp.WS2_32.dll_recv]
mov edi, eax
test edi, edi
je 0x4079f7
sub ebx, edi
add esi, edi
test ebx, ebx
jg 0x4079d9
mov esi, dword [ebp - 0x320]
cmp edi, 0xffffffff
je 0x407bee
cmp edi, 2
jb 0x407bee
push dword [ebp - 0x330]
call dword [sym.imp.WS2_32.dll_htons]
mov word [ebp - 0x310], ax
test ax, ax
je 0x407b51
mov ecx, dword [0x411bec]
movzx ebx, ax
cmp ebx, ecx
jle 0x407a68
test ecx, ecx
je 0x407a50
push dword [0x411be8]
call dword [sym.imp.msvcrt.dll_free]
mov ax, word [ebp - 0x310]
pop ecx
movzx ebx, ax
push ebx
mov dword [0x411bec], ebx
call dword [sym.imp.msvcrt.dll_malloc]
pop ecx
mov dword [0x411be8], eax
jmp 0x407a6d
mov eax, dword [0x411be8]
mov dword [ebp - 0x314], eax
test ebx, ebx
je 0x407aa9
mov esi, eax
push 0
push ebx
push esi
push dword [0x40e2b0]
call dword [sym.imp.WS2_32.dll_recv]
mov edi, eax
test edi, edi
jle 0x407a97
sub ebx, edi
add esi, edi
test ebx, ebx
jg 0x407a79
mov dword [ebp - 0x314], esi
mov esi, dword [ebp - 0x320]
mov eax, dword [ebp - 0x314]
cmp edi, 0xffffffff
je 0x407be7
lea ecx, [ebp - 0x328]
push ecx
lea ecx, [ebp - 0x31c]
push ecx
push dword [ebp - 0x334]
push dword [ebp - 0x338]
push eax
call fcn.00407c8e
mov dword [ebp - 0x32c], eax
test eax, eax
jne 0x407b4e
cmp dword [ebp - 0x318], eax
je 0x407b22
mov edx, dword [ebp - 0x31c]
mov ecx, edx
sub ecx, dword [ebp - 0x324]
cmp ecx, 0x32
jle 0x407b22
push 0x403180
push 1
mov dword [ebp - 0x324], edx
call fcn.0040ccf9
pop ecx
push eax
call dword [sym.imp.msvcrt.dll_fprintf]
push 1
call fcn.0040ccf9
push eax
call dword [sym.imp.msvcrt.dll_fflush]
add esp, 0x10
cmp dword [ebp - 0x328], 2
jge 0x407b51
cmp dword [0x411bf4], 0
je 0x4079d0
mov ebx, 0x402b38
and dword [0x411bf4], 0
push ebx
call dword [sym.imp.msvcrt.dll_printf]
pop ecx
jmp 0x407b56
push 3
pop esi
mov ebx, 0x402b38
mov edi, dword [ebp - 0x318]
test edi, edi
je 0x407b8d
mov ecx, dword [ebp - 0x31c]
mov edx, 0x402d3a
mov eax, 0x403184
cmp ecx, 1
jne 0x407b77
mov eax, edx
cmp ecx, 0x32
jge 0x407b7e
mov ebx, edx
push eax
push ecx
push ebx
push 0x21
push 1
call fcn.0040b1f1
add esp, 0x14
push dword [0x40e2b0]
call dword [sym.imp.WS2_32.dll_closesocket]
or dword [0x40e2b0], 0xffffffff
test edi, edi
je 0x407bbc
mov eax, dword [0x412300]
test eax, eax
je 0x407bbc
push eax
call dword [sym.imp.msvcrt.dll_fclose]
and dword [0x412300], 0
pop ecx
sub esi, 0
je 0x407c56
sub esi, 1
je 0x407c78
sub esi, 1
je 0x407bf6
sub esi, 1
jne 0x407c78
mov eax, dword [ebp - 0x32c]
jmp 0x407c7b
push 2
jmp 0x407b50
xor esi, esi
inc esi
jmp 0x407b51
mov esi, dword [0x411be8]
push 0xd0
push 2
call fcn.0040b1f1
movzx eax, word [esi + 0xa]
pop ecx
pop ecx
push eax
call dword [sym.imp.WS2_32.dll_ntohs]
movzx eax, ax
push eax
movzx eax, word [esi + 8]
push eax
call dword [sym.imp.WS2_32.dll_ntohs]
movzx eax, ax
push eax
movzx eax, word [esi + 6]
push eax
call dword [sym.imp.WS2_32.dll_ntohs]
movzx eax, ax
push eax
movzx eax, byte [esi + 3]
and eax, 0xf
push dword [eax*4 + 0x401050]
push 0xd1
push 2
call fcn.0040b1f1
add esp, 0x18
jmp 0x407c78
xor eax, eax
jmp 0x407c7b
push 0x403164
call dword [sym.imp.msvcrt.dll_perror]
pop ecx
push dword [0x40e2b0]
call dword [sym.imp.WS2_32.dll_closesocket]
mov dword [0x40e2b0], edi
push 0xfffffffffffffffd
pop eax
mov ecx, dword [ebp - 8]
pop edi
pop esi
xor ecx, ebp
pop ebx
call fcn.0040c730
mov esp, ebp
pop ebp
ret 4