1
- ALL_BINARY_TARGETS := exploit decrypt cli kernelutil loader
1
+ ALL_BINARY_TARGETS := decrypt cli kernelutil loader
2
2
3
3
.PHONY : all
4
4
all : $(ALL_BINARY_TARGETS )
@@ -19,15 +19,32 @@ CROSS := arm-none-eabi-
19
19
20
20
RUN_CLI_DIR := /data/local/tmp
21
21
22
- decrypt : decrypt.c
23
- $(CC ) $(CFLAGS ) -o $@ $< -lcrypto
22
+ # # root shell
24
23
25
- kernelutil : kernelutil.go
26
- $(GO ) build -o $@ $<
24
+ getroot.elf : getroot.c getroot.lds
25
+ $(CROSS )$(CC ) $(TARGET_CFLAGS ) -Os -ffreestanding -nostdlib -o $@ -Wl,-r -T getroot.lds $<
26
+
27
+ assets.go : getroot.elf
28
+ go-bindata -nocompress -pkg main -o $@ $^
29
+
30
+ loader : loader.go assets.go
31
+ GOARCH=arm $(GO ) build -o $@ $^
32
+
33
+ # # utils
27
34
28
35
cli : cli.go
29
36
GOARCH=arm $(GO ) build -o $@ $<
30
37
38
+ kernelutil : kernelutil.go
39
+ $(GO ) build -o $@ $<
40
+
41
+ # # firmware unpacking
42
+
43
+ decrypt : decrypt.c
44
+ $(CC ) $(CFLAGS ) -o $@ $< -lcrypto
45
+
46
+ # # debugging stuff
47
+
31
48
# _Cust_dump_all_thread (b.da)
32
49
threaddump.txt :
33
50
$(MAKE ) run-cli CLICOMMAND=b.da | tee $@
@@ -64,40 +81,10 @@ dtv_driver.lds: dtv_driver.ko threaddump.lds
64
81
$(PERL ) -nE ' say "$$2 = 0x$$1;" if /^([0-9a-f]+)\s+.\s.*\s(\S+)$$/ && hex($$1) > 0' | \
65
82
sort -k3 > $@
66
83
67
- LOAD_SYM =_CmdVersion
68
- shellcode.lds : shellcode.lds.in dtv_driver.lds
69
- loadaddr=$$($(PERL ) -nE 'say $$1 if /^$(LOAD_SYM ) = (.*) ; /' < dtv_driver.lds) \
70
- $(PERL ) -pe ' s/#LOADADDR#/$$ENV{loadaddr}/g' < $< > $@
71
-
72
- shellcode.o : shellcode.lds dtv_driver.lds kernel.lds shellcode.S
73
- echo ' .ascii "Built at $(shell date)"' > buildts.S
74
- $(CROSS )$(CC ) $(CFLAGS ) -nostdlib -o $@ $^
75
-
76
- shellcode.bin : shellcode.o
77
- $(CROSS )$(OBJCOPY ) -O binary -j .text --reverse-bytes=4 $< $@
78
-
79
- shellcode.bin.h : shellcode.bin
80
- $(XXD ) -i $^ > $@
81
-
82
- shellcode.addr.h : shellcode.o
83
- $(READELF ) -e $< | $(AWK ) ' /Entry point/ { print "tgt_addr_t shellcode_addr = "$$NF";" }' > $@
84
-
85
- exploit : main.c shellcode.bin.h shellcode.addr.h
86
- $(CC ) $(CFLAGS ) -I$(CURDIR ) -o $@ $<
87
-
88
- findsym.elf : findsym.c findsym.lds
89
- $(CROSS )$(CC ) $(TARGET_CFLAGS ) -Os -ffreestanding -nostdlib -o $@ -Wl,-r -T findsym.lds $<
90
-
91
- assets.go : findsym.elf
92
- go-bindata -nocompress -pkg main -o $@ $^
93
-
94
- loader : loader.go assets.go
95
- GOARCH=arm $(GO ) build -o $@ $^
96
-
97
84
.PHONY : run-cli
98
85
run-cli : cli
99
86
$(ADB ) push cli $(RUN_CLI_DIR ) /cli && $(ADB ) shell $(RUN_CLI_DIR ) /cli $(CLICOMMAND )
100
87
101
88
.PHONY : clean
102
89
clean :
103
- rm -f * .o * .bin * .bin.h * .addr.h findsym. elf buildts.S dtv_driver.lds threaddump.lds kernel.lds assets.go $(ALL_BINARY_TARGETS )
90
+ rm -f getroot. elf dtv_driver.lds threaddump.lds kernel.lds assets.go $(ALL_BINARY_TARGETS )
0 commit comments