This commit is contained in:
Jean-Marie Mineau 2025-04-07 15:40:51 +02:00
parent 190a8a8690
commit e6aafccf33
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
13 changed files with 47 additions and 181 deletions

View file

@ -5,7 +5,7 @@
FOLDER=$(dirname "$(realpath $0)")
env --chdir "${FOLDER}/../patcher" cargo build --release --target=x86_64-unknown-linux-musl
cp "${FOLDER}/../patcher/target/x86_64-unknown-linux-musl/release/patcher" "${FOLDER}/src/theseus_autopatcher/patcher_86_64_musl"
env --chdir "${FOLDER}/../patcher" cargo build --profile minsizerelease --target=x86_64-unknown-linux-musl
cp "${FOLDER}/../patcher/target/x86_64-unknown-linux-musl/minsizerelease/patcher" "${FOLDER}/src/theseus_autopatcher/patcher_86_64_musl"
env --chdir "${FOLDER}" poetry build

View file

@ -19,7 +19,12 @@ def patch_apk(
zipalign: Path,
apksigner: Path,
keystore: Path,
keypass: None | str = None,
):
optional_args = []
if keypass is not None:
optional_args.append("--keypassword")
optional_args.append(keypass)
subprocess.run(
[
str(PATCHER_BIN_PATH.absolute()),
@ -37,6 +42,7 @@ def patch_apk(
str(apksigner.absolute()),
"--code-loading-patch-strategy",
"model-class-loaders",
*optional_args,
]
)
@ -80,6 +86,13 @@ def main():
type=Path,
default=Path(".") / "TheseusKey.keystore",
)
parser.add_argument(
"-kp",
"--keypass",
required=False,
help="Password for the key in the keystore",
type=str,
)
parser.add_argument(
"--keytool",
required=False,
@ -90,7 +103,7 @@ def main():
"--patch",
required=False,
help="Path to the patcher executable to use. By default, use the one embeded with \
the package. (static x86_64 linux build with musl)",
the package. (static x86_64 linux build with musl optimized for binary size instead of speed)",
type=Path,
)
args = parser.parse_args()
@ -131,7 +144,9 @@ def main():
exit(1)
if not args.keystore.exists():
gen_keystore(keytool, args.keystore)
if args.keypass is None:
args.keypass = "P@ssw0rd!"
gen_keystore(keytool, args.keystore, args.keypass)
with tempfile.TemporaryDirectory() as tmpdname:
tmpd = Path(tmpdname)
@ -151,4 +166,5 @@ def main():
zipalign=zipalign,
apksigner=apksigner,
keystore=args.keystore,
keypass=args.keypass,
)

View file

@ -66,7 +66,7 @@ def get_keytool_path() -> Path | None:
return None
def gen_keystore(keytool: Path, storepath: Path):
def gen_keystore(keytool: Path, storepath: Path, keypass: str):
print(f"{str(storepath)} does not exist, creating it.")
subprocess.run(
[
@ -78,6 +78,10 @@ def gen_keystore(keytool: Path, storepath: Path):
"CN=SomeKey,O=SomeOne,C=FR",
"-keystore",
str(storepath),
"-storepass",
keypass,
"-keypass",
keypass,
"-alias",
"SignKey",
"-keyalg",

View file

@ -20,6 +20,7 @@ pip install "${FOLDER}/dist/theseus_autopatcher-0.1.0-py3-none-any.whl[grodd]"
adb wait-for-device
theseus-autopatch -a "${FOLDER}/../test_apks/dynloading/build/test_dynloading.apk" -o /tmp/patched_dynloading.apk -k "${FOLDER}/../test_apks/dynloading/ToyKey.keystore"
#theseus-autopatch -a "${FOLDER}/../test_apks/dynloading/build/test_dynloading.apk" -o /tmp/patched_dynloading.apk -k "${FOLDER}/../test_apks/dynloading/ToyKey.keystore"
theseus-autopatch -a "${FOLDER}/../test_apks/dynloading/build/test_dynloading.apk" -o /tmp/patched_dynloading.apk -k /tmp/kstore.keystore -kp 'P@ssw0rd!'
rm -rf "${TMP}"