serialize to json
This commit is contained in:
parent
ebaeaef877
commit
eece6178f9
18 changed files with 2515 additions and 293 deletions
92
test.py
92
test.py
|
|
@ -27,49 +27,49 @@ clazz = apk.classes[clazz_id]
|
|||
method = clazz.virtual_methods[method_id]
|
||||
code = method.code
|
||||
|
||||
logging.getLogger().setLevel(logging.ERROR)
|
||||
|
||||
print(f"Code of {method_id}")
|
||||
for i in code.insns:
|
||||
print(i)
|
||||
|
||||
new_insns = []
|
||||
for i in code.insns:
|
||||
if isinstance(i, asc.ins.ConstString):
|
||||
if i.lit == "Hello":
|
||||
i = asc.ins.ConstString(i.reg, DexString("Degemer Mat"))
|
||||
elif i.lit == "Bye":
|
||||
i = asc.ins.ConstString(i.reg, DexString("Kenavo"))
|
||||
new_insns.append(i)
|
||||
|
||||
# This need improving!
|
||||
code = asc.Code(code.registers_size, code.ins_size, code.outs_size, new_insns)
|
||||
apk.set_method_code(method_id, code)
|
||||
# apk.set_method_code(method.descriptor, code)
|
||||
|
||||
clazz = apk.classes[clazz_id]
|
||||
method = clazz.virtual_methods[method_id]
|
||||
code = method.code
|
||||
|
||||
print(f"Code of {method_id}")
|
||||
for i in code.insns:
|
||||
print(i)
|
||||
|
||||
dex_raw = apk.gen_raw_dex()
|
||||
assert len(dex_raw) == 1
|
||||
with open(DEX_NAME, "wb") as file:
|
||||
file.write(dex_raw[0])
|
||||
|
||||
|
||||
with open(DEX_NAME, "rb") as file:
|
||||
dex = file.read()
|
||||
new_apk = asc.Apk()
|
||||
new_apk.add_dex_file(dex)
|
||||
|
||||
clazz = new_apk.classes[clazz_id]
|
||||
method = clazz.virtual_methods[method_id]
|
||||
code = method.code
|
||||
|
||||
print(f"Code of {method_id} in new apk")
|
||||
for i in code.insns:
|
||||
print(i)
|
||||
# logging.getLogger().setLevel(logging.ERROR)
|
||||
#
|
||||
# print(f"Code of {method_id}")
|
||||
# for i in code.insns:
|
||||
# print(i)
|
||||
#
|
||||
# new_insns = []
|
||||
# for i in code.insns:
|
||||
# if isinstance(i, asc.ins.ConstString):
|
||||
# if i.lit == "Hello":
|
||||
# i = asc.ins.ConstString(i.reg, DexString("Degemer Mat"))
|
||||
# elif i.lit == "Bye":
|
||||
# i = asc.ins.ConstString(i.reg, DexString("Kenavo"))
|
||||
# new_insns.append(i)
|
||||
#
|
||||
## This need improving!
|
||||
# code = asc.Code(code.registers_size, code.ins_size, code.outs_size, new_insns)
|
||||
# apk.set_method_code(method_id, code)
|
||||
## apk.set_method_code(method.descriptor, code)
|
||||
#
|
||||
# clazz = apk.classes[clazz_id]
|
||||
# method = clazz.virtual_methods[method_id]
|
||||
# code = method.code
|
||||
#
|
||||
# print(f"Code of {method_id}")
|
||||
# for i in code.insns:
|
||||
# print(i)
|
||||
#
|
||||
# dex_raw = apk.gen_raw_dex()
|
||||
# assert len(dex_raw) == 1
|
||||
# with open(DEX_NAME, "wb") as file:
|
||||
# file.write(dex_raw[0])
|
||||
#
|
||||
#
|
||||
# with open(DEX_NAME, "rb") as file:
|
||||
# dex = file.read()
|
||||
# new_apk = asc.Apk()
|
||||
# new_apk.add_dex_file(dex)
|
||||
#
|
||||
# clazz = new_apk.classes[clazz_id]
|
||||
# method = clazz.virtual_methods[method_id]
|
||||
# code = method.code
|
||||
#
|
||||
# print(f"Code of {method_id} in new apk")
|
||||
# for i in code.insns:
|
||||
# print(i)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue