File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44* .obj
55* .elf
66* .DS_Store
7+ * .sc
78# Precompiled Headers
89* .gch
910* .pch
Original file line number Diff line number Diff line change 1+ default : system-execve-shell
2+
3+ system-execve-shell.o : shellcode/system-execve-shell.c
4+ gcc-6 -c shellcode/system-execve-shell.c -o shellcode/system-execve-shell.o --shared -fpic -static -O0 -fno-asynchronous-unwind-tables -D LIB
5+
6+ system-execve-shell : shellcode/system-execve-shell.o
7+ ld shellcode/system-execve-shell.o -o shellcode/system-execve-shell -S -static -dylib -order_file shellcode/system-execve-order-file.txt
8+
9+ system-execve-shell : shellcode/system-execve-shell
10+ gobjcopy -O binary --only-section=.text shellcode/system-execve-shell shellcode/system-execve-shell.sc
11+
12+ clean :
13+ -rm -f shellcode/system-execve-shell.o
14+ -rm -f shellcode/system-execve-shell
Original file line number Diff line number Diff line change 33A small setup that I used to learn X86_x64 shellcode generation using ASM and compiled C code.
44
55
6- ## OSX Setup
6+ ## OSX Host Setup
77
88Please ensure you have the following installed before starting to build.
99
1010- Install XCode: ` xcode-select --install `
1111- Install Brew: ` /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" `
12- - Install Brew GCC: ` brew install gcc `
12+ - Install Brew GCC: ` brew install gcc `
13+ - Link GCC 6: ` ln -s /usr/local/Cellar/gcc/6.3.0_1/bin/gcc-6 gcc-6 `
14+
15+
16+ ## Shellcode generation
17+
18+ In this project we have a few diffrent types of shell code that I have built as POC using C and ASM.
19+
20+ ### System Execve /bin/sh
21+ This code uses inline ASM in C for system call and executes a /bin/sh as an example.
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ echo " - Starting to build Shellcode: system-execve-shell "
3+ gcc-6 -c shellcode/system-execve-shell.c -o shellcode/system-execve-shell.o --shared -fpic -static -O0 -fno-asynchronous-unwind-tables -D LIB
4+ echo " - Starting to link Shellcode: system-execve-shell "
5+ ld shellcode/system-execve-shell.o -o shellcode/system-execve-shell -S -static -dylib -order_file shellcode/system-execve-order-file.txt
6+ echo " - Starting to export Shellcode: system-execve-shell "
7+ gobjcopy -O binary --only-section=.text shellcode/system-execve-shell shellcode/system-execve-shell.sc
8+
9+ echo " - Clean Up from build"
10+ rm -f shellcode/system-execve-shell.o
11+ rm -f shellcode/system-execve-shell
Original file line number Diff line number Diff line change 1+ _main1
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ or for byte savings: (86 bytes)
1010/usr/local/Cellar/gcc/6.3.0_1/bin/gcc-6 -c test.c --shared -fpic -static -O3 -fno-asynchronous-unwind-tables -D LIB
1111
12122) link your code:
13- ld test.o -o test -S -static -dylib -order_file order_file .txt
13+ ld test.o -o test -S -static -dylib -order_file system-execve-order-file .txt
1414
15152) get hex of shel code of section:
1616gobjcopy -O binary --only-section=.text test test.output
You can’t perform that action at this time.
0 commit comments