-
Notifications
You must be signed in to change notification settings - Fork 9
/
UpdateName.py
53 lines (42 loc) · 2.17 KB
/
UpdateName.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import json
from json import JSONEncoder
from com.pnfsoftware.jeb.client.api import IScript
from com.pnfsoftware.jeb.core.units.code.android import IDexUnit
class UpdateName(IScript):
def __init__(self):
self.dexUnit = None
self.ctx = None
self.mainProject = None
def renamePerfect(self, oldFeature, newFeature):
for idx in range(0, len(oldFeature["Field"])):
oldField = oldFeature["Field"][idx]
nowField = newFeature["Field"][idx]
if oldField["NowName"] != oldField["RawName"]:
print("rename field: " + nowField["RawSign"] + " -> " + oldField["NowName"])
self.dexUnit.getField(nowField["RawSign"]).setName(oldField["NowName"])
for idx in range(0, len(oldFeature["Method"])):
oldMethod = oldFeature["Method"][idx]
nowMethod = newFeature["Method"][idx]
if oldMethod["NowName"] != oldMethod["RawName"]:
print("rename method: " + nowMethod["RawSign"] + " -> " + oldMethod["NowName"])
self.dexUnit.getMethod(nowMethod["RawSign"]).setName(oldMethod["NowName"])
dexClz = self.dexUnit.getClass(newFeature["RawSign"])
if oldFeature["RawName"] != oldFeature["NowName"]:
print("rename class: " + newFeature["RawSign"] + " -> " + oldFeature["NowName"])
dexClz.setName(oldFeature["NowName"])
def renameLikely(self, oldFeature, newFeature):
pass
def run(self, ctx):
self.ctx = ctx
self.mainProject = ctx.getMainProject()
self.dexUnit = self.mainProject.findUnit(IDexUnit)
perfectJson = json.loads(open(r"D:\desktop\j8e_match_clz\perfectMatch.json").read())
for item in perfectJson:
self.renamePerfect(item["source"], item["match"][0])
# perfectJson = json.loads(open(r"D:\desktop\j8e_match_clz\likelyMathc.json").read())
# for item in perfectJson:
# self.renameLikely(item["source"], item["match"][0])
#
# perfectJson = json.loads(open(r"D:\desktop\j8e_match_clz\multipleMatch.json").read())
# for item in perfectJson:
# self.renameLikely(item["source"], item["match"][0])