Skip to content

Commit 03abba3

Browse files
Update dpulse.py [created function run() to support entry point]
1 parent 8fda590 commit 03abba3

File tree

1 file changed

+99
-95
lines changed

1 file changed

+99
-95
lines changed

dpulse.py

Lines changed: 99 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -39,104 +39,108 @@ def run(self):
3939

4040
db.db_creation('report_storage.db')
4141

42-
while True:
43-
cli.print_main_menu()
44-
choice = input(Fore.YELLOW + "Enter your choice >> ")
45-
if choice == "1":
46-
print('\n')
47-
while True:
48-
short_domain = input(Fore.YELLOW + "\nEnter target's domain name (or 'back' to return to the menu) >> ")
49-
if short_domain.lower() == "back":
50-
print(Fore.RED + "\nReturned to main menu")
51-
break
52-
else:
53-
url = "http://" + short_domain + "/"
54-
case_comment = input(Fore.YELLOW + "Enter case comment (or enter '-' if you don't need comment to the case) >> ")
55-
report_filetype = input(Fore.YELLOW + "Enter report file extension [xlsx/pdf] >> ")
56-
report_filetype_lowered = report_filetype.lower()
57-
if report_filetype_lowered == 'pdf' or report_filetype_lowered == 'xlsx':
58-
print(Fore.LIGHTMAGENTA_EX + "\n[PRE-SCAN SUMMARY]\n" + Style.RESET_ALL)
59-
print(Fore.GREEN + "Determined target: {}\nCase comment: {}\nReport file extension: {}\n".format(short_domain, case_comment, report_filetype_lowered) + Style.RESET_ALL)
60-
print(Fore.LIGHTMAGENTA_EX + "[SCANNING PROCESS]\n" + Style.RESET_ALL)
61-
spinner_thread = ProgressBar()
62-
spinner_thread.start()
63-
if report_filetype_lowered == 'pdf':
64-
try:
65-
data_array, report_info_array = data_processing.data_gathering(short_domain, url, report_filetype_lowered)
66-
pdf_rc.report_assembling(short_domain, url, case_comment, data_array, report_info_array)
67-
finally:
68-
spinner_thread.do_run = False
69-
spinner_thread.join()
70-
elif report_filetype_lowered == 'xlsx':
71-
try:
72-
data_array, report_info_array = data_processing.data_gathering(short_domain, url, report_filetype_lowered)
73-
xlsx_rc.create_report(short_domain, url, case_comment, data_array, report_info_array)
74-
finally:
75-
spinner_thread.do_run = False
76-
spinner_thread.join()
42+
def run():
43+
while True:
44+
cli.print_main_menu()
45+
choice = input(Fore.YELLOW + "Enter your choice >> ")
46+
if choice == "1":
47+
print('\n')
48+
while True:
49+
short_domain = input(Fore.YELLOW + "\nEnter target's domain name (or 'back' to return to the menu) >> ")
50+
if short_domain.lower() == "back":
51+
print(Fore.RED + "\nReturned to main menu")
52+
break
7753
else:
78-
print(Fore.RED + "Unsupported report file extension. Please choose between xlsx or pdf.")
54+
url = "http://" + short_domain + "/"
55+
case_comment = input(Fore.YELLOW + "Enter case comment (or enter '-' if you don't need comment to the case) >> ")
56+
report_filetype = input(Fore.YELLOW + "Enter report file extension [xlsx/pdf] >> ")
57+
report_filetype_lowered = report_filetype.lower()
58+
if report_filetype_lowered == 'pdf' or report_filetype_lowered == 'xlsx':
59+
print(Fore.LIGHTMAGENTA_EX + "\n[PRE-SCAN SUMMARY]\n" + Style.RESET_ALL)
60+
print(Fore.GREEN + "Determined target: {}\nCase comment: {}\nReport file extension: {}\n".format(short_domain, case_comment, report_filetype_lowered) + Style.RESET_ALL)
61+
print(Fore.LIGHTMAGENTA_EX + "[SCANNING PROCESS]\n" + Style.RESET_ALL)
62+
spinner_thread = ProgressBar()
63+
spinner_thread.start()
64+
if report_filetype_lowered == 'pdf':
65+
try:
66+
data_array, report_info_array = data_processing.data_gathering(short_domain, url, report_filetype_lowered)
67+
pdf_rc.report_assembling(short_domain, url, case_comment, data_array, report_info_array)
68+
finally:
69+
spinner_thread.do_run = False
70+
spinner_thread.join()
71+
elif report_filetype_lowered == 'xlsx':
72+
try:
73+
data_array, report_info_array = data_processing.data_gathering(short_domain, url, report_filetype_lowered)
74+
xlsx_rc.create_report(short_domain, url, case_comment, data_array, report_info_array)
75+
finally:
76+
spinner_thread.do_run = False
77+
spinner_thread.join()
78+
else:
79+
print(Fore.RED + "Unsupported report file extension. Please choose between xlsx or pdf.")
7980

80-
elif choice == "2":
81-
cli.print_settings_menu()
82-
choice_settings = input(Fore.YELLOW + "Enter your choice >> ")
83-
if choice_settings == '1':
84-
with open('dorkslist.txt', 'r') as cfg_file:
85-
print(Fore.LIGHTMAGENTA_EX + '\n[START OF CONFIG FILE]' + Style.RESET_ALL)
86-
print('\n' + Fore.LIGHTBLUE_EX + cfg_file.read() + Style.RESET_ALL)
87-
print(Fore.LIGHTMAGENTA_EX + '\n[END OF CONFIG FILE]\n' + Style.RESET_ALL)
88-
continue
89-
elif choice_settings == '2':
90-
with open('dorkslist.txt', 'a+') as cfg_file:
91-
print(Fore.LIGHTMAGENTA_EX + '\n[START OF CONFIG FILE]' + Style.RESET_ALL)
92-
cfg_file.seek(0)
93-
print('\n' + Fore.LIGHTBLUE_EX + cfg_file.read() + Style.RESET_ALL)
94-
print(Fore.LIGHTMAGENTA_EX + '\n[END OF CONFIG FILE]\n' + Style.RESET_ALL)
95-
new_line = str(input(Fore.YELLOW + "Input new dork >> ") + Style.RESET_ALL)
96-
print(Fore.GREEN + "New dork successfully added to dorks list" + Style.RESET_ALL)
97-
cfg_file.write(new_line + '\n')
81+
elif choice == "2":
82+
cli.print_settings_menu()
83+
choice_settings = input(Fore.YELLOW + "Enter your choice >> ")
84+
if choice_settings == '1':
85+
with open('dorkslist.txt', 'r') as cfg_file:
86+
print(Fore.LIGHTMAGENTA_EX + '\n[START OF CONFIG FILE]' + Style.RESET_ALL)
87+
print('\n' + Fore.LIGHTBLUE_EX + cfg_file.read() + Style.RESET_ALL)
88+
print(Fore.LIGHTMAGENTA_EX + '\n[END OF CONFIG FILE]\n' + Style.RESET_ALL)
89+
continue
90+
elif choice_settings == '2':
91+
with open('dorkslist.txt', 'a+') as cfg_file:
92+
print(Fore.LIGHTMAGENTA_EX + '\n[START OF CONFIG FILE]' + Style.RESET_ALL)
93+
cfg_file.seek(0)
94+
print('\n' + Fore.LIGHTBLUE_EX + cfg_file.read() + Style.RESET_ALL)
95+
print(Fore.LIGHTMAGENTA_EX + '\n[END OF CONFIG FILE]\n' + Style.RESET_ALL)
96+
new_line = str(input(Fore.YELLOW + "Input new dork >> ") + Style.RESET_ALL)
97+
print(Fore.GREEN + "New dork successfully added to dorks list" + Style.RESET_ALL)
98+
cfg_file.write(new_line + '\n')
99+
continue
100+
elif choice_settings == '3':
98101
continue
99-
elif choice_settings == '3':
100-
continue
101-
break
102+
break
102103

103-
elif choice == "3":
104-
cli.print_help_menu()
105-
choice_help = input(Fore.YELLOW + "Enter your choice >> ")
106-
if choice_help == '1':
107-
webbrowser.open('https://github.com/OSINT-TECHNOLOGIES/dpulse/wiki/How-to-correctly-input-your-targets-address-in-DPULSE')
108-
elif choice_help == '2':
109-
webbrowser.open('https://github.com/OSINT-TECHNOLOGIES/dpulse/wiki/DPULSE-interface-colors-meaning')
110-
elif choice_help == '3':
111-
continue
104+
elif choice == "3":
105+
cli.print_help_menu()
106+
choice_help = input(Fore.YELLOW + "Enter your choice >> ")
107+
if choice_help == '1':
108+
webbrowser.open('https://github.com/OSINT-TECHNOLOGIES/dpulse/wiki/How-to-correctly-input-your-targets-address-in-DPULSE')
109+
elif choice_help == '2':
110+
webbrowser.open('https://github.com/OSINT-TECHNOLOGIES/dpulse/wiki/DPULSE-interface-colors-meaning')
111+
elif choice_help == '3':
112+
continue
112113

113-
elif choice == "4":
114-
cli.print_db_menu()
115-
print('\n')
116-
db.db_creation('report_storage.db')
117-
print('\n')
118-
choice_db = input(Fore.YELLOW + "Enter your choice >> ")
119-
if choice_db == '1':
120-
db.db_select()
121-
elif choice_db == "2":
122-
if db.db_select() is None:
123-
pass
124-
else:
125-
print(Fore.LIGHTMAGENTA_EX + "\n[DATABASE'S CONTENT]\n" + Style.RESET_ALL)
126-
cursor, sqlite_connection = db.db_select()
127-
id_to_extract = int(input(Fore.YELLOW + "\nEnter report ID you want to extract >> "))
128-
extracted_folder_name = 'report_recreated_ID#{}'.format(id_to_extract)
129-
try:
130-
os.makedirs(extracted_folder_name)
131-
db.db_report_recreate(extracted_folder_name, id_to_extract)
132-
except FileExistsError:
133-
print(Fore.RED + "Folder with the same name alredy exists. Delete it or just check it's content" + Style.RESET_ALL)
114+
elif choice == "4":
115+
cli.print_db_menu()
116+
print('\n')
117+
db.db_creation('report_storage.db')
118+
print('\n')
119+
choice_db = input(Fore.YELLOW + "Enter your choice >> ")
120+
if choice_db == '1':
121+
db.db_select()
122+
elif choice_db == "2":
123+
if db.db_select() is None:
134124
pass
135-
elif choice_db == "3":
136-
print(Fore.GREEN + "\nDatabase connection is successfully closed")
137-
continue
138-
elif choice == "5":
139-
print(Fore.RED + "Exiting the program." + Style.RESET_ALL)
140-
break
141-
else:
142-
print(Fore.RED + "Invalid choice. Please enter an existing menu item" + Style.RESET_ALL)
125+
else:
126+
print(Fore.LIGHTMAGENTA_EX + "\n[DATABASE'S CONTENT]\n" + Style.RESET_ALL)
127+
cursor, sqlite_connection = db.db_select()
128+
id_to_extract = int(input(Fore.YELLOW + "\nEnter report ID you want to extract >> "))
129+
extracted_folder_name = 'report_recreated_ID#{}'.format(id_to_extract)
130+
try:
131+
os.makedirs(extracted_folder_name)
132+
db.db_report_recreate(extracted_folder_name, id_to_extract)
133+
except FileExistsError:
134+
print(Fore.RED + "Folder with the same name alredy exists. Delete it or just check it's content" + Style.RESET_ALL)
135+
pass
136+
elif choice_db == "3":
137+
print(Fore.GREEN + "\nDatabase connection is successfully closed")
138+
continue
139+
elif choice == "5":
140+
print(Fore.RED + "Exiting the program." + Style.RESET_ALL)
141+
break
142+
else:
143+
print(Fore.RED + "Invalid choice. Please enter an existing menu item" + Style.RESET_ALL)
144+
145+
if __name__ == "__main__":
146+
run()

0 commit comments

Comments
 (0)