Skip to content

Commit b8a2aa0

Browse files
authored
Merge pull request #30 from kelvinBen/v1.0.9.1
add "识别到壳后自动进行脱壳处理"
2 parents 18188fd + ae2de54 commit b8a2aa0

8 files changed

Lines changed: 434 additions & 54 deletions

File tree

app.py

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,28 @@
1313
def cli():
1414
pass
1515

16+
1617
# 创建Android任务
1718

1819

1920
@cli.command(help="Get the key information of Android system.")
20-
@click.option("-i", "--inputs", required=True, type=str, help="Please enter the APK file or DEX file to be scanned or the corresponding APK download address.")
21-
@click.option("-r", "--rules", required=False, type=str, default="", help="Please enter a rule for temporary scanning of file contents.")
22-
@click.option("-s", "--sniffer", is_flag=True, default=False, help="Enable the network sniffer function. It is on by default.")
23-
@click.option("-n", '--no-resource', is_flag=True, default=False, help="Ignore all resource files, including network sniffing. It is not enabled by default.")
24-
@click.option("-a", '--all', is_flag=True, default=False, help="Output the string content that conforms to the scan rules.It is on by default.")
25-
@click.option("-t", '--threads', required=False, type=int, default=10, help="Set the number of concurrency. The larger the concurrency, the faster the speed. The default value is 10.")
21+
@click.option("-i", "--inputs", required=True, type=str,
22+
help="Please enter the APK file or DEX file to be scanned or the corresponding APK download address.")
23+
@click.option("-r", "--rules", required=False, type=str, default="",
24+
help="Please enter a rule for temporary scanning of file contents.")
25+
@click.option("-s", "--sniffer", is_flag=True, default=False,
26+
help="Enable the network sniffer function. It is on by default.")
27+
@click.option("-n", '--no-resource', is_flag=True, default=False,
28+
help="Ignore all resource files, including network sniffing. It is not enabled by default.")
29+
@click.option("-a", '--all', is_flag=True, default=False,
30+
help="Output the string content that conforms to the scan rules.It is on by default.")
31+
@click.option("-t", '--threads', required=False, type=int, default=10,
32+
help="Set the number of concurrency. The larger the concurrency, the faster the speed. The default value is 10.")
2633
@click.option("-o", '--output', required=False, type=str, default=None, help="Specify the result set output directory.")
27-
@click.option("-p", '--package', required=False, type=str, default="", help="Specifies the package name information that needs to be scanned.")
28-
def android(inputs: str, rules: str, sniffer: bool, no_resource: bool, all: bool, threads: int, output, package: str) -> None:
34+
@click.option("-p", '--package', required=False, type=str, default="",
35+
help="Specifies the package name information that needs to be scanned.")
36+
def android(inputs: str, rules: str, sniffer: bool, no_resource: bool, all: bool, threads: int, output,
37+
package: str) -> None:
2938
try:
3039
bootstrapper = Bootstrapper(__file__, output, all, no_resource)
3140
bootstrapper.init()
@@ -36,12 +45,18 @@ def android(inputs: str, rules: str, sniffer: bool, no_resource: bool, all: bool
3645

3746

3847
@cli.command(help="Get the key information of iOS system.")
39-
@click.option("-i", "--inputs", required=True, type=str, help="Please enter IPA file or ELF file to scan or corresponding IPA download address. App store is not supported at present.")
40-
@click.option("-r", "--rules", required=False, type=str, default="", help="Please enter a rule for temporary scanning of file contents.")
41-
@click.option("-s", "--sniffer", is_flag=True, default=False, help="Enable the network sniffer function. It is on by default.")
42-
@click.option("-n", '--no-resource', is_flag=True, default=False, help="Ignore all resource files, including network sniffing. It is not enabled by default.")
43-
@click.option("-a", '--all', is_flag=True, default=False, help="Output the string content that conforms to the scan rules.It is on by default.")
44-
@click.option("-t", '--threads', required=False, type=int, default=10, help="Set the number of concurrency. The larger the concurrency, the faster the speed. The default value is 10.")
48+
@click.option("-i", "--inputs", required=True, type=str,
49+
help="Please enter IPA file or ELF file to scan or corresponding IPA download address. App store is not supported at present.")
50+
@click.option("-r", "--rules", required=False, type=str, default="",
51+
help="Please enter a rule for temporary scanning of file contents.")
52+
@click.option("-s", "--sniffer", is_flag=True, default=False,
53+
help="Enable the network sniffer function. It is on by default.")
54+
@click.option("-n", '--no-resource', is_flag=True, default=False,
55+
help="Ignore all resource files, including network sniffing. It is not enabled by default.")
56+
@click.option("-a", '--all', is_flag=True, default=False,
57+
help="Output the string content that conforms to the scan rules.It is on by default.")
58+
@click.option("-t", '--threads', required=False, type=int, default=10,
59+
help="Set the number of concurrency. The larger the concurrency, the faster the speed. The default value is 10.")
4560
@click.option("-o", '--output', required=False, type=str, default=None, help="Specify the result set output directory.")
4661
def ios(inputs: str, rules: str, sniffer: bool, no_resource: bool, all: bool, threads: int, output: str) -> None:
4762
try:
@@ -54,12 +69,18 @@ def ios(inputs: str, rules: str, sniffer: bool, no_resource: bool, all: bool, th
5469

5570

5671
@cli.command(help="Get the key information of Web system.")
57-
@click.option("-i", "--inputs", required=True, type=str, help="Please enter the site directory or site file to scan or the corresponding site download address.")
58-
@click.option("-r", "--rules", required=False, type=str, default="", help="Please enter a rule for temporary scanning of file contents.")
59-
@click.option("-s", "--sniffer", is_flag=True, default=False, help="Enable the network sniffer function. It is on by default.")
60-
@click.option("-n", '--no-resource', is_flag=True, default=False, help="Ignore all resource files, including network sniffing. It is not enabled by default.")
61-
@click.option("-a", '--all', is_flag=True, default=False, help="Output the string content that conforms to the scan rules.It is on by default.")
62-
@click.option("-t", '--threads', required=False, type=int, default=10, help="Set the number of concurrency. The larger the concurrency, the faster the speed. The default value is 10.")
72+
@click.option("-i", "--inputs", required=True, type=str,
73+
help="Please enter the site directory or site file to scan or the corresponding site download address.")
74+
@click.option("-r", "--rules", required=False, type=str, default="",
75+
help="Please enter a rule for temporary scanning of file contents.")
76+
@click.option("-s", "--sniffer", is_flag=True, default=False,
77+
help="Enable the network sniffer function. It is on by default.")
78+
@click.option("-n", '--no-resource', is_flag=True, default=False,
79+
help="Ignore all resource files, including network sniffing. It is not enabled by default.")
80+
@click.option("-a", '--all', is_flag=True, default=False,
81+
help="Output the string content that conforms to the scan rules.It is on by default.")
82+
@click.option("-t", '--threads', required=False, type=int, default=10,
83+
help="Set the number of concurrency. The larger the concurrency, the faster the speed. The default value is 10.")
6384
@click.option("-o", '--output', required=False, type=str, default=None, help="Specify the result set output directory.")
6485
def web(inputs: str, rules: str, sniffer: bool, no_resource: bool, all: bool, threads: int, output: str) -> None:
6586
try:

libs/core/__init__.py

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
# apktool 所在路径
1717
apktool_path = ""
1818

19+
# adb 所在路径
20+
adb_path = ""
21+
22+
# frida server 所在路径
23+
frida32_path = ""
24+
frida64_path = ""
25+
26+
# aapt 所在路径
27+
aapt_apth = ""
28+
1929
# 系统类型
2030
os_type = ""
2131

@@ -28,12 +38,17 @@
2838
# excel 起始行号
2939
excel_row = 1
3040

41+
3142
class Bootstrapper(object):
3243

33-
def __init__(self, path, out_path, all=False, no_resource= False):
44+
def __init__(self, path, out_path, all=False, no_resource=False):
3445
global smali_path
3546
global backsmali_path
3647
global apktool_path
48+
global adb_path
49+
global frida32_path
50+
global frida64_path
51+
global aapt_apth
3752
global os_type
3853
global output_path
3954
global script_root_dir
@@ -43,44 +58,48 @@ def __init__(self, path, out_path, all=False, no_resource= False):
4358
global history_path
4459
global app_history_path
4560
global domain_history_path
46-
global excel_row
61+
global excel_row
4762
global download_path
4863
global download_flag
4964
global out_dir
5065
global all_flag
51-
global resource_flag
66+
global resource_flag
5267

5368
all_flag = not all
5469
resource_flag = no_resource
5570

5671
create_time = time.strftime("%Y%m%d%H%M%S", time.localtime())
57-
script_root_dir = os.path.dirname(os.path.abspath(path))
72+
script_root_dir = os.path.dirname(os.path.abspath(path))
5873
if out_path:
5974
out_dir = out_path
6075
else:
6176
out_dir = script_root_dir
62-
tools_dir = os.path.join(script_root_dir,"tools")
63-
output_path = os.path.join(out_dir,"out")
64-
history_path = os.path.join(script_root_dir,"history")
65-
77+
tools_dir = os.path.join(script_root_dir, "tools")
78+
output_path = os.path.join(out_dir, "out")
79+
history_path = os.path.join(script_root_dir, "history")
80+
6681
if platform.system() == "Windows":
67-
machine2bits = {'AMD64':64, 'x86_64': 64, 'i386': 32, 'x86': 32}
82+
machine2bits = {'AMD64': 64, 'x86_64': 64, 'i386': 32, 'x86': 32}
6883
machine2bits.get(platform.machine())
6984

7085
if platform.machine() == 'i386' or platform.machine() == 'x86':
71-
strings_path = os.path.join(tools_dir,"strings.exe")
86+
strings_path = os.path.join(tools_dir, "strings.exe")
7287
else:
73-
strings_path = os.path.join(tools_dir,"strings64.exe")
88+
strings_path = os.path.join(tools_dir, "strings64.exe")
7489
else:
75-
strings_path ="strings"
76-
77-
backsmali_path = os.path.join(tools_dir,"baksmali.jar")
90+
strings_path = "strings"
91+
92+
backsmali_path = os.path.join(tools_dir, "baksmali.jar")
7893
apktool_path = os.path.join(tools_dir, "apktool.jar")
79-
download_path = os.path.join(out_dir,"download")
80-
txt_result_path = os.path.join(out_dir,"result_"+str(create_time)+".txt")
81-
xls_result_path = os.path.join(out_dir,"result_"+str(create_time)+".xlsx")
82-
app_history_path = os.path.join(history_path,"app_history.txt")
83-
domain_history_path = os.path.join(history_path,"domain_history.txt")
94+
adb_path = os.path.join(tools_dir + '\\unpacker', "adb.exe")
95+
frida32_path = os.path.join(tools_dir + '\\unpacker', "hexl-server-arm32")
96+
frida64_path = os.path.join(tools_dir + '\\unpacker', "hexl-server-arm64")
97+
aapt_apth = os.path.join(tools_dir + '\\unpacker', "aapt.exe")
98+
download_path = os.path.join(out_dir, "download")
99+
txt_result_path = os.path.join(out_dir, "result_" + str(create_time) + ".txt")
100+
xls_result_path = os.path.join(out_dir, "result_" + str(create_time) + ".xlsx")
101+
app_history_path = os.path.join(history_path, "app_history.txt")
102+
domain_history_path = os.path.join(history_path, "domain_history.txt")
84103

85104
def init(self):
86105
if not os.path.exists(out_dir):
@@ -95,7 +114,7 @@ def init(self):
95114
if not (platform.system() == "Windows"):
96115
raise e
97116
self.__removed_dirs_cmd__(output_path)
98-
117+
99118
os.makedirs(output_path)
100119
print("[*] Create directory {}".format(output_path))
101120

@@ -106,22 +125,22 @@ def init(self):
106125
if not os.path.exists(history_path):
107126
os.makedirs(history_path)
108127
print("[*] Create directory {}".format(history_path))
109-
128+
110129
if os.path.exists(txt_result_path):
111130
os.remove(txt_result_path)
112131

113132
if os.path.exists(xls_result_path):
114133
os.remove(xls_result_path)
115-
116-
def __removed_dirs_cmd__(self,output_path):
134+
135+
def __removed_dirs_cmd__(self, output_path):
117136
files = os.listdir(output_path)
118137
for file in files:
119-
new_dir = os.path.join(output_path,"newdir")
120-
old_dir = os.path.join(output_path,file)
138+
new_dir = os.path.join(output_path, "newdir")
139+
old_dir = os.path.join(output_path, file)
121140
if not os.path.exists(new_dir):
122141
os.makedirs(new_dir)
123142
os.chdir(output_path)
124143
cmd = ("robocopy %s %s /purge") % (new_dir, old_dir)
125144
os.system(cmd)
126145
os.removedirs(new_dir)
127-
os.removedirs(old_dir)
146+
os.removedirs(old_dir)

0 commit comments

Comments
 (0)