Skip to content

Commit 8dd4ca9

Browse files
Update main.py
1 parent 2389267 commit 8dd4ca9

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

main.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,12 @@ def extract_and_analyse():
101101
def extract_and_analyse2():
102102
log_procedure("Starting extraction and analysis process")
103103

104-
url = "http://192.144.168.75/api_docs"
104+
endpoint = "172.22.21.51:8000"
105+
if mobsf_entry2.get().strip():
106+
endpoint = mobsf_entry2.get().strip()
107+
105108
try:
109+
url = f"http://{endpoint}/api_docs"
106110
response = requests.get(url)
107111
if response.status_code == 200:
108112
soup = BeautifulSoup(response.text, 'html.parser')
@@ -117,8 +121,8 @@ def extract_and_analyse2():
117121

118122
except requests.exceptions.RequestException as e:
119123
log_procedure(f"An error occurred: {e}")
120-
121-
SERVER = "http://192.144.168.75"
124+
125+
SERVER = f"http://{endpoint}"
122126
APIKEY = api_key_value
123127
paths = extract_selected_files2()
124128
log_procedure(f"Selected files to process: {paths}")
@@ -128,21 +132,19 @@ def extract_and_analyse2():
128132
try:
129133
FILE = paths[0] + paths[i] + "/base.apk"
130134

131-
"""Upload File"""
132135
log_procedure("Uploading file")
133136
multipart_data = MultipartEncoder(fields={'file': (FILE, open(FILE, 'rb'), 'application/octet-stream')})
134137
headers = {'Content-Type': multipart_data.content_type, 'Authorization': APIKEY}
135138
response = requests.post(SERVER + '/api/v1/upload', data=multipart_data, headers=headers)
136139
data0 = response.text
137140

138-
"""Scan the file"""
139141
log_procedure("Scanning file")
140142
post_dict = json.loads(data0)
141143
headers = {'Authorization': APIKEY}
142144
response = requests.post(SERVER + '/api/v1/scan', data=post_dict, headers=headers)
143145

144146
data = {"hash": json.loads(data0)["hash"]}
145-
webbrowser.open_new_tab(f"http://192.144.168.75/StaticAnalyzer/?name=base.apk&type=apk&checksum={data['hash']}")
147+
webbrowser.open_new_tab(f"http://{endpoint}/static_analyzer/{data['hash']}/")
146148
log_procedure("HTML report opened in web browser")
147149

148150
except requests.exceptions.RequestException as e:
@@ -298,7 +300,7 @@ def select_all_items():
298300
widget.var.set(1)
299301

300302
def deselect_all_items():
301-
# Iterate through all items in the listbox
303+
# Iterate through all itemshtt in the listbox
302304
for widget in listbox.winfo_children():
303305
if isinstance(widget, tk.Checkbutton):
304306
widget.var.set(0)
@@ -483,6 +485,17 @@ def read_last_file_path3():
483485
return file.read().strip()
484486
else:
485487
return ""
488+
489+
def save_entry_content(event=None):
490+
content = mobsf_entry2.get().strip()
491+
with open("mobsf_entry_content.txt", "w") as file:
492+
file.write(content)
493+
494+
def load_entry_content():
495+
if os.path.exists("mobsf_entry_content.txt"):
496+
with open("mobsf_entry_content.txt", "r") as file:
497+
content = file.read()
498+
mobsf_entry2.insert(tk.END, content)
486499

487500
def browse_file3():
488501
filename = filedialog.askopenfilename()
@@ -567,7 +580,9 @@ def browse_file3():
567580
top_center_left_left_frame = tk.Label(top_center_left_frame)
568581
top_center_left_left_frame.pack(side=tk.LEFT, fill=tk.X)
569582
top_center_left_right_frame = tk.Label(top_center_left_frame)
570-
top_center_left_right_frame.pack(side=tk.RIGHT, fill=tk.X)
583+
top_center_left_right_frame.pack(side=tk.RIGHT)
584+
top_center_left_right_left_frame = tk.Label(top_center_left_frame)
585+
top_center_left_right_left_frame.pack(side=tk.LEFT, fill=tk.X, expand=True)
571586
apk_file_label = tk.Label(top_center_left_left_frame, text="APK Files", font=("consolas", 16))
572587
apk_file_label.pack(side=tk.TOP, padx=5, pady=5)
573588
select_all_button2 = tk.Button(top_center_left_right_frame, text="Select ALL", command=toggle_select_all2)
@@ -578,6 +593,11 @@ def browse_file3():
578593
apk_entry.pack(side=tk.RIGHT ,padx=5, pady=5)
579594
apk_filter_label = tk.Label(top_center_left_frame, text="Filter:")
580595
apk_filter_label.pack(padx=5, pady=5, side=tk.RIGHT)
596+
mobsf_entry2 = tk.Entry(top_center_left_right_left_frame)
597+
mobsf_entry2.pack(side=tk.RIGHT ,padx=5, pady=5)
598+
load_entry_content()
599+
mobsf_label = tk.Label(top_center_left_right_left_frame, text="Mobsf (ip:port):")
600+
mobsf_label.pack(padx=5, pady=5, side=tk.RIGHT)
581601

582602
top_right_left_frame = tk.Label(top_right_frame)
583603
top_right_left_frame.pack(side=tk.TOP, fill=tk.X)
@@ -653,8 +673,9 @@ def browse_file3():
653673
extract_button3 = tk.Button(bot_right_frame, text="Extract Selected Files", command=extract_selected_files3)
654674
extract_button3.pack(pady=5)
655675

676+
root.bind("<Destroy>", save_entry_content)
656677
# Run the GUI
657678
root.mainloop()
658679

659680
if __name__ == '__main__':
660-
applicationGUI()
681+
applicationGUI()

0 commit comments

Comments
 (0)