Skip to content

Commit 76b9dcf

Browse files
committed
clean up
1 parent 3ebf7d5 commit 76b9dcf

File tree

8 files changed

+24
-554
lines changed

8 files changed

+24
-554
lines changed

Makefile

+23-36
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ALL_BINARY_TARGETS := exploit decrypt cli kernelutil loader
1+
ALL_BINARY_TARGETS := decrypt cli kernelutil loader
22

33
.PHONY: all
44
all: $(ALL_BINARY_TARGETS)
@@ -19,15 +19,32 @@ CROSS := arm-none-eabi-
1919

2020
RUN_CLI_DIR := /data/local/tmp
2121

22-
decrypt: decrypt.c
23-
$(CC) $(CFLAGS) -o $@ $< -lcrypto
22+
## root shell
2423

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
2734

2835
cli: cli.go
2936
GOARCH=arm $(GO) build -o $@ $<
3037

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+
3148
# _Cust_dump_all_thread (b.da)
3249
threaddump.txt:
3350
$(MAKE) run-cli CLICOMMAND=b.da | tee $@
@@ -64,40 +81,10 @@ dtv_driver.lds: dtv_driver.ko threaddump.lds
6481
$(PERL) -nE 'say "$$2 = 0x$$1;" if /^([0-9a-f]+)\s+.\s.*\s(\S+)$$/ && hex($$1) > 0' | \
6582
sort -k3 > $@
6683

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-
9784
.PHONY: run-cli
9885
run-cli: cli
9986
$(ADB) push cli $(RUN_CLI_DIR)/cli && $(ADB) shell $(RUN_CLI_DIR)/cli $(CLICOMMAND)
10087

10188
.PHONY: clean
10289
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

Comments
 (0)