Skip to content

Commit b2594f8

Browse files
Updated dpulse.py to 0.9rc1
1 parent fe96119 commit b2594f8

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

dpulse.py

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,27 @@
1616
import webbrowser
1717
import sqlite3
1818
import os
19-
except ImportError:
20-
print(Fore.RED + "[Error #001 - Import error] Can't import some requirements that are necessary to start DPULSE. Please check that all necessary requirements are installed!" + Style.RESET_ALL)
19+
import itertools
20+
import threading
21+
from time import sleep
22+
except ImportError as e:
23+
print(Fore.RED + "Import error appeared. Reason: {}".format(e) + Style.RESET_ALL)
2124
sys.exit()
2225

2326
cli = cli_init.Menu()
24-
progress_bar = cli_init.ProgressBar()
25-
2627
cli.welcome_menu()
28+
29+
class ProgressBar(threading.Thread):
30+
def __init__(self):
31+
super(ProgressBar, self).__init__()
32+
self.do_run = True
33+
34+
def run(self):
35+
for char in itertools.cycle('|/-\\'):
36+
if not self.do_run:
37+
break
38+
print(Fore.LIGHTMAGENTA_EX + Back.WHITE + char + Style.RESET_ALL, end='\r')
39+
sleep(0.1)
2740
def db_connect():
2841
sqlite_connection = sqlite3.connect('report_storage.db')
2942
cursor = sqlite_connection.cursor()
@@ -47,10 +60,8 @@ def db_interaction(db_path):
4760
sqlite_connection.commit()
4861
sqlite_connection.close()
4962
print(Fore.GREEN + "Successfully created report storage database" + Style.RESET_ALL)
50-
print('\n')
5163
else:
5264
print(Fore.GREEN + "Report storage database exists" + Style.RESET_ALL)
53-
print('\n')
5465

5566
while True:
5667
cli.print_main_menu()
@@ -59,20 +70,20 @@ def db_interaction(db_path):
5970
if choice == "1":
6071
db_path = "report_storage.db"
6172
db_interaction(db_path)
62-
short_domain = str(input(Fore.YELLOW + "Enter target's domain name >> "))
73+
short_domain = str(input(Fore.YELLOW + "\nEnter target's domain name >> "))
6374
url = "http://" + short_domain + "/"
6475
case_comment = str(input(Fore.YELLOW + "Enter case comment (or enter - if you don't need comment to the case) >> "))
65-
print(Fore.LIGHTMAGENTA_EX + "\n/// SUMMARY ///\n" + Style.RESET_ALL)
76+
print(Fore.LIGHTMAGENTA_EX + "\n[PRE-SCAN SUMMARY]\n" + Style.RESET_ALL)
6677
print(Fore.GREEN + "Determined target: {}\nCase comment: {}\n".format(short_domain, case_comment) + Style.RESET_ALL)
67-
print(Fore.LIGHTMAGENTA_EX + "/// SCANNING PROCESS ///\n" + Style.RESET_ALL)
68-
spinner_thread = progress_bar
78+
print(Fore.LIGHTMAGENTA_EX + "[SCANNING PROCESS]\n" + Style.RESET_ALL)
79+
spinner_thread = ProgressBar()
6980
spinner_thread.start()
7081
try:
7182
rc.create_report(short_domain, url, case_comment)
7283
finally:
7384
spinner_thread.do_run = False
7485
spinner_thread.join()
75-
print(Fore.LIGHTMAGENTA_EX + "\n/// SCANNING PROCESS END ///\n" + Style.RESET_ALL)
86+
print(Fore.LIGHTMAGENTA_EX + "\n[SCANNING PROCESS END]\n" + Style.RESET_ALL)
7687
elif choice == "2":
7788
cli.print_settings_menu()
7889
choice_settings = input(Fore.YELLOW + "Enter your choice >> ")
@@ -83,6 +94,16 @@ def db_interaction(db_path):
8394
print(Fore.LIGHTMAGENTA_EX + '\n[END OF CONFIG FILE]\n' + Style.RESET_ALL)
8495
continue
8596
elif choice_settings == '2':
97+
with open('config.txt', 'a+') as cfg_file:
98+
print(Fore.LIGHTMAGENTA_EX + '\n[START OF CONFIG FILE]' + Style.RESET_ALL)
99+
cfg_file.seek(0)
100+
print('\n' + Fore.LIGHTBLUE_EX + cfg_file.read() + Style.RESET_ALL)
101+
print(Fore.LIGHTMAGENTA_EX + '\n[END OF CONFIG FILE]\n' + Style.RESET_ALL)
102+
new_line = str(input(Fore.YELLOW + "Input new dork >> ") + Style.RESET_ALL)
103+
print(Fore.GREEN + "New dork successfully added to config.txt" + Style.RESET_ALL)
104+
cfg_file.write(new_line + '\n')
105+
continue
106+
elif choice_settings == '3':
86107
continue
87108
break
88109
elif choice == "3":
@@ -103,7 +124,7 @@ def db_interaction(db_path):
103124
db_path = "report_storage.db"
104125
db_interaction(db_path)
105126
cursor, sqlite_connection = db_connect()
106-
print(Fore.GREEN + "Connected to report storage database")
127+
print(Fore.GREEN + "Connected to report storage database\n")
107128
choice_db = input(Fore.YELLOW + "Enter your choice >> ")
108129
if choice_db == '1':
109130
try:
@@ -113,8 +134,8 @@ def db_interaction(db_path):
113134
print(Fore.LIGHTMAGENTA_EX + "\n[DATABASE'S CONTENT]" + Style.RESET_ALL)
114135
for row in records:
115136
print(Fore.LIGHTBLUE_EX + f"Case ID: {row[2]} | Case creation date: {row[0]} | Case name: {row[1]} | Case comment: {row[3]}" + Style.RESET_ALL)
116-
except sqlite3.Error as error:
117-
print(Fore.RED + "[Error #002 - Sqlite3 error] Failed to see storage database's content", error)
137+
except sqlite3.Error as e:
138+
print(Fore.RED + "Failed to see storage database's content. Reason: {}".format(e))
118139
elif choice_db == "2":
119140
print(Fore.LIGHTMAGENTA_EX + "\n[DATABASE'S CONTENT]" + Style.RESET_ALL)
120141
select_query = "SELECT creation_date, target, id, comment FROM report_storage;"

0 commit comments

Comments
 (0)