-
-
Save mlen/5607532 to your computer and use it in GitHub Desktop.
Shellcode testbed. Works on Debian 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test: test.c test.h | |
gcc -o test test.c | |
test.h: test.bin | |
xxd -i test.bin > test.h | |
test.bin: test.s | |
nasm -f bin -o test.bin test.s | |
clean: | |
rm test.bin test.h test | |
.PHONY: clean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/mman.h> | |
#include <unistd.h> | |
#include "test.h" | |
int main(void) { | |
int (*func)(); | |
int *pageptr; | |
int pagesize; | |
pagesize = getpagesize(); | |
pageptr = test_bin - ((int)test_bin % pagesize); | |
mprotect(pageptr, (test_bin_len/pagesize + 1)*pagesize, PROT_READ|PROT_EXEC); | |
func = (int (*)())test_bin; | |
(*func)(); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SECTION .text | |
BITS 64 | |
mov rax, 1 | |
mov rbx, 1 | |
int 0x80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment