Commit f430b18a by sikang

add script

parent f85fee62
rm -rf ../resGuardApks
cd script
./rename_project.sh
cd ../../
gradlew resguardAppProductOthersRelease
cd lib_base/script
./reset_name.sh
{
"activities": [
"HomeActivity",
"CertifyActiviy",
"CertifyProgressActivity",
"FaceDetectActivity",
"LoanDetailActivity",
"LoanHistoryActivity",
"LoginActivity",
"SettingsActivity",
"SplashActivity",
"AccountFragment",
"ContactInfoFragment",
"IdentityInfoFragment",
"PersonalInfoFragment",
"ProfessionalFragment",
"LoanApplyFragment",
"LoanBankFragment",
"LoanReviewFragment",
"ProductListFragment",
"RepaymentFragment"
],
"root": "../../app/src/main",
"manifest": "../../app/src/main/AndroidManifest.xml"
}
#!/usr/bin/env python3
import json
import string
import random
import glob, os
used_names = []
activity_mangle_setting = {}
def process_file_content(path, file_name):
print("processing content: %s..."%path)
with open(path, "rt") as fin:
file_content = fin.read()
# replace the file content based on mangle settings
for (src, dst) in activity_mangle_setting.items():
file_content = file_content.replace(src, dst)
ext = os.path.splitext(file_name)[1]
if ext == '.java':
comment = "// machine renamed: %s\n"%file_name
file_content = "%s%s"%(comment, file_content)
with open(path, "wt") as fout:
fout.write(file_content)
print("done\n")
return
# rand string for class names
def gen_rand_str():
rand_str = ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase, k=8))
while rand_str in used_names:
rand_str = ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase, k=8))
used_names.append(rand_str)
return rand_str
# read configs
with open('obact.json', "rt") as f:
json_root = json.load(f)
activities = json_root["activities"]
source_root = json_root["root"]
manifest = json_root["manifest"]
# mangle activity names
for act_name in activities:
activity_mangle_setting[act_name] = gen_rand_str()
print("activity mapping %s"%activity_mangle_setting)
root_path = os.path.join(os.getcwd(), source_root)
# perform content replace for the files
print("processing file content...")
for root, dirs, files in os.walk(source_root):
directory = os.path.join(os.getcwd(), root)
for file in files:
if file.endswith(".java"):
# get the path of the java file
path = os.path.join(directory, file)
process_file_content(path, file)
print("processing file content done")
print("renaming files")
for root, dirs, files in os.walk(source_root):
directory = os.path.join(os.getcwd(), root)
for file in files:
if file.endswith(".java"):
name = os.path.splitext(file)[0]
if name in activity_mangle_setting:
# get the path of the java file
src = os.path.join(directory, file)
dst = os.path.join(directory, "%s.java"%activity_mangle_setting[name])
print("%s -> %s"%(src, dst))
os.rename(src, dst)
print("renaming files done")
manifest_path = os.path.join(os.getcwd(), manifest)
process_file_content(manifest_path, "AndroidManifest.xml")
{
"activities": [
"BaseActivity",
"BaseApplication",
"BaseFragment",
"InstallReferrerReceiver",
"ContactEntity",
"SmsEntity",
"AboutUsActivity",
"ActivityCenter",
"AgreementPolicyActivity",
"HelpCenterActivity",
"MessageListActivity",
"RefreshDeskActivity",
"RegionActivity",
"RepaymentGuideActivity",
"TakePhotoActivity",
"RefreshDeskListActivity",
"WebActivity",
"LoanInfoFragment",
"RegionFragment",
"RepaymentH5Fragment",
"AvoidOnResultFragment",
"MsgHandleService",
"MsgInstanceIdService",
"Collector",
"ActivityInfoBean",
"BankBean",
"BannerMessageDto",
"BasicAck",
"CertBean",
"ContactInfoBean",
"CouponBean",
"DepositMethodsBean",
"DepositResponseBean",
"DisplayBean",
"EmojiLocationBean",
"EmploymentBean",
"EmploymentBean",
"EmploymentServerBean",
"EventCenterBean",
"GatewayInfoBean",
"GeoLocationBean",
"HistoryLoanAppInfoBean",
"IdentifyBean",
"InviteeBean",
"InviteePersonBean",
"InviteResult",
"LatestLoanAppBean",
"LoanAppBeanFatherStatusLogs",
"LoanAppHelpCenterTipsBean",
"LoaningAmoutBean",
"PersonalInfoServerBean",
"LoanRange",
"LoginRequestBean",
"LoginStatusBean",
"MessageBean",
"MsgInboxBean",
"OcrResultBean",
"PersonalInfoBean",
"PhotoInfo",
"ProductBean",
"AvoidOnResultFragment",
"IncomeMessageProto",
"ResponseErrorBody",
"ThirdPartItemBean",
"ProgressBean",
"RecordFilesResponse",
"RegionBean",
"RepaymentGuideBean",
"SysDictBean",
"ThirdPartDataBean",
"TokenInfoBean",
"TotalAmount",
"UpdateBean",
"UserBankInfo",
"UserBean",
"VersionBean",
"YWUser",
"TDChannel"
],
"root": "../../lib_base/src/main",
"manifest": "../../lib_base/src/main/AndroidManifest.xml",
"approot": "../../app/src/main",
"appmanifest": "../../app/src/main/AndroidManifest.xml"
}
#!/usr/bin/env python3
import json
import string
import random
import glob, os
used_names = []
activity_mangle_setting = {}
def process_file_content(path, file_name):
print("processing content: %s..."%path)
with open(path, "rt") as fin:
file_content = fin.read()
# replace the file content based on mangle settings
for (src, dst) in activity_mangle_setting.items():
file_content = file_content.replace(src, dst)
ext = os.path.splitext(file_name)[1]
if ext == '.java':
comment = "// machine renamed: %s\n"%file_name
file_content = "%s%s"%(comment, file_content)
with open(path, "wt") as fout:
fout.write(file_content)
print("done\n")
return
# rand string for class names
def gen_rand_str():
rand_str = ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase, k=8))
while rand_str in used_names:
rand_str = ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase, k=8))
used_names.append(rand_str)
return rand_str
# read configs
with open('obact_lib.json', "rt") as f:
json_root = json.load(f)
activities = json_root["activities"]
source_root = json_root["root"]
manifest = json_root["manifest"]
# mangle activity names
for act_name in activities:
activity_mangle_setting[act_name] = gen_rand_str()
print("activity mapping %s"%activity_mangle_setting)
root_path = os.path.join(os.getcwd(), source_root)
# perform content replace for the files
print("processing file content...")
for root, dirs, files in os.walk(source_root):
directory = os.path.join(os.getcwd(), root)
for file in files:
if file.endswith(".java"):
# get the path of the java file
path = os.path.join(directory, file)
process_file_content(path, file)
print("processing file content done")
print("renaming files")
for root, dirs, files in os.walk(source_root):
directory = os.path.join(os.getcwd(), root)
for file in files:
if file.endswith(".java"):
name = os.path.splitext(file)[0]
if name in activity_mangle_setting:
# get the path of the java file
src = os.path.join(directory, file)
dst = os.path.join(directory, "%s.java"%activity_mangle_setting[name])
print("%s -> %s"%(src, dst))
os.rename(src, dst)
print("renaming files done")
manifest_path = os.path.join(os.getcwd(), manifest)
process_file_content(manifest_path, "AndroidManifest.xml")
#update app
# read configs
with open('obact_lib.json', "rt") as f:
json_root = json.load(f)
activities = json_root["activities"]
source_root = json_root["approot"]
manifest = json_root["appmanifest"]
print("activity mapping %s"%activity_mangle_setting)
root_path = os.path.join(os.getcwd(), source_root)
# perform content replace for the files
print("processing file content...")
for root, dirs, files in os.walk(source_root):
directory = os.path.join(os.getcwd(), root)
for file in files:
if file.endswith(".java"):
# get the path of the java file
path = os.path.join(directory, file)
process_file_content(path, file)
print("processing file content done")
print("renaming files")
for root, dirs, files in os.walk(source_root):
directory = os.path.join(os.getcwd(), root)
for file in files:
if file.endswith(".java"):
name = os.path.splitext(file)[0]
if name in activity_mangle_setting:
# get the path of the java file
src = os.path.join(directory, file)
dst = os.path.join(directory, "%s.java"%activity_mangle_setting[name])
print("%s -> %s"%(src, dst))
os.rename(src, dst)
print("renaming files done")
manifest_path = os.path.join(os.getcwd(), manifest)
process_file_content(manifest_path, "AndroidManifest.xml")
chmod a+x obact.py
chmod a+x obact_lib.py
obact.py
obact_lib.py
cd ..
git checkout . && git clean -df
git reset --hard origin/master
cd ..
git checkout . && git clean -df
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment