This commit is contained in:
Mari Wahl 2014-12-02 10:19:52 -05:00
parent 84df40b7cb
commit 36356bcc36
77 changed files with 203 additions and 27 deletions

View file

@ -0,0 +1,2 @@
shell: simplest_shellcode.c
gcc -static -g -o shell simplest_shellcode.c

View file

@ -0,0 +1,5 @@
as --32 -o s.o s.s
ld -m elf_i386 -o s s.o
./s
objdump -d s

View file

@ -0,0 +1,9 @@
#include <stdlib.h>
int main()
{
char *array[2];
array[0] = "/bin/sh";
array[1] = NULL;
execve(array[0], array, NULL);
exit(0);
}

View file

@ -0,0 +1,16 @@
.code32
.text
.globl _start
_start:
xorl %eax, %eax /* We need to push a null terminated string to the stack */
pushl %eax /* So first, push a null */
pushl $0x68732f2f /* Push //sh */
pushl $0x6e69622f /* push /bin */
movl %esp, %ebx /* Store the %esp of /bin/sh into %ebx */
pushl %eax /* Since eax is still null, let's use it again */
pushl %ebx /* Now we can writ the /bin/sh again for **argv */
movl %esp, %ecx /* Write argv into %ecx */
xorl %edx, %edx /* NULL out edx */
movb $0xb, %al /* Write syscall 11 into %al */
int $0x80 /* Interrupt the system */