Skip to content

Commit

Permalink
Merge pull request #30 from kelvinBen/v1.0.9.1
Browse files Browse the repository at this point in the history
add "识别到壳后自动进行脱壳处理"
  • Loading branch information
kelvinBen authored Dec 18, 2022
2 parents 18188fd + ae2de54 commit b8a2aa0
Show file tree
Hide file tree
Showing 8 changed files with 434 additions and 54 deletions.
61 changes: 41 additions & 20 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,28 @@
def cli():
pass


# 创建Android任务


@cli.command(help="Get the key information of Android system.")
@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.")
@click.option("-r", "--rules", required=False, type=str, default="", help="Please enter a rule for temporary scanning of file contents.")
@click.option("-s", "--sniffer", is_flag=True, default=False, help="Enable the network sniffer function. It is on by default.")
@click.option("-n", '--no-resource', is_flag=True, default=False, help="Ignore all resource files, including network sniffing. It is not enabled by default.")
@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.")
@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.")
@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.")
@click.option("-r", "--rules", required=False, type=str, default="",
help="Please enter a rule for temporary scanning of file contents.")
@click.option("-s", "--sniffer", is_flag=True, default=False,
help="Enable the network sniffer function. It is on by default.")
@click.option("-n", '--no-resource', is_flag=True, default=False,
help="Ignore all resource files, including network sniffing. It is not enabled by default.")
@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.")
@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.")
@click.option("-o", '--output', required=False, type=str, default=None, help="Specify the result set output directory.")
@click.option("-p", '--package', required=False, type=str, default="", help="Specifies the package name information that needs to be scanned.")
def android(inputs: str, rules: str, sniffer: bool, no_resource: bool, all: bool, threads: int, output, package: str) -> None:
@click.option("-p", '--package', required=False, type=str, default="",
help="Specifies the package name information that needs to be scanned.")
def android(inputs: str, rules: str, sniffer: bool, no_resource: bool, all: bool, threads: int, output,
package: str) -> None:
try:
bootstrapper = Bootstrapper(__file__, output, all, no_resource)
bootstrapper.init()
Expand All @@ -36,12 +45,18 @@ def android(inputs: str, rules: str, sniffer: bool, no_resource: bool, all: bool


@cli.command(help="Get the key information of iOS system.")
@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.")
@click.option("-r", "--rules", required=False, type=str, default="", help="Please enter a rule for temporary scanning of file contents.")
@click.option("-s", "--sniffer", is_flag=True, default=False, help="Enable the network sniffer function. It is on by default.")
@click.option("-n", '--no-resource', is_flag=True, default=False, help="Ignore all resource files, including network sniffing. It is not enabled by default.")
@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.")
@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.")
@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.")
@click.option("-r", "--rules", required=False, type=str, default="",
help="Please enter a rule for temporary scanning of file contents.")
@click.option("-s", "--sniffer", is_flag=True, default=False,
help="Enable the network sniffer function. It is on by default.")
@click.option("-n", '--no-resource', is_flag=True, default=False,
help="Ignore all resource files, including network sniffing. It is not enabled by default.")
@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.")
@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.")
@click.option("-o", '--output', required=False, type=str, default=None, help="Specify the result set output directory.")
def ios(inputs: str, rules: str, sniffer: bool, no_resource: bool, all: bool, threads: int, output: str) -> None:
try:
Expand All @@ -54,12 +69,18 @@ def ios(inputs: str, rules: str, sniffer: bool, no_resource: bool, all: bool, th


@cli.command(help="Get the key information of Web system.")
@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.")
@click.option("-r", "--rules", required=False, type=str, default="", help="Please enter a rule for temporary scanning of file contents.")
@click.option("-s", "--sniffer", is_flag=True, default=False, help="Enable the network sniffer function. It is on by default.")
@click.option("-n", '--no-resource', is_flag=True, default=False, help="Ignore all resource files, including network sniffing. It is not enabled by default.")
@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.")
@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.")
@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.")
@click.option("-r", "--rules", required=False, type=str, default="",
help="Please enter a rule for temporary scanning of file contents.")
@click.option("-s", "--sniffer", is_flag=True, default=False,
help="Enable the network sniffer function. It is on by default.")
@click.option("-n", '--no-resource', is_flag=True, default=False,
help="Ignore all resource files, including network sniffing. It is not enabled by default.")
@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.")
@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.")
@click.option("-o", '--output', required=False, type=str, default=None, help="Specify the result set output directory.")
def web(inputs: str, rules: str, sniffer: bool, no_resource: bool, all: bool, threads: int, output: str) -> None:
try:
Expand Down
71 changes: 45 additions & 26 deletions libs/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
# apktool 所在路径
apktool_path = ""

# adb 所在路径
adb_path = ""

# frida server 所在路径
frida32_path = ""
frida64_path = ""

# aapt 所在路径
aapt_apth = ""

# 系统类型
os_type = ""

Expand All @@ -28,12 +38,17 @@
# excel 起始行号
excel_row = 1


class Bootstrapper(object):

def __init__(self, path, out_path, all=False, no_resource= False):
def __init__(self, path, out_path, all=False, no_resource=False):
global smali_path
global backsmali_path
global apktool_path
global adb_path
global frida32_path
global frida64_path
global aapt_apth
global os_type
global output_path
global script_root_dir
Expand All @@ -43,44 +58,48 @@ def __init__(self, path, out_path, all=False, no_resource= False):
global history_path
global app_history_path
global domain_history_path
global excel_row
global excel_row
global download_path
global download_flag
global out_dir
global all_flag
global resource_flag
global resource_flag

all_flag = not all
resource_flag = no_resource

create_time = time.strftime("%Y%m%d%H%M%S", time.localtime())
script_root_dir = os.path.dirname(os.path.abspath(path))
script_root_dir = os.path.dirname(os.path.abspath(path))
if out_path:
out_dir = out_path
else:
out_dir = script_root_dir
tools_dir = os.path.join(script_root_dir,"tools")
output_path = os.path.join(out_dir,"out")
history_path = os.path.join(script_root_dir,"history")
tools_dir = os.path.join(script_root_dir, "tools")
output_path = os.path.join(out_dir, "out")
history_path = os.path.join(script_root_dir, "history")

if platform.system() == "Windows":
machine2bits = {'AMD64':64, 'x86_64': 64, 'i386': 32, 'x86': 32}
machine2bits = {'AMD64': 64, 'x86_64': 64, 'i386': 32, 'x86': 32}
machine2bits.get(platform.machine())

if platform.machine() == 'i386' or platform.machine() == 'x86':
strings_path = os.path.join(tools_dir,"strings.exe")
strings_path = os.path.join(tools_dir, "strings.exe")
else:
strings_path = os.path.join(tools_dir,"strings64.exe")
strings_path = os.path.join(tools_dir, "strings64.exe")
else:
strings_path ="strings"
backsmali_path = os.path.join(tools_dir,"baksmali.jar")
strings_path = "strings"

backsmali_path = os.path.join(tools_dir, "baksmali.jar")
apktool_path = os.path.join(tools_dir, "apktool.jar")
download_path = os.path.join(out_dir,"download")
txt_result_path = os.path.join(out_dir,"result_"+str(create_time)+".txt")
xls_result_path = os.path.join(out_dir,"result_"+str(create_time)+".xlsx")
app_history_path = os.path.join(history_path,"app_history.txt")
domain_history_path = os.path.join(history_path,"domain_history.txt")
adb_path = os.path.join(tools_dir + '\\unpacker', "adb.exe")
frida32_path = os.path.join(tools_dir + '\\unpacker', "hexl-server-arm32")
frida64_path = os.path.join(tools_dir + '\\unpacker', "hexl-server-arm64")
aapt_apth = os.path.join(tools_dir + '\\unpacker', "aapt.exe")
download_path = os.path.join(out_dir, "download")
txt_result_path = os.path.join(out_dir, "result_" + str(create_time) + ".txt")
xls_result_path = os.path.join(out_dir, "result_" + str(create_time) + ".xlsx")
app_history_path = os.path.join(history_path, "app_history.txt")
domain_history_path = os.path.join(history_path, "domain_history.txt")

def init(self):
if not os.path.exists(out_dir):
Expand All @@ -95,7 +114,7 @@ def init(self):
if not (platform.system() == "Windows"):
raise e
self.__removed_dirs_cmd__(output_path)

os.makedirs(output_path)
print("[*] Create directory {}".format(output_path))

Expand All @@ -106,22 +125,22 @@ def init(self):
if not os.path.exists(history_path):
os.makedirs(history_path)
print("[*] Create directory {}".format(history_path))

if os.path.exists(txt_result_path):
os.remove(txt_result_path)

if os.path.exists(xls_result_path):
os.remove(xls_result_path)
def __removed_dirs_cmd__(self,output_path):

def __removed_dirs_cmd__(self, output_path):
files = os.listdir(output_path)
for file in files:
new_dir = os.path.join(output_path,"newdir")
old_dir = os.path.join(output_path,file)
new_dir = os.path.join(output_path, "newdir")
old_dir = os.path.join(output_path, file)
if not os.path.exists(new_dir):
os.makedirs(new_dir)
os.chdir(output_path)
cmd = ("robocopy %s %s /purge") % (new_dir, old_dir)
os.system(cmd)
os.removedirs(new_dir)
os.removedirs(old_dir)
os.removedirs(old_dir)
Loading

0 comments on commit b8a2aa0

Please sign in to comment.