Function at 0x403ff0
Capabilities:
Act as tcp client
Connect socket
Connect tcp socket
Connect udp socket
Create tcp socket
Create udp socket
Get socket status
Initialize winsock library
Receive data
Receive data on socket
Resolve dns
Send data
Send data on socket
Set socket configuration

Disassembly:
push r15
push r14
push r13
push r12
push rbp
push rdi
push rsi
push rbx
sub rsp, 0x628
mov qword [rsp + 0x678], rdx
mov rdi, rcx
mov rbx, r8
lea rdx, [rsp + 0x78]
mov ecx, 2
call qword [sym.imp.WS2_32.dll_WSAStartup]
test eax, eax
je 0x404040
call qword [sym.imp.msvcrt.dll___iob_func]
lea rcx, [0x004064a0]
lea rdx, [rax + 0x60]
call sub.msvcrt.dll_fputs
jmp 0x404735
mov eax, dword [rsp + 0x78]
cmp al, 2
jne 0x40404e
shr ax, 8
je 0x40406f
call qword [sym.imp.msvcrt.dll___iob_func]
lea rcx, [0x004064a0]
lea rdx, [rax + 0x60]
call sub.msvcrt.dll_fputs
call qword [sym.imp.WS2_32.dll_WSACleanup]
jmp 0x404735
lea rcx, str.TFTP_update
lea rsi, [rdi + 6]
lea r12, [rdi + 0x16]
call sub.msvcrt.dll_puts
lea rcx, str.Board_IP:__s_n
mov rdx, rsi
call sub.msvcrt.dll_printf
lea rcx, str.Filename:__s_n
mov rdx, r12
call sub.msvcrt.dll_printf
lea rdx, [rdi + 0x36]
lea rcx, str.Update_to_version:__s_n
call sub.msvcrt.dll_printf
mov rcx, rsi
call qword [sym.imp.WS2_32.dll_gethostbyname]
test rax, rax
mov r13, rax
jne 0x4040df
call qword [sym.imp.WS2_32.dll_WSAGetLastError]
lea rcx, [0x004064fe]
mov r8d, eax
mov rdx, rsi
call sub.msvcrt.dll_printf
jmp 0x404735
cmp byte [rdi + 5], 0
lea r14, [rsp + 0x58]
je 0x404324
lea rdx, [r14 + 2]
xor eax, eax
mov ecx, 0xe
mov word [rsp + 0x58], 2
mov rdi, rdx
rep stosb byte [rdi], al
mov ecx, 0x4e20
call qword [sym.imp.WS2_32.dll_htons]
mov word [rsp + 0x5a], ax
mov rax, qword [r13 + 0x18]
mov r8d, 6
mov edx, 1
mov ecx, 2
mov rax, qword [rax]
mov eax, dword [rax]
mov dword [rsp + 0x5c], eax
call qword [sym.imp.WS2_32.dll_socket]
cmp rax, 0xffffffffffffffff
mov rbp, rax
jne 0x404155
call qword [sym.imp.WS2_32.dll_WSAGetLastError]
lea rcx, str.Cant_create_telnet_socket__Error_code___d_n
mov edx, eax
jmp 0x4043d4
lea rcx, str.Sending_reset_command...
lea rsi, [rsp + 0x54]
call sub.msvcrt.dll_puts
mov ecx, ebp
mov dword [rsp + 0x54], 1
mov r8, rsi
mov edx, 0x8004667e
mov rdi, qword [sym.imp.WS2_32.dll_ioctlsocket]
call rdi
inc eax
lea rcx, str.ioctl_non_block_socket_error
je 0x404228
mov r8d, 0x10
mov rdx, r14
mov rcx, rbp
call qword [sym.imp.WS2_32.dll_connect]
inc eax
jne 0x404251
call qword [sym.imp.WS2_32.dll_WSAGetLastError]
cmp eax, 0x2733
je 0x4041c0
lea rcx, str.connection_failed
jmp 0x404228
lea rax, [rsp + 0x68]
lea r15, [rsp + 0x418]
xor edx, edx
xor ecx, ecx
mov dword [rsp + 0x210], 1
mov qword [rsp + 0x218], rbp
mov dword [rsp + 0x418], 1
mov qword [rsp + 0x420], rbp
mov r9, r15
mov dword [rsp + 0x6c], 0
mov dword [rsp + 0x68], 2
lea r8, [rsp + 0x210]
mov qword [rsp + 0x20], rax
call qword [sym.imp.WS2_32.dll_select]
test eax, eax
jg 0x40423e
lea rcx, str.Connection_timed_out
call sub.msvcrt.dll_puts
lea rcx, str.Board_not_responding_to_telnet_commands__please_restart_the_board_manually_
call sub.msvcrt.dll_puts
jmp 0x404319
mov rdx, r15
mov rcx, rbp
call sub.WS2_32.dll___WSAFDIsSet
test eax, eax
jne 0x4041b7
mov rcx, rbp
mov dword [rsp + 0x54], 0
mov r8, rsi
mov edx, 0x8004667e
call rdi
inc eax
lea rcx, str.ioctl_block_socket_error
je 0x404228
lea rdi, [rsp + 0x210]
lea rsi, str.reset_n
mov ecx, 7
rep movsb byte [rdi], byte [rsi]
lea rdx, [rsp + 0x210]
xor eax, eax
or rcx, 0xffffffffffffffff
xor r9d, r9d
mov rdi, rdx
repne scasb al, byte [rdi]
mov rsi, rcx
mov rcx, rbp
not rsi
lea r8d, [rsi - 1]
call qword [sym.imp.WS2_32.dll_send]
inc eax
jne 0x4042c8
call qword [sym.imp.WS2_32.dll_WSAGetLastError]
lea rcx, str.Send___error__ld._n
mov edx, eax
jmp 0x4043d4
lea rsi, [rsp + 0x418]
xor r9d, r9d
mov r8d, 0x20
mov rcx, rbp
mov rdx, rsi
call qword [sym.imp.WS2_32.dll_recv]
test eax, eax
jg 0x4042fd
call qword [sym.imp.WS2_32.dll_WSAGetLastError]
lea rcx, str.recv___error__ld._n
mov edx, eax
jmp 0x4043d4
sub eax, 2
lea rcx, str.Board_reset_nmsg:___s__n
mov rdx, rsi
cdqe
mov byte [rsp + rax + 0x418], 0
call sub.msvcrt.dll_printf
mov rcx, rbp
call qword [sym.imp.WS2_32.dll_closesocket]
jmp 0x404330
lea rcx, str.Please_RESET_the_board_manually
call sub.msvcrt.dll_puts
lea rdx, [r14 + 2]
xor ebp, ebp
mov ecx, 0xe
mov al, bpl
mov word [rsp + 0x58], 2
mov rdi, rdx
rep stosb byte [rdi], al
mov ecx, 0x45
call qword [sym.imp.WS2_32.dll_htons]
mov word [rsp + 0x5a], ax
mov rax, qword [r13 + 0x18]
mov r8d, 0x11
mov edx, 2
mov ecx, 2
mov rax, qword [rax]
mov eax, dword [rax]
mov dword [rsp + 0x5c], eax
call qword [sym.imp.WS2_32.dll_socket]
cmp rax, 0xffffffffffffffff
mov r15, rax
jne 0x404397
call qword [sym.imp.WS2_32.dll_WSAGetLastError]
lea rcx, str.Cant_create_TFTP_socket__Error_code___d_n
mov edx, eax
jmp 0x4043d4
mov dword [rsp + 0x4c], 0xc8
mov dword [rsp + 0x20], 4
lea r9, [rsp + 0x4c]
mov r8d, 0x1006
mov edx, pe_overlay
mov rcx, rax
call qword [sym.imp.WS2_32.dll_setsockopt]
test eax, eax
mov dword [rsp + 0x34], eax
je 0x4043de
lea rcx, [0x004066af]
mov edx, 1
call sub.msvcrt.dll_printf
jmp 0x404735
or rsi, 0xffffffffffffffff
mov al, bpl
mov rdi, r12
mov rcx, rsi
lea r13, [rsp + 0x418]
mov rdx, r12
repne scasb al, byte [rdi]
mov rdi, r12
mov word [rsp + 0x418], 0x200
not rcx
lea eax, [rcx + 8]
lea rcx, [r13 + 2]
mov dword [rsp + 0x38], eax
call sub.msvcrt.dll_strcpy
mov al, bpl
mov rcx, rsi
lea rdx, str.octet
repne scasb al, byte [rdi]
mov rbp, rcx
not rbp
lea rcx, [r13 + rbp + 2]
xor ebp, ebp
call sub.msvcrt.dll_strcpy
lea rcx, str.Waiting_for_board_to_reboot....
mov dword [rsp + 0x54], 0x2f7c5c2d
call sub.msvcrt.dll_printf
mov rdi, qword [sym.imp.WS2_32.dll_sendto]
xor r9d, r9d
mov dword [rsp + 0x28], 0x10
mov qword [rsp + 0x20], r14
mov r8d, dword [rsp + 0x38]
mov rdx, r13
mov rcx, r15
call rdi
cmp eax, 0xffffffff
je 0x40447c
cmp dword [rsp + 0x38], eax
je 0x404491
call qword [sym.imp.WS2_32.dll_WSAGetLastError]
lea edx, [rax - 0x2750]
cmp edx, 1
ja 0x4045d2
lea rax, [rsp + 0x50]
lea rsi, [rsp + 0x210]
xor r9d, r9d
mov dword [rsp + 0x50], 0x10
mov r8d, 0x10
mov rcx, r15
mov qword [rsp + 0x28], rax
lea rax, [rsp + 0x68]
mov rdx, rsi
mov qword [rsp + 0x20], rax
call qword [sym.imp.WS2_32.dll_recvfrom]
test eax, eax
jg 0x4044ee
lea r12d, [rbp + 1]
and ebp, 3
lea rcx, [0x00406715]
movsx edx, byte [rsp + rbp + 0x54]
mov ebp, r12d
call sub.msvcrt.dll_printf
jmp 0x404454
movzx edx, byte [rsp + 0x211]
cmp edx, 5
jne 0x404510
lea rdx, [rsi + 4]
lea rcx, str._nError__Message_from_remote_host:__s_n
call sub.msvcrt.dll_printf
jmp 0x40471a
cmp edx, 4
je 0x404526
lea rcx, str._nUnexpected_packet_received__Type___d_n
call sub.msvcrt.dll_printf
jmp 0x40471a
lea rcx, str._nReprogramming..._n_
mov esi, 0x200
mov r12, rbx
mov ebp, 1
call sub.msvcrt.dll_printf
mov rax, rsi
cmp rbx, 0x200
lea rdx, [r13 + 4]
cmovbe rax, rbx
mov dword [rsp + 0x418], 0x1000300
mov rsi, qword [rsp + 0x678]
mov ecx, eax
mov rdi, rdx
rep movsb byte [rdi], byte [rsi]
lea esi, [rax + 4]
mov rax, qword [sym.imp.WS2_32.dll_sendto]
mov qword [rsp + 0x38], rax
mov rax, rbx
xor edx, edx
sub rax, r12
imul rax, rax, 0x4f
div rbx
movsxd rdx, dword [rsp + 0x34]
cmp rax, rdx
jbe 0x4045a3
lea rcx, [0x0040677c]
mov dword [rsp + 0x34], eax
call sub.msvcrt.dll_printf
xor r9d, r9d
mov dword [rsp + 0x28], 0x10
mov qword [rsp + 0x20], r14
mov r8d, esi
mov rdx, r13
mov rcx, r15
mov rax, qword [rsp + 0x38]
call rax
cmp eax, 0xffffffff
je 0x4045cc
cmp esi, eax
je 0x4045e0
call qword [sym.imp.WS2_32.dll_WSAGetLastError]
mov edx, eax
lea rcx, [0x004066ec]
jmp 0x40451c
lea rax, [rsp + 0x50]
lea rdi, [rsp + 0x210]
xor r9d, r9d
mov dword [rsp + 0x50], 0x10
mov r8d, 0x10
mov rcx, r15
mov qword [rsp + 0x28], rax
lea rax, [rsp + 0x68]
mov rdx, rdi
mov qword [rsp + 0x20], rax
call qword [sym.imp.WS2_32.dll_recvfrom]
test eax, eax
jle 0x40457a
movzx edx, byte [rsp + 0x211]
cmp edx, 5
jne 0x404643
lea rdx, [rdi + 4]
lea rcx, str._nError__Message_from_remote_host:__s_n
call sub.msvcrt.dll_printf
jmp 0x40470e
cmp edx, 4
je 0x404659
lea rcx, str._nUnexpected_packet_received__Type___d_n
call sub.msvcrt.dll_printf
jmp 0x40470e
movzx eax, byte [rsp + 0x212]
shl eax, 8
mov edx, eax
movzx eax, byte [rsp + 0x213]
or eax, edx
cmp ax, bp
movzx edx, ax
jbe 0x40468d
lea rcx, str._nUnexpected_ACK_block_received__got__d__want__d_n
movzx r8d, bp
call sub.msvcrt.dll_printf
jmp 0x40470e
shl edx, 9
mov r12, rbx
movsxd rcx, edx
cmp rbx, rcx
cmovbe edx, ebx
movsxd rsi, edx
sub r12, rsi
jne 0x4046b2
lea rcx, [0x004067b1]
call sub.msvcrt.dll_puts
jmp 0x40470e
lea ebp, [rax + 1]
lea rdx, [r13 + 4]
mov word [rsp + 0x418], 0x300
mov eax, ebp
mov byte [rsp + 0x41b], bpl
mov rdi, rdx
shr ax, 8
cmp r12, 0x200
mov byte [rsp + 0x41a], al
mov eax, 0x200
cmovbe rax, r12
add rsi, qword [rsp + 0x678]
mov ecx, eax
rep movsb byte [rdi], byte [rsi]
lea esi, [rax + 4]
call qword [sym.imp.msvcrt.dll___iob_func]
lea rcx, [rax + 0x30]
call sub.msvcrt.dll_fflush
jmp 0x40457a
lea rcx, str.Reprogramming_completed_successfully.
call sub.msvcrt.dll_puts
mov rcx, r15
call qword [sym.imp.WS2_32.dll_closesocket]
call qword [sym.imp.WS2_32.dll_WSACleanup]
mov ecx, 0x1388
call qword [sym.imp.KERNEL32.dll_Sleep]
nop
add rsp, 0x628
pop rbx
pop rsi
pop rdi
pop rbp
pop r12
pop r13
pop r14
pop r15
ret