Skip to content

Commit 43028ef

Browse files
Build Script
1 parent 9d05469 commit 43028ef

6 files changed

Lines changed: 39 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*.obj
55
*.elf
66
*.DS_Store
7+
*.sc
78
# Precompiled Headers
89
*.gch
910
*.pch

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@
33
A 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

88
Please 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.

build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_main1

shellcode/system-execve-shell.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
1212
2) 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
1515
2) get hex of shel code of section:
1616
gobjcopy -O binary --only-section=.text test test.output

0 commit comments

Comments
 (0)