Function at 0x406b40
Capabilities:
Download and write a file
Receive and write data from server to client
Receive data
Receive data on socket
Send data
Send data on socket
Write file on windows

Disassembly:
push ebx
mov ebx, dword [esp + 8]
push ebp
mov ebp, dword [ebx + 0x10]
push esi
push edi
xor edi, edi
cmp dword [esp + 0x18], edi
lea esi, [ebx + 0x405c]
jne 0x406b8e
push 4
call sub.WSOCK32.dll_htons
push edi
push 4
mov word [esi], ax
mov word [esi + 2], di
mov eax, dword [ebx + 0x18]
push esi
push eax
call sub.WSOCK32.dll_send
cmp eax, 4
je 0x406b8e
push edi
mov esi, str.send
mov ecx, ebx
call fcn.00405e10
add esp, 4
pop edi
pop esi
pop ebp
pop ebx
ret
cmp dword [ebx + 0x4494], edi
mov dword [ebx + 0x3c], edi
mov dword [ebx + 0x38], edi
je 0x406bb0
lea ecx, [ebx + 0x4498]
push ecx
call fcn.00403860
add esp, 4
jmp 0x406bb0
mov edi, ebx
call fcn.00405e90
test eax, eax
je 0x406ccd
mov edx, dword [ebx + 0x18]
push 0
push 0x4004
lea edi, [ebx + 0x58]
push edi
push edx
call sub.WSOCK32.dll_recv
mov esi, eax
test esi, esi
jle 0x406d79
push ebx
call fcn.00408ff0
add esp, 4
cmp esi, 4
jb 0x406d8f
movzx eax, word [edi]
push eax
call sub.WSOCK32.dll_ntohs
cmp ax, 3
jne 0x406db4
movzx ecx, word [edi + 2]
push ecx
call sub.WSOCK32.dll_ntohs
test ax, ax
jne 0x406c4f
cmp dword [ebx + 0x28], 0
jne 0x406c4f
cmp dword [ebx + 0x4478], 0
lea edx, [esi - 4]
mov dword [ebx + 0x34], edx
jne 0x406d1b
cmp dword [ebx + 0x3c], 0
jne 0x406d1b
mov eax, dword [ebx + 0x4474]
push str.WARNING:_First_block_sent_by_client_is_0__should_be_1__fixed_by_Tftpd32
push eax
push ebp
push 1
call fcn.004098c0
add esp, 0x10
add dword [ebx + 0x28], 0xffffffff
movzx ecx, word [edi + 2]
push ecx
call sub.WSOCK32.dll_ntohs
mov dx, word [ebx + 0x28]
add dx, 1
cmp ax, dx
jne 0x406cef
mov eax, dword [ebx + 0x38]
add dword [ebx + 0x447c], eax
add dword [ebx + 0x28], 1
xor ecx, ecx
push ecx
lea eax, [esi - 4]
lea esi, [ebx + 0x34]
push esi
push eax
mov dword [ebx + 0x38], ecx
mov dword [ebx + 0x3c], ecx
mov ecx, dword [ebx + 0x1c]
add edi, 4
push edi
push ecx
mov dword [esi], eax
call dword [sym.imp.KERNEL32.dll_WriteFile]
test eax, eax
je 0x406de6
cmp dword [ebx + 0x4494], 0
je 0x406cbc
mov edx, dword [esi]
push edx
lea eax, [ebx + 0x4498]
push edi
push eax
call fcn.00403f60
add esp, 0xc
mov ecx, dword [esi]
add dword [ebx + 0x4478], ecx
mov esi, ebx
call fcn.00405430
jmp 0x406cef
mov edx, dword [ebx + 0x28]
mov eax, dword [ebx + 0x4474]
add edx, 1
push edx
push str.timeout_while_waiting_for_data_blk__d
push eax
push ebp
push 9
call fcn.004098c0
add esp, 0x14
add dword [ebx + 0x38], 1
push 4
call sub.WSOCK32.dll_htons
lea esi, [ebx + 0x405c]
mov word [esi], ax
movzx ecx, word [ebx + 0x28]
push ecx
call sub.WSOCK32.dll_htons
push 0
push 4
mov word [esi + 2], ax
mov edx, dword [ebx + 0x18]
push esi
push edx
call sub.WSOCK32.dll_send
mov eax, dword [ebx + 0x34]
cmp eax, dword [ebx + 0x40]
mov eax, dword [0x41f388]
jne 0x406d37
cmp dword [ebx + 0x3c], 0x32
jae 0x406d41
cmp dword [ebx + 0x38], eax
jb 0x406bb0
cmp dword [ebx + 0x3c], 0x32
jb 0x406dfc
mov ax, word [ebx + 0x28]
add ax, 1
lea edx, [ebx + 0x4272]
push edx
mov edx, dword [ebx + 0x4474]
movzx ecx, ax
push ecx
push str.MAX_RETRIES_while_waiting_for_Data_block__d._file___s_
push edx
push ebp
push 0
call fcn.004098c0
push 0
call fcn.00405810
add esp, 0x1c
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
ret
push 0
mov esi, str.recv
mov ecx, ebx
call fcn.00405e10
add esp, 4
pop edi
pop esi
pop ebp
pop ebx
ret
mov ecx, dword [ebx + 0x4474]
push str.rcvd_packet_too_short
push ecx
push ebp
push 1
call fcn.004098c0
push 4
call fcn.00405810
add esp, 0x14
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
ret
movzx edx, word [edi]
push edx
call sub.WSOCK32.dll_ntohs
mov ecx, dword [ebx + 0x4474]
movzx eax, ax
push eax
push str.Peer_sent_unexpected_message__d
push ecx
push ebp
push 1
call fcn.004098c0
push 4
call fcn.00405810
add esp, 0x18
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
ret
push 3
mov esi, str.write
mov ecx, ebx
call fcn.00405e10
add esp, 4
pop edi
pop esi
pop ebp
pop ebx
ret
cmp dword [ebx + 0x38], eax
jb 0x406e39
mov cx, word [ebx + 0x28]
add cx, 1
lea eax, [ebx + 0x4272]
push eax
mov eax, dword [ebx + 0x4474]
movzx edx, cx
push edx
push str.TIMEOUT_while_waiting_for_Data_block__d__file___s_
push eax
push ebp
push 0
call fcn.004098c0
push 0
call fcn.00405810
add esp, 0x1c
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
ret
cmp dword [ebx + 0x4494], 0
je 0x406e4f
cmp dword [ebx + 0x24], 0
jne 0x406e4f
mov esi, ebx
call fcn.00405200
push ebx
call fcn.00405700
add esp, 4
pop edi
pop esi
pop ebp
mov eax, 1
pop ebx
ret