WIP eddit from python
This commit is contained in:
parent
d3e005fd68
commit
8dce87d569
9 changed files with 474 additions and 9 deletions
31
test.py
31
test.py
|
|
@ -8,7 +8,8 @@ import androscalpel as asc
|
|||
import zipfile as z
|
||||
from androscalpel import *
|
||||
|
||||
APK_NAME = "test.apk"
|
||||
# APK_NAME = "test.apk"
|
||||
APK_NAME = "/home/histausse/workspace/androscalpel/apk_frauder/app-release.apk"
|
||||
DEX_NAME = "classes.dex"
|
||||
|
||||
with z.ZipFile(APK_NAME) as zipf:
|
||||
|
|
@ -18,4 +19,32 @@ with z.ZipFile(APK_NAME) as zipf:
|
|||
apk = asc.Apk()
|
||||
apk.add_dex_file(dex)
|
||||
|
||||
clazz_id = IdType("Lcom/example/testapplication/ui/home/HomeViewModel;")
|
||||
proto_id = IdMethodType(IdType("Ljava/lang/String;"), [])
|
||||
method_id = IdMethod("text_gen", proto_id, clazz_id)
|
||||
|
||||
clazz = apk.classes[clazz_id]
|
||||
method = clazz.virtual_methods[method_id]
|
||||
|
||||
print("Code of {method_id}")
|
||||
for i in method.code.insns:
|
||||
print(i)
|
||||
|
||||
new_insns = []
|
||||
for i in method.code.insns:
|
||||
if isinstance(i, asc.ins.ConstString):
|
||||
if i.lit == "Hello":
|
||||
i.lit = DexString("Degemer Mat")
|
||||
elif i.lit == "Bye":
|
||||
i.lit = DexString("Kenavo")
|
||||
new_insns.append(i)
|
||||
|
||||
# This need improving!
|
||||
new_code = method.code
|
||||
new_code.insns = new_insns
|
||||
method.code = new_code
|
||||
clazz.virtual_methods[method_id] = method
|
||||
apk.classes[clazz_id] = clazz
|
||||
|
||||
|
||||
dex_raw = apk.gen_raw_dex()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue