Answer the question
In order to leave comments, you need to log in
Why not connect to the server?
section .bss
wsadata resb 408 ; sizeof(WSADATA)
section .data
IP0 EQU 188
IP1 EQU 187
IP2 EQU 188
IP3 EQU 179
AF_INET EQU 2
IPPROTO_TCP EQU 6
SOCK_STREAM EQU 1
sockaddr_in dd 0, 0, 0, 0 ; 16 bytes : sizeof(SOCKADDR_IN)
socket dd 0
errorCreatingSocket db "Error creating socket", 0Dh, 0Ah
errorCreatingSocketLen EQU $-errorCreatingSocket
errorCreatingConnect db "Error creating connect", 0Dh, 0Ah
errorCreatingConnectLen EQU $-errorCreatingConnect
errorSendingData db "Error sending data", 0Dh, 0Ah
errorSendingDataLen EQU $-errorSendingData
section .text
_start:
mov al, 2
mov ah, 2
push wsadata
push eax
call [email protected]
test eax, eax
jnz error
mov byte [sockaddr_in + 1], AF_INET ; sin_family
mov byte [sockaddr_in + 2], 80 ; sin_port[0]
mov byte [sockaddr_in + 3], 0 ; sin_port[1]
mov byte [sockaddr_in + 4], IP0
mov byte [sockaddr_in + 5], IP1
mov byte [sockaddr_in + 6], IP2 ;IN_ADDR structure
mov byte [sockaddr_in + 7], IP3
push IPPROTO_TCP
push SOCK_STREAM
push AF_INET
call [email protected]
mov ebx, errorCreatingSocket
mov edx, errorCreatingSocketLen
cmp eax, -1
je error
mov dword [socket], eax
push 16
push sockaddr_in
push dword [socket]
call [email protected]
mov ebx, errorCreatingConnect
mov edx, errorCreatingConnectLen
cmp eax, -1
je error
push 0
push msgRequestLen
push msgRequest
push dword [socket]
call [email protected]
mov ebx, errorSendingData
mov edx, errorSendingDataLen
cmp eax, -1
je error
push 0
push 8128
push buffer
push dword [socket]
call [email protected]
mov dword [requestLength], eax
exit:
push 0
call [email protected]
00 02 50 00 bc bb bc b3 00 00 00 00 00 00 00 00
Answer the question
In order to leave comments, you need to log in
I'm looking here , and it seems to me that the beginning of the sockaddr_in initialization in your code should look like this:
mov byte [sockaddr_in + 0], AF_INET ; sin_family
mov byte [sockaddr_in + 2], 0 ; sin_port[0] это старший байт sin_port
mov byte [sockaddr_in + 3], 80 ; sin_port[1] а это младший
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question