@@ -101,8 +101,12 @@ def extract_and_analyse():
101
101
def extract_and_analyse2 ():
102
102
log_procedure ("Starting extraction and analysis process" )
103
103
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
+
105
108
try :
109
+ url = f"http://{ endpoint } /api_docs"
106
110
response = requests .get (url )
107
111
if response .status_code == 200 :
108
112
soup = BeautifulSoup (response .text , 'html.parser' )
@@ -117,8 +121,8 @@ def extract_and_analyse2():
117
121
118
122
except requests .exceptions .RequestException as e :
119
123
log_procedure (f"An error occurred: { e } " )
120
-
121
- SERVER = "http://192.144.168.75 "
124
+
125
+ SERVER = f "http://{ endpoint } "
122
126
APIKEY = api_key_value
123
127
paths = extract_selected_files2 ()
124
128
log_procedure (f"Selected files to process: { paths } " )
@@ -128,21 +132,19 @@ def extract_and_analyse2():
128
132
try :
129
133
FILE = paths [0 ] + paths [i ] + "/base.apk"
130
134
131
- """Upload File"""
132
135
log_procedure ("Uploading file" )
133
136
multipart_data = MultipartEncoder (fields = {'file' : (FILE , open (FILE , 'rb' ), 'application/octet-stream' )})
134
137
headers = {'Content-Type' : multipart_data .content_type , 'Authorization' : APIKEY }
135
138
response = requests .post (SERVER + '/api/v1/upload' , data = multipart_data , headers = headers )
136
139
data0 = response .text
137
140
138
- """Scan the file"""
139
141
log_procedure ("Scanning file" )
140
142
post_dict = json .loads (data0 )
141
143
headers = {'Authorization' : APIKEY }
142
144
response = requests .post (SERVER + '/api/v1/scan' , data = post_dict , headers = headers )
143
145
144
146
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' ]} / " )
146
148
log_procedure ("HTML report opened in web browser" )
147
149
148
150
except requests .exceptions .RequestException as e :
@@ -298,7 +300,7 @@ def select_all_items():
298
300
widget .var .set (1 )
299
301
300
302
def deselect_all_items ():
301
- # Iterate through all items in the listbox
303
+ # Iterate through all itemshtt in the listbox
302
304
for widget in listbox .winfo_children ():
303
305
if isinstance (widget , tk .Checkbutton ):
304
306
widget .var .set (0 )
@@ -483,6 +485,17 @@ def read_last_file_path3():
483
485
return file .read ().strip ()
484
486
else :
485
487
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 )
486
499
487
500
def browse_file3 ():
488
501
filename = filedialog .askopenfilename ()
@@ -567,7 +580,9 @@ def browse_file3():
567
580
top_center_left_left_frame = tk .Label (top_center_left_frame )
568
581
top_center_left_left_frame .pack (side = tk .LEFT , fill = tk .X )
569
582
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 )
571
586
apk_file_label = tk .Label (top_center_left_left_frame , text = "APK Files" , font = ("consolas" , 16 ))
572
587
apk_file_label .pack (side = tk .TOP , padx = 5 , pady = 5 )
573
588
select_all_button2 = tk .Button (top_center_left_right_frame , text = "Select ALL" , command = toggle_select_all2 )
@@ -578,6 +593,11 @@ def browse_file3():
578
593
apk_entry .pack (side = tk .RIGHT ,padx = 5 , pady = 5 )
579
594
apk_filter_label = tk .Label (top_center_left_frame , text = "Filter:" )
580
595
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 )
581
601
582
602
top_right_left_frame = tk .Label (top_right_frame )
583
603
top_right_left_frame .pack (side = tk .TOP , fill = tk .X )
@@ -653,8 +673,9 @@ def browse_file3():
653
673
extract_button3 = tk .Button (bot_right_frame , text = "Extract Selected Files" , command = extract_selected_files3 )
654
674
extract_button3 .pack (pady = 5 )
655
675
676
+ root .bind ("<Destroy>" , save_entry_content )
656
677
# Run the GUI
657
678
root .mainloop ()
658
679
659
680
if __name__ == '__main__' :
660
- applicationGUI ()
681
+ applicationGUI ()
0 commit comments