-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsys_socket.s
66 lines (52 loc) · 938 Bytes
/
sys_socket.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
BITS 64
global _print_create_socket
struc sockaddr_in
.sin_family resw 1
.sin_port resw 1
.sin_addr resd 1
.sin_zero resb 8
endstruc
istruc sockaddr_in
at sockaddr_in.sin_addr, dd 0x100007f
at sockaddr_in.sin_port, dw 0x9a02
at sockaddr_in.sin_family, dw 2
at sockaddr_in.sin_zero, dd 0, 0
iend
section .rodata
print_sock_creat db "Creation of socket", 10,0
print_sock_creat_len equ $-print_sock_creat
section .text
_print_create_socket:
mov rax, 0x1
mov rdi, 1
mov rsi, print_sock_creat
mov rdx, print_sock_creat_len
syscall
call _emptyRegister
jmp _create_sock
_create_sock:
mov rax, 41
mov rdi, 2
mov rsi, 1
mov rdx, 0
syscall
push rax
jmp _connect2socket
_connect2socket:
mov rax, 42
pop rsi
mov rdi, rsi
mov rsi, sockaddr_in
mov rdx, 1
syscall
jmp _exit
_exit:
mov rax, 0x3C
mov rdi, 0
syscall
_emptyRegister:
xor rax, rax
xor rdi, rdi
xor rsi, rsi
xor rdx, rdx
ret