Skip to content

Commit

Permalink
Makefile for unpacking and repacking apk
Browse files Browse the repository at this point in the history
  • Loading branch information
dancek committed Sep 9, 2019
0 parents commit 5410551
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apk.out/
dist/
dll/

original.apk

debug-cert.pem
debug-key.pk8
1 change: 1 addition & 0 deletions CHECKSUMS.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12dc636b2d9e2f6a75d28fc15a3d98ef6ec43f3f95a8710b8aba1ceae29efccd original.apk
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
all: dist/signed.apk

.PHONY: all clean install unpack

APK_DIR=apk.out/
MAIN_DLL=${APK_DIR}assets/bin/Data/Managed/Assembly-CSharp.dll

${APK_DIR}: original.apk
sha256sum -c CHECKSUMS.sha256
apktool decode --output ${APK_DIR} $<
mkdir -p dll/original/
mv ${MAIN_DLL} dll/original/

install: dist/signed.apk
adb install $<

clean:
rm -rf dist/ dll/ ${APK_DIR}

dist/base.apk: ${APK_DIR} ${MAIN_DLL}
mkdir -p dist/
apktool build --output $@ ${APK_DIR}

dist/aligned.apk: dist/base.apk
rm -f $@
zipalign 4 $< $@

dist/signed.apk: dist/aligned.apk debug-key.pk8
apksigner sign --key debug-key.pk8 --cert debug-cert.pem --out $@ dist/aligned.apk

debug-key.pk8:
openssl req -x509 -days 9125 -newkey rsa:1024 -nodes -keyout debug-key.pem -out debug-cert.pem -subj "/CN=debug"
openssl pkcs8 -topk8 -outform DER -in debug-key.pem -inform PEM -out debug-key.pk8 -nocrypt
rm debug-key.pem

dll/main.il: dll/original/Assembly-CSharp.dll
ildasm -out=$@ $<

${MAIN_DLL}: dll/main.il
ilasm -dll -output=$@ $<

0 comments on commit 5410551

Please sign in to comment.