Function at 0x401640
Capabilities:
Create tcp socket
Download and write a file
Receive and write data from server to client
Receive data
Receive data on socket
Set socket configuration
Write file on windows

Disassembly:
push ebp
mov ebp, esp
mov eax, 0x2598
call fcn.00512840
mov eax, dword [0x581e00]
xor eax, ebp
mov dword [ebp - 8], eax
mov eax, dword [ebp + 8]
push ebx
push esi
push edi
mov edi, ecx
xor ecx, ecx
mov esi, edx
mov dword [ebp - 0x258c], esi
mov dword [ebp - 0x2590], ecx
mov dword [ebp - 0x2594], ecx
mov dword [ebp - 0x2584], 0xffffffff
mov dword [ebp - 0x2580], ecx
mov dword [ebp - 0x2564], ecx
mov dword [ebp - 0x2560], ecx
mov dword [ebp - 0x256c], ecx
mov dword [ebp - 0x2568], ecx
mov dword [ebp - 0x2558], ecx
mov dword [ebp - 0x2598], 0xbb8
mov dword [ebp - 0x2588], ecx
cmp esi, ecx
je 0x4016bc
mov dword [esi], ecx
mov dword [esi + 4], ecx
push ecx
push 6
push 4
push ecx
push ecx
push 0xc0000000
push eax
call dword [sym.imp.KERNEL32.dll_CreateFileA]
mov dword [ebp - 0x2578], eax
cmp eax, 0xffffffff
jne 0x4016ef
xor eax, eax
xor edx, edx
pop edi
pop esi
pop ebx
mov ecx, dword [ebp - 8]
xor ecx, ebp
call fcn.0050cbf9
mov esp, ebp
pop ebp
ret
push 7
push str.http:__
push edi
call fcn.005127ac
add esp, 0xc
test eax, eax
je 0x40171c
push str.Protocol_must_be_HTTP._n
call fcn.00409470
mov ecx, dword [ebp - 0x2578]
add esp, 4
push ecx
jmp 0x401ba0
lea eax, [ebp - 0x54c]
push eax
lea ecx, [ebp - 0x4c]
push ecx
lea edx, [ebp - 0x14c]
push edx
mov eax, edi
call fcn.004012e0
add esp, 0xc
push 6
push 1
push 2
call dword [sym.imp.WS2_32.dll_socket]
mov edi, eax
mov dword [ebp - 0x2574], edi
cmp edi, 0xffffffff
je 0x401bc3
push 4
lea eax, [ebp - 0x2598]
push eax
push 0x1006
push 0xffff
push edi
call dword [sym.imp.WS2_32.dll_setsockopt]
lea ecx, [ebp - 0x14c]
push ecx
push edi
lea edx, [ebp - 0x4c]
call fcn.00401410
add esp, 8
test eax, eax
je 0x401c15
lea edx, [ebp - 0x54c]
push edx
mov eax, edi
push eax
lea ebx, [ebp - 0x14c]
call fcn.004014d0
add esp, 8
test eax, eax
je 0x401c15
lea ebx, [ebx]
push 0x2001
lea ecx, [ebp - 0x2554]
push 0
push ecx
call fcn.00510790
mov eax, dword [ebp - 0x2574]
add esp, 0xc
push 0
push 0x2000
lea edx, [ebp - 0x2554]
push edx
push eax
call dword [sym.imp.WS2_32.dll_recv]
mov ebx, eax
cmp ebx, 0xffffffff
je 0x401bdf
call dword [sym.imp.WS2_32.dll_WSAGetLastError]
cmp eax, 0x2749
je 0x401b62
cmp eax, 0x274a
je 0x401b62
cmp eax, 0x2744
je 0x401b62
cmp eax, 0x2746
je 0x401b62
cmp eax, 0x2745
je 0x401b62
cmp eax, 0x274c
je 0x401b47
test ebx, ebx
jne 0x40185f
mov eax, dword [ebp - 0x2588]
inc eax
mov dword [ebp - 0x2588], eax
cmp eax, 3
jb 0x401b20
inc dword [ebp - 0x2558]
mov dword [ebp - 0x2588], ebx
jmp 0x401b75
cmp dword [ebp - 0x2590], 0
je 0x4018b8
mov eax, dword [ebp - 0x2578]
xor edi, edi
add dword [ebp - 0x2564], ebx
push edi
lea ecx, [ebp - 0x2570]
adc dword [ebp - 0x2560], edi
push ecx
push ebx
lea edx, [ebp - 0x2554]
push edx
push eax
mov dword [ebp - 0x2570], edi
call dword [sym.imp.KERNEL32.dll_WriteFile]
cmp dword [ebp - 0x2570], ebx
je 0x4018a7
call dword [sym.imp.KERNEL32.dll_GetLastError]
add dword [ebp - 0x256c], ebx
adc dword [ebp - 0x2568], edi
jmp 0x401b17
lea edi, [ebp - 0x2554]
mov edi, edi
lea eax, [ebp + ebx - 0x2554]
cmp edi, eax
jae 0x401b17
push 4
push 0x560a5c
push edi
call fcn.0050cd53
add esp, 0xc
test eax, eax
je 0x401a60
mov al, byte [edi]
cmp al, 0x20
je 0x4018f9
cmp al, 9
je 0x4018f9
cmp al, 0xd
je 0x4018f9
cmp al, 0xa
jne 0x4018fc
inc edi
jmp 0x4018e7
push 8
push str.HTTP_1.1
push edi
call fcn.005127ac
add esp, 0xc
test eax, eax
jne 0x401988
lea esi, [edi + 8]
mov al, byte [esi]
cmp al, 0x20
je 0x40191d
cmp al, 9
jne 0x401920
inc esi
jmp 0x401913
push 0x560898
push esi
call fcn.0050ce20
add esp, 8
test eax, eax
jne 0x401951
push 0xa
push esi
call fcn.0050d070
add esp, 8
test eax, eax
jne 0x401951
mov eax, esi
lea edx, [eax + 1]
mov cl, byte [eax]
inc eax
test cl, cl
jne 0x401946
sub eax, edx
add eax, esi
mov cl, byte [eax]
push esi
push 0x56089c
mov byte [eax], 0
call fcn.00409470
push esi
mov byte [eax], cl
call fcn.0050cd32
add esp, 0xc
mov dword [ebp - 0x2594], eax
cmp eax, 0x190
jge 0x401c15
mov esi, dword [ebp - 0x258c]
jmp 0x401a43
push 0xe
push str.accept_ranges:
push edi
call fcn.005127ac
add esp, 0xc
test eax, eax
jne 0x4019d3
lea ecx, [edi + 0xe]
nop
mov al, byte [ecx]
cmp al, 0x20
je 0x4019aa
cmp al, 9
jne 0x4019ad
inc ecx
jmp 0x4019a0
push 4
push str.none
push ecx
call fcn.005127ac
add esp, 0xc
test eax, eax
jne 0x401a43
mov dword [ebp - 0x256c], eax
mov dword [ebp - 0x2568], eax
jmp 0x401a43
push 0xf
push str.content_length:
push edi
call fcn.005127ac
add esp, 0xc
test eax, eax
jne 0x401a1f
lea ecx, [edi + 0xf]
lea ebx, [ebx]
mov al, byte [ecx]
cmp al, 0x20
je 0x4019fa
cmp al, 9
jne 0x4019fd
inc ecx
jmp 0x4019f0
push ecx
call fcn.0050cd3d
add esp, 4
mov dword [ebp - 0x2584], eax
mov dword [ebp - 0x2580], edx
test esi, esi
je 0x401a43
mov ecx, eax
mov dword [esi], ecx
mov dword [esi + 4], edx
jmp 0x401a43
cmp dword [ebp - 0x2594], 0x12c
jl 0x401a43
push 9
push str.Location:
push edi
call fcn.005127ac
add esp, 0xc
test eax, eax
je 0x401ac7
push 0x560898
push edi
call fcn.0050ce20
mov edi, eax
add esp, 8
test edi, edi
jne 0x4018c0
jmp 0x401b17
mov ecx, dword [ebp - 0x2578]
add edi, 4
sub ebx, edi
lea esi, [ebp + ebx - 0x2554]
xor ebx, ebx
add dword [ebp - 0x2564], esi
push ebx
lea eax, [ebp - 0x2570]
adc dword [ebp - 0x2560], ebx
push eax
push esi
push edi
push ecx
mov dword [ebp - 0x2570], 0
mov dword [ebp - 0x2590], 1
call dword [sym.imp.KERNEL32.dll_WriteFile]
cmp dword [ebp - 0x2570], esi
je 0x401ab3
call dword [sym.imp.KERNEL32.dll_GetLastError]
add dword [ebp - 0x256c], esi
mov esi, dword [ebp - 0x258c]
adc dword [ebp - 0x2568], ebx
jmp 0x401b17
add edi, 9
lea ebx, [ebx]
mov al, byte [edi]
cmp al, 0x20
je 0x401ada
cmp al, 9
jne 0x401add
inc edi
jmp 0x401ad0
push 7
push str.http:__
push edi
call fcn.005127ac
add esp, 0xc
test eax, eax
jne 0x401c08
lea edx, [ebp - 0x54c]
push edx
lea eax, [ebp - 0x4c]
push eax
lea ecx, [ebp - 0x14c]
push ecx
mov eax, edi
call fcn.004012e0
add esp, 0xc
inc dword [ebp - 0x2558]
cmp dword [ebp - 0x2558], 0
jne 0x401b75
mov edx, dword [ebp - 0x2560]
cmp edx, dword [ebp - 0x2580]
ja 0x401b75
jb 0x4017b0
mov eax, dword [ebp - 0x2564]
cmp eax, dword [ebp - 0x2584]
jae 0x401b75
jmp 0x4017b0
call fcn.00401060
push eax
push str.Respond_timeout._s_n
call fcn.00409470
add esp, 8
inc dword [ebp - 0x2558]
jmp 0x401b75
call fcn.00401060
push eax
push str.The_network_has_been_disconnected._s_n
call fcn.00409470
add esp, 8
mov ecx, dword [ebp - 0x2574]
push ecx
call dword [sym.imp.WS2_32.dll_closesocket]
mov eax, dword [ebp - 0x2558]
mov edx, eax
dec eax
mov dword [ebp - 0x2558], eax
test edx, edx
jne 0x401738
mov edx, dword [ebp - 0x2578]
push edx
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov ecx, dword [ebp - 8]
mov edx, dword [ebp - 0x2560]
mov eax, dword [ebp - 0x2564]
pop edi
pop esi
xor ecx, ebp
pop ebx
call fcn.0050cbf9
mov esp, ebp
pop ebp
ret
call fcn.00401060
push eax
push str.Unable_to_initialize_socket._s_n
call fcn.00409470
mov ecx, dword [ebp - 0x2578]
add esp, 8
push ecx
jmp 0x401ba0
call fcn.00401060
push eax
push str.Failed_to_receive_data._s_n
call fcn.00409470
mov eax, dword [ebp - 0x2574]
add esp, 8
push eax
call dword [sym.imp.WS2_32.dll_closesocket]
mov ecx, dword [ebp - 0x2578]
push ecx
jmp 0x401ba0
push str.Protocol_must_be_HTTP._n
call fcn.00409470
add esp, 4
mov eax, dword [ebp - 0x2574]
push eax
call dword [sym.imp.WS2_32.dll_closesocket]
mov ecx, dword [ebp - 0x2578]
push ecx
jmp 0x401ba0