forked from Gameye98/DTL-X
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dtlx.py
569 lines (556 loc) · 23.8 KB
/
dtlx.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
import os, sys, re
import hashlib
import subprocess
endl = "\012"
class patcher:
def __init__(self, fin, args):
self.endl = "\012"
self.isneutralize = False
self.ismodified = False
self.isclean = False
self.fin = fin
self.fnm = fin.split("/")[fin.split("/")[-1]] if "/" in fin else fin
if not os.path.isfile(self.fin):
raise FileNotFoundError(f"{self.fin}: No such file or directory")
self.fout = self.fnm
if self.fout.endswith(".apk"):
self.fout = self.fout[0:len(self.fout)-4]
else:
self.fout = self.fout+".out"
while os.path.isdir(self.fout):
self.fout = self.fout+".out"
self.raw = self.fout
# Decompile APK file
print("\x1b[92m+++++ Decompile APK into Project\x1b[0m")
os.system(f"apktool d {self.fin}")
self.manifestxml = open(f"{self.fout}/AndroidManifest.xml","r").read()
# Fixing bug where the manifest copy content itself many times
if len(self.manifestxml.split("</manifest>")) > 1:
self.manifestxml = self.manifestxml.split("</manifest>")[0]+"</manifest>"
self.smalidir = list(filter(lambda x: x.startswith("smali"), os.listdir(self.fout)))
self.smalidir = list(map(lambda x: self.fout+"/"+x, self.smalidir))
self.args = args
for args_iter in self.args:
# Switch Operator
if args_iter=="rmads1":self.removeAds1()
elif args_iter=="rmads2":self.removeAds2()
elif args_iter=="rmads3":self.removeAds3()
elif args_iter=="rmads4":self.removeAds4()
elif args_iter=="rmads5":self.removeAds5()
elif args_iter=="rmnop":self.removeNop()
elif args_iter=="rmnown":self.removeUnknown()
elif args_iter=="customfont":self.customFont()
elif args_iter=="rmscrnrestrict":self.removeSetsecure()
elif args_iter=="rmcopy":self.removeCopyProtection()
elif args_iter=="rmprop":self.removeProperties()
elif args_iter=="rmtrackers":self.removeTrackers()
elif args_iter=="cleanrun":self.isclean=True
elif args_iter=="nokill":self.nokill()
# Compile Project
print("\x1b[92m+++++ Compile Project into APK\x1b[0m")
os.system(f"apktool b -f -d {self.fout}")
print("\x1b[1;92m[+] Signing APK file... \x1b[0m",end="")
os.system(f"apksigner sign --ks assets/user.keystore --ks-key-alias user --ks-pass pass:12345678 {self.fout}/dist/{self.fnm}")
print("\x1b[1;92mOK\x1b[0m")
print("\x1b[1;92m[+] Verifying APK file... \x1b[0m",end="")
os.system(f"apksigner verify {self.fout}/dist/{self.fnm}")
print("\x1b[1;92mOK\x1b[0m")
self.signed = self.fnm
if self.signed.endswith(".apk"):
self.signed = self.signed[0:len(self.signed)-4]+"_sign.apk"
else:
self.signed = self.signed+"_sign.apk"
os.rename(self.fout+"/dist/"+self.fnm, self.signed)
# Delete Project if isclean = True
if self.isclean: os.system(f"rm -rf {self.fout}")
def warning(self,content):
print(f"\x1b[1;41;93m{content}\x1b[0m")
__import__("time").sleep(0.1)
def success(self,content):
print(f"\x1b[1;92m{content}\x1b[0m")
__import__("time").sleep(0.1)
def writeManifestXML(self):
if len(self.manifestxml.split("</manifest>")) > 1:
self.manifestxml = self.manifestxml.split("</manifest>")[0]+"</manifest>"
open(self.fout+"/AndroidManifest.xml","w").write(self.manifestxml)
def writeNeutralize(self):
if not self.isneutralize:
os.system(f"mkdir -p {self.fout}/smali/sec/blackhole/dtlx")
open(self.fout+"/smali/sec/blackhole/dtlx/Schadenfreude.smali","w").write(neutralize)
self.isneutralize = True
def removeAds1(self):
self.gms_ad = [x for x in self.manifestxml.split(self.endl) if x.strip().startswith("<activity") and "com.google.android.gms.ad" in x and x.strip().endswith(">")]
for gmsx in self.gms_ad:
print(f"\x1b[1;92m[+] Found {len(self.gms_ad)} result(s) related to the com.google.android.gms.ad\x1b[0m")
self.manifestxml = self.manifestxml.replace(gmsx,"")
self.writeManifestXML()
print(f"\x1b[1;92m[+] AndroidManifest.xml has been updated\x1b[0m")
def removeAds2(self):
manifesttmp = ""
self.no_inet = ["android.permission.INTERNET","android.permission.ACCESS_NETWORK_STATE","android.permission.ACCESS_WIFI_STATE","android.permission.RECEIVE_BOOT_COMPLETED","com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE"]
for inetx in self.no_inet:
for f_iter in self.manifestxml.split(self.endl):
if f_iter.strip().startswith("<uses-permission") and inetx in f_iter:
self.warning(f_iter.strip())
else:
manifesttmp += f_iter+endl
self.manifestxml = manifesttmp
self.writeManifestXML()
print(f"\x1b[1;92m[+] AndroidManifest.xml has been updated\x1b[0m")
def removeAds3(self):
for x in self.smalidir:
self.f_ls = subprocess.run(f"find {x}/",shell=True,check=True,stdout=subprocess.PIPE).stdout.decode().split(self.endl)
self.f_ls = list(filter(lambda x: not x.startswith(".") and x.strip() != "", self.f_ls))
self.f_ls = list(filter(lambda x: os.path.isfile(x) and x.endswith(".smali"), self.f_ls))
for fx in self.f_ls:
self.ffx = open(fx,"r").read()
if "\"ca-app-pub" in self.ffx:
self.success(f"[+] Found (\"ca-app-pub): {fx}... ")
self.ffx = self.ffx.replace("\"ca-app-pub","\"noads")
self.success("FIXED")
open(fx,"w").write(self.ffx)
def removeAds4(self):
for x in self.smalidir:
self.f_ls = subprocess.run(f"find {x}/",shell=True,check=True,stdout=subprocess.PIPE).stdout.decode().split(self.endl)
self.f_ls = list(filter(lambda x: not x.startswith(".") and x.strip() != "", self.f_ls))
for fx in self.f_ls:
if os.path.isfile(fx) and "/ads/" in fx and fx.endswith(".smali"):
self.ffx = open(fx,"r").read()
self.readperline = self.ffx.strip().split(endl)
while "" in self.readperline:
self.readperline.remove("")
self.modifiedsourcefile = ""
for rpl_iterx in self.readperline:
if "invoke" in rpl_iterx:
for rpl_itery in strmatch["adloader"]:
if rpl_itery in rpl_iterx:
if rpl_iterx.strip().endswith(")V"):
print("*"*int(system("tput cols")))
self.success(f"[+] Patch (invoke~()V): {fx}")
self.warning(rpl_iterx)
rpl_iterx = rpl_iterx.replace(rpl_iterx.strip(),"invoke-static {}, Lsec/blackhole/dtlx/Schadenfreude;->neutralize()V")
self.success(rpl_iterx)
elif rpl_iterx.strip().endswith(")Z"):
print("*"*int(system("tput cols")))
self.success(f"[+] Patch (invoke~()Z): {fx}")
self.warning(rpl_iterx)
rpl_iterx = rpl_iterx.replace(rpl_iterx.strip(),"invoke-static {}, Lsec/blackhole/dtlx/Schadenfreude;->neutralize()Z")
self.success(rpl_iterx)
elif "const-string-still-fix-issue" in rpl_iterx:
print(f"\x1b[1;92m[+] Patch (const-string): {fx}... \x1b[0m")
self.constvar = re.findall(r"const-string\s(v[0-9]+|p[0-9]+),\s\"(.*?)\"", rpl_iterx)[0][0]
rpl_iterx = rpl_iterx.replace(rpl_iterx.strip(),f"const-string {self.constvar}, \"null\"")
self.modifiedsourcefile += rpl_iterx+endl
open(fx,"w").write(self.modifiedsourcefile)
self.ismodified = True
if self.ismodified: self.writeNeutralize()
def removeAds5(self):
for x in self.smalidir:
self.f_ls = subprocess.run(f"find {x}/",shell=True,check=True,stdout=subprocess.PIPE).stdout.decode().split(self.endl)
self.f_ls = list(filter(lambda x: not x.startswith(".") and x.strip() != "", self.f_ls))
self.f_ls = list(filter(lambda x: os.path.isfile(x) and x.endswith(".smali"), self.f_ls))
for fx in self.f_ls:
self.ffx = open(fx,"r").read()
if "\"ca-app-pub" in self.ffx:
ca_id = re.findall(r"(ca\-app\-pub\-[0-9][0-9][0-9][0-9])", self.ffx)
for i in ca_id:
print("\x1b[1;41;93m[+] Found (\"ca-app-pub): {fx}... \x1b[0m",end="")
self.ffx = self.ffx.replace(i,"ca-app-pub-0000")
self.success("FIXED")
open(fx,"w").write(self.ffx)
def removeNop(self):
for x in self.smalidir:
self.f_ls = subprocess.run(f"find {x}/",shell=True,check=True,stdout=subprocess.PIPE).stdout.decode().split(self.endl)
self.f_ls = list(filter(lambda x: not x.startswith("."), self.f_ls))
for fx in self.f_ls:
if os.path.isfile(fx) and fx.endswith(".smali"):
self.ffx = open(fx,"r").read()
# Read Per Line
self.rpl = self.ffx.strip().split("\n")
while "" in self.rpl: self.rpl.remove("")
self.modifiedsourcefile = ""
for rpl_i in self.rpl:
if rpl_i.strip() != "nop":
self.modifiedsourcefile += rpl_i+endl
open(fx,"w").write(self.modifiedsourcefile)
def removeUnknown(self):
self.unknown = self.fout+"/unknown"
if os.path.isdir(self.fout+"/unknown"):
os.system(f"rm -rf {self.unknown}")
def customFont(self):
fontPath = input("+++++ fontfile: ")
if os.path.isfile(fontPath):
# Generate user font hash
fontHash = hashlib.md5(open(fontPath,"rb").read()).hexdigest()
self.f_ls = subprocess.run(f"find {self.fout}/",shell=True,check=True,stdout=subprocess.PIPE).stdout.decode().split(self.endl)
# Remove empty item
self.f_ls = list(filter(lambda x: x != "", self.f_ls))
# Filter: If item ends with ".ttf" only
self.f_ls = list(filter(lambda x: x.endswith(".ttf"), self.f_ls))
# Filter: If user font hash is different with item hash only
self.f_ls = list(filter(lambda x: hashlib.md5(open(x,"rb").read()).hexdigest() != fontHash, self.f_ls))
# Copy self.f_ls for other task
tmp_fls = self.f_ls
# Map: Make copy of user font to each destination found
list(map(lambda x: __import__("shutil").copyfile(fontPath,x),self.f_ls))
# Print all item, stdout
list(map(lambda x: self.warning(x),tmp_fls))
def removeCopyProtection(self):
# Retrieve list of files pertains to copy protection
self.f_ls = list(protection["copy"])
# Map: Rename item, starts with directoryName
self.f_ls = list(map(lambda x: self.fout+"/"+x,self.f_ls))
# Filter: If file exists only
self.f_ls = list(filter(lambda x: os.path.exists(x),self.f_ls))
if len(self.f_ls) > 0: self.success("+++++ appcloner copy protection detected")
# Copy self.f_ls for other task
tmp_fls = self.f_ls
# Delete all files that linked to copy protection
list(map(lambda x: os.system(f"rm -rf \"{x}\""),self.f_ls))
# Print all item, stdout
list(map(lambda x: self.warning(x),tmp_fls))
# Check all possible protections smali code
self.f_ls = list(filter(lambda x: x[0].startswith(self.fout+"/smali"), list(__import__("itertools").permutations(self.smalidir+["andhook","com/applisto","com/swift/sandhook"], 2))))
self.f_ls = list(map(lambda x: "/".join(x), self.f_ls))
self.f_ls = list(filter(lambda x: os.path.isdir(x), self.f_ls))
tmp_fls = self.f_ls
list(map(lambda x: os.system(f"rm -rf \"{x}\""),self.f_ls))
list(map(lambda x: self.warning(x),tmp_fls))
# SENSITIVE: Remove all smali file that make an invoke to com/applisto
for iterx in self.smalidir:
self.f_ls = subprocess.run(f"find {iterx}/",shell=True,check=True,stdout=subprocess.PIPE).stdout.decode().split(self.endl)
self.f_ls = list(filter(lambda x: x.endswith(".smali"), self.f_ls))
self.f_ls = list(filter(lambda x: "com/applisto" in open(x,"r").read(), self.f_ls))
tmp_fls = self.f_ls
list(map(lambda x: os.system(f"rm -rf \"{x}\""), self.f_ls))
list(map(lambda x: self.warning(x), tmp_fls))
# Clean apktool.yml
self.f_ls = list(filter(lambda x: not "com/applisto" in x, open(self.fout+"/apktool.yml","r").read().split(self.endl)))
self.f_ls = list(filter(lambda x: x.strip() != "", self.f_ls))
open(self.fout+"/apktool.yml","w").write("\012".join(self.f_ls))
# Remove leftover from AndroidManifest.xml
# Try 1: Using regex
reg = re.findall(r"(<.*? android:name=\"com.applisto.appcloner.*?/>)", self.manifestxml)
for iterx in reg:
self.warning(iterx)
self.manifestxml = self.manifestxml.replace(iterx,"")
# Try 2: Iterate and filter through each lines
cpmanifest = list(filter(lambda x: x.strip() != "", self.manifestxml.strip().split(self.endl)))
isreceiver = False
self.manifestxml = ""
for iterx in cpmanifest:
iterz = iterx.strip()
if iterz.startswith("<receiver android:name=\"com.applisto"):
self.warning(iterx)
isreceiver = True
elif iterz.startswith("</receiver>"):
isreceiver = False
elif not isreceiver:
self.manifestxml += iterx+self.endl
self.writeManifestXML()
def removeProperties(self):
# List Files and Filter Filename Ends With (.properties)
self.f_ls = subprocess.run(f"find {self.fout}/unknown/",shell=True,check=True,stdout=subprocess.PIPE).stdout.decode().split(self.endl)
self.f_ls = list(filter(lambda x: x.endswith(".properties"), self.f_ls))
self.f_ls = list(filter(lambda x: os.path.isfile(x), self.f_ls))
fls_name = list(map(lambda x: x.split("/")[-1], self.f_ls))
tmp_fls = self.f_ls
# Remove all .properties files
list(map(lambda x: os.system(f"rm -rf \"{x}\""), self.f_ls))
list(map(lambda x: self.warning(x), tmp_fls))
# Clean apktool.yml
self.f_ls = open(self.fout+"/apktool.yml","r").read().split(self.endl)
self.f_ls = list(filter(lambda x: x.strip() != "", self.f_ls))
tmp_fls = []
self.modifiedsourcefile = ""
for iterx in self.f_ls:
isProperty = False
isPropertyName = None
for iterz in fls_name:
itery = iterx.strip()
if itery.startswith(iterz):
isProperty = True
isPropertyName = iterx
break
if isProperty:
tmp_fls.append(isPropertyName)
else:
self.modifiedsourcefile += iterx+self.endl
list(map(lambda x: self.warning(x), tmp_fls))
open(self.fout+"/apktool.yml","w").write(self.modifiedsourcefile)
def removeSetsecure(self):
print("Still working on")
def removeTrackers(self):
for tracksx in trackers:
self.warning(tracksx[0]+": "+tracksx[2])
self.removeClass(tracksx[1])
def removeClass(self, class_name):
# Delete class com.crashlytics.android
for smalixdir in self.smalidir:
if os.path.isdir(smalixdir+"/"+class_name.replace(".","/")):
self.warning(smalixdir+"/"+class_name.replace(".","/"))
os.system(f"rm -rf {smalixdir}/"+class_name.replace(".","/"))
for smalixdir in self.smalidir:
self.f_ls = subprocess.run(f"find {smalixdir}/",shell=True,check=True,stdout=subprocess.PIPE).stdout.decode().split(self.endl)
self.f_ls = list(filter(lambda x: not x.startswith(".") and x.strip() != "", self.f_ls))
self.f_ls = list(filter(lambda x: x.endswith(""), self.f_ls))
self.f_ls = list(filter(lambda x: os.path.isfile(x), self.f_ls))
# Clean smali code that execute operations pertain to $class_name
for fx in self.f_ls:
self.ffx = open(fx,"r").read()
self.readperline = self.ffx.strip().split(endl)
while "" in self.readperline:
self.readperline.remove("")
self.modifiedsourcefile = ""
isgetobj = False
for rpl_iterx in self.readperline:
rplix = rpl_iterx.strip()
if class_name.replace(".","/") in rpl_iterx or class_name in rpl_iterx:
if rplix.startswith("invoke"):
if rpl_iterx.strip().endswith(")V"):
print("*"*int(system("tput cols")))
self.success(f"[+] Patch (invoke~()V): {fx}")
self.warning(rpl_iterx)
rpl_iterx = rpl_iterx.replace(rplix,"invoke-static {}, Lsec/blackhole/dtlx/Schadenfreude;->neutralize()V")
self.success(rpl_iterx)
elif rpl_iterx.strip().endswith(")Z"):
print("*"*int(system("tput cols")))
self.success(f"[+] Patch (invoke~()Z): {fx}")
self.warning(rpl_iterx)
rpl_iterx = rpl_iterx.replace(rplix,"invoke-static {}, Lsec/blackhole/dtlx/Schadenfreude;->neutralize()Z")
self.success(rpl_iterx)
elif rplix.startswith("move-result") and isgetobj:
print(f"\x1b[1;92m[+] Patch (new-instance): {fx}... \x1b[0m")
self.warning(rpl_iterx)
rpl_iterx = rpl_iterx.replace(rplix,"")
isgetobj = False
elif rplix.startswith("new-instance"):
print(f"\x1b[1;92m[+] Patch (new-instance): {fx}... \x1b[0m")
self.warning(rpl_iterx)
rpl_iterx = rpl_iterx.replace(rplix,"")
isgetobj = True
elif rplix.startswith("iget"):
print(f"\x1b[1;92m[+] Patch (iget): {fx}... \x1b[0m")
self.warning(rpl_iterx)
rpl_iterx = rpl_iterx.replace(rplix,"")
elif rplix.startswith("iput"):
print(f"\x1b[1;92m[+] Patch (iput): {fx}... \x1b[0m")
self.warning(rpl_iterx)
rpl_iterx = rpl_iterx.replace(rplix,"")
self.modifiedsourcefile += rpl_iterx+endl
elif rplix.startswith("const-string") and "\"crashlytics" in rplix.lower():
print(f"\x1b[1;92m[+] Patch (const-string): {fx}... \x1b[0m")
self.warning(rpl_iterx)
constvar = rplix.split(",")[0]
rpl_iterx = rpl_iterx.replace(rplix,f"{constvar}, \"null\"")
self.modifiedsourcefile += rpl_iterx+endl
else:
self.modifiedsourcefile += rpl_iterx+endl
open(fx,"w").write(self.modifiedsourcefile)
self.ismodified = True
if self.ismodified: self.writeNeutralize()
# Remove leftover from AndroidManifest.xml
self.cleanManifest(class_name)
def cleanManifest(self, targetClass):
# Remove leftover from AndroidManifest.xml
# Try 1: Using regex
reg = re.findall(r"(<.*? android:name=\""+targetClass+".*?/>)", self.manifestxml)
for iterx in reg:
self.warning(iterx)
self.manifestxml = self.manifestxml.replace(iterx,"")
# Try 2: Using regex
primarydata = {"meta-data","receiver","service"}
cpmanifest = list(filter(lambda x: x.strip() != "", self.manifestxml.strip().split(self.endl)))
isreceiver = False
ismetadata = False
isservice = False
allmatch = []
for xmltagi in primarydata:
reg = re.findall(rf'(<{xmltagi}((.|\n|\r)*?)</{xmltagi}>)', self.manifestxml)
if len(reg) != 0:
allmatch.append([x[0] for x in reg])
for regxi in allmatch:
if targetClass in regxi:
self.warning(regxi)
self.manifestxml = self.manifestxml.replace(regxi,"")
self.writeManifestXML()
def nokill(self):
for x in self.smalidir:
self.f_ls = subprocess.run(f"find {x}/",shell=True,check=True,stdout=subprocess.PIPE).stdout.decode().split(self.endl)
self.f_ls = list(filter(lambda x: not x.startswith("."), self.f_ls))
for fx in self.f_ls:
if os.path.isfile(fx) and fx.endswith(".smali"):
self.ffx = open(fx,"r").read()
# Read Per Line
self.rpl = self.ffx.strip().split("\n")
while "" in self.rpl: self.rpl.remove("")
self.modifiedsourcefile = ""
for rpl_i in self.rpl:
isexitcalled = False
for exiti in kamusexit:
if exiti in rpl_i:
self.warning(rpl_i)
isexitcalled = True
break
if not isexitcalled: self.modifiedsourcefile += rpl_i+endl
open(fx,"w").write(self.modifiedsourcefile)
###
helpbanner = """ __ __ __
,__| | |_| |___ __ __
| _ | _| |___|_ ` _| author: Gameye98 (1.0-dev)
|_____|____|__| |__.__| APK REVERSER & PATCHER
--rmads1: target=AndroidManifest.xml,replace=com.google.android.gms.ad
--rmads2: No Internet (remove the required permission to do so)
--rmads3: Search using regex and replace string ("ca-app-pub) with ("noads)
--rmads4: (Powerful) Disable all kind of ads loader base on the dictionary list
--rmads5: Randomize first 4 digits of the 16 digits Admob Adunit and App ID
--rmnop: Remove all nop instruction found on the smali file
--rmunknown: Remove all unknown files (.properties, etc)
--customfont: Update and replace all font files with user recommended file
--rmcopy: Remove AppCloner Copy Protection
--rmprop: Remove only .properties file
--rmtrackers: Remove Trackers
--nokill: No Kill
--cleanrun: Remove the decompiled project after done patching
"""
mainbanner = """
\x1b[1;92m@@@@@@@ @@@@@@@ @@@ @@@ @@@ \x1b[0m
\x1b[1;92m@@@@@@@@ @@@@@@@ @@@ @@@ @@@ \x1b[0m
\x1b[1;92m@@! @@@ @@! @@! @@! !@@ \x1b[0m
\x1b[1;92m!@! @!@ !@! !@! !@! @!! \x1b[0m
\x1b[1;92m@!@ !@! @!! @!! @!@!@!@!@ !@@!@! \x1b[0m
\x1b[1;92m!@! !!! !!! !!! !!!@!@!!! @!!! \x1b[0m
\x1b[1;92m!!: !!! !!: !!: !: :!! \x1b[0m
\x1b[1;92m:!: !:! :!: :!: :!: !:! \x1b[0m
\x1b[1;92m :::: :: :: :: :::: :: ::: \x1b[0m
\x1b[1;92m:: : : : : :: : : : :: \x1b[0m
\x1b[1;41;93mAPK REVERSER & PATCHER - author by Gameye98 (BHSec)\x1b[0m
"""
strmatch = {
"adloader": (
"loadAd",
"load",
"show",
"loadAdFromBid",
"loadAds",
"requestBannerAd",
"requestInterstitialAd",
"showInterstitial",
"isLoading",
"addView",
"loadUrl",
"loadDataWithBaseURL",
"hasVideoContent",
"loadData",
"showVideo",
"showAd",
"loadBannerAd",
"loadInterstitialAd",
"loadNativeAd"
)
}
trackers = [
["Google CrashLytics","com.google.firebase.crashlytics","http://crashlytics.com"],
["Google Firebase Analytics","com.google.android.gms.measurement","https://firebase.google.com/"],
["Google Ads","com.google.android.gms.ads.mediation","https://developers.google.con/admob/android"],
["Pollfish","com.pollfish","https://www.pollfish.com"],
["Facebook Analytics","com.facebook.appevents","https://developers.facebook.com/docs/android"],
["Facebook Share","com.facebook.share","https://developers.facebook.com/docs/android"],
["Facebook Ads","com.facebook.ads","https://developers.facebook.com/docs/android"]
]
protection = {
"copy": (
"__launcher_icon.png",
"assets/app_cloner_branding.png",
"assets/natives_sec_blob.dat",
"unknown/andhook",
"unknown/com/applisto",
"lib/arm64-v8a/libappcloner.so",
"lib/arm64-v8a/libsandhook-native.so",
"lib/arm64-v8a/libsandhook.so",
"lib/armeabi-v7a/libappcloner.so",
"lib/armeabi-v7a/libsandhook-native.so",
"lib/armeabi-v7a/libsandhook.so"
)
}
kamusregex = (
("matchall_invoke","(invoke-.*\s\{.*\},\s)"),
("matchall_conststring","const-string\s(v[0-9]),\s\"(.*?)\"")
)
kamusexit = (
("Ljava/lang/System;->exit(I)V"),
("Landroid/app/Activity;->onDestroy()V"),
("Landroid/app/Activity;->finish()V"),
("Landroid/app/Service;->stopSelf()V"),
("Landroid/app/Activity;->finishActivity(I)V"),
("Landroid/os/Process;->killProcess(I)V"),
("Landroid/app/Activity;->finishAffinity()V"),
("Landroid/app/Activity;->finishAndRemoveTask()V")
)
neutralize = """.class public Lsec/blackhole/dtlx/Schadenfreude;
.super Ljava/lang/Object;
.source "Schadenfreude.java"
.method public static neutralize()V
.locals 0
return-void
.end method
.method public static neutralize()Z
.locals 1
const/4 v0, 0x0
return v0
.end method
"""
def system(cmd):
try:
sysExec = subprocess.run(cmd,shell=True,check=True,stdout=subprocess.PIPE).stdout.decode()
return sysExec
except Exception as e:
print(e)
return None
def main():
print(mainbanner)
global isconsole
c = 0
p = sys.argv
p.remove(p[0])
if len(p) >= 2:
funcls = []
ftarget = p[-1]
if os.path.isfile(ftarget):
p = p[0:len(p)-1]
else:
print(helpbanner)
return None
for px in p:
if px == "--rmads1":
funcls.append("rmads1")
elif px == "--rmads2":
funcls.append("rmads2")
elif px == "--rmads3":
funcls.append("rmads3")
elif px == "--rmads4":
funcls.append("rmads4")
elif px == "--rmads5":
funcls.append("rmads5")
elif px == "--rmnop":
funcls.append("rmnop")
elif px == "--rmunknown":
funcls.append("rmnown")
elif px == "--customfont":
funcls.append("customfont")
elif px == "--rmcopy":
funcls.append("rmcopy")
elif px == "--rmprop":
funcls.append("rmprop")
elif px == "--rmtrackers":
funcls.append("rmtrackers")
elif px == "--cleanrun":
funcls.append("cleanrun")
elif px == "--nokill":
funcls.append("nokill")
patcher(ftarget,funcls)
if __name__ == "__main__":
if len(sys.argv) >= 2:
main()
else:
print(helpbanner)