15
15
from rich .console import Console
16
16
import sys
17
17
import webbrowser
18
+ import sqlite3
19
+ import os
18
20
except ImportError :
19
21
print (Fore .RED + "Can't import some requirements that are necessary to start DPULSE. Please check that all necessary requirements are installed!" + Style .RESET_ALL )
20
22
sys .exit ()
@@ -33,7 +35,7 @@ def run(self):
33
35
console = Console ()
34
36
fig = Figlet (font = 'univers' )
35
37
console .print (fig .renderText ('DPULSE' ), style = "bold blue" )
36
- print (Fore .BLUE + Back .WHITE + 'HEARTBEAT // version: 0.4b ' + Style .RESET_ALL )
38
+ print (Fore .BLUE + Back .WHITE + 'HEARTBEAT // version: 0.5b ' + Style .RESET_ALL )
37
39
print (Fore .BLUE + Back .WHITE + 'Developed by: OSINT-TECHNOLOGIES (https://github.com/OSINT-TECHNOLOGIES)' + Style .RESET_ALL + '\n \n ' )
38
40
39
41
def print_main_menu ():
@@ -42,8 +44,8 @@ def print_main_menu():
42
44
print (Fore .GREEN + "1. Determine target and start scan" )
43
45
print (Fore .GREEN + "2. Settings" )
44
46
print (Fore .GREEN + "3. Help" )
45
- print (Fore .RED + "4. Exit DPULSE" + Style . RESET_ALL + ' \n ' )
46
-
47
+ print (Fore .GREEN + "4. Manage report storage database" )
48
+ print ( Fore . RED + "5. Exit DPULSE" + Style . RESET_ALL + ' \n ' )
47
49
def print_settings_menu ():
48
50
print ('\n ' )
49
51
print (Fore .BLUE + '[SETTINGS MENU]' )
@@ -66,6 +68,13 @@ def print_help_menu():
66
68
print (Fore .GREEN + "2. DPULSE config parameters and their meanings" )
67
69
print (Fore .RED + "3. Return to main menu" + Style .RESET_ALL + '\n ' )
68
70
71
+ def print_db_menu ():
72
+ print (Fore .BLUE + '[DATABASE MENU]' )
73
+ print (Fore .GREEN + "1. Show database information" )
74
+ print (Fore .GREEN + "2. Show database content" )
75
+ print (Fore .GREEN + "3. Recreate report from database" )
76
+ print (Fore .RED + "4. Return to main menu" + Style .RESET_ALL + '\n ' )
77
+
69
78
def change_setting (filename ):
70
79
cfg_context = open (filename ).read ()
71
80
@@ -94,11 +103,12 @@ def change_setting(filename):
94
103
short_domain = str (input (Fore .YELLOW + "Enter target's domain name >> " ))
95
104
url = "http://" + short_domain + "/"
96
105
dorking_results_amount = int (input (Fore .YELLOW + 'Enter amount of printed Google Dorking results >> ' ))
106
+ case_comment = str (input (Fore .YELLOW + "Enter case comment (or enter - if you don't need comment to the case) >> " ))
97
107
print (Fore .GREEN + 'Determined target >> {}\n Show {} Google Dorking result' .format (short_domain , dorking_results_amount ) + Style .RESET_ALL )
98
108
spinner_thread = ProgressBar ()
99
109
spinner_thread .start ()
100
110
try :
101
- rc .create_report (short_domain , url , dorking_results_amount )
111
+ rc .create_report (short_domain , url , dorking_results_amount , case_comment )
102
112
finally :
103
113
spinner_thread .do_run = False
104
114
spinner_thread .join ()
@@ -126,7 +136,84 @@ def change_setting(filename):
126
136
webbrowser .open ('https://github.com/OSINT-TECHNOLOGIES/dpulse/wiki/DPULSE-config-parameters-and-their-meanings' )
127
137
elif choice_help == '3' :
128
138
continue
139
+
129
140
elif choice == "4" :
141
+ print_db_menu ()
142
+ db_path = "report_storage.db"
143
+ if not os .path .exists (db_path ):
144
+ print (Fore .RED + "Report storage database was not found. DPULSE will create it in a second" )
145
+ sqlite_connection = sqlite3 .connect ('report_storage.db' )
146
+ cursor = sqlite_connection .cursor ()
147
+ create_table_sql = """
148
+ CREATE TABLE "report_storage" (
149
+ "id" INTEGER NOT NULL UNIQUE,
150
+ "report_content" BLOB NOT NULL,
151
+ "comment" TEXT NOT NULL,
152
+ "target" TEXT NOT NULL,
153
+ "creation_date" INTEGER NOT NULL,
154
+ PRIMARY KEY("id" AUTOINCREMENT)
155
+ );
156
+ """
157
+ cursor .execute (create_table_sql )
158
+ sqlite_connection .commit ()
159
+ sqlite_connection .close ()
160
+ print (Fore .GREEN + "Successfully created report storage database" )
161
+ else :
162
+ print (Fore .GREEN + "Report storage database exists" )
163
+
164
+ sqlite_connection = sqlite3 .connect ('report_storage.db' )
165
+ cursor = sqlite_connection .cursor ()
166
+ print (Fore .GREEN + "Connected to report storage database" )
167
+ choice_db = input (Fore .YELLOW + "Enter your choice >> " )
168
+ if choice_db == '1' :
169
+ try :
170
+ cursor .execute ("PRAGMA table_info(report_storage);" )
171
+ info = cursor .fetchall ()
172
+ print (Fore .YELLOW + "\n ~ DATABASE'S COLUMNS ~" + Style .RESET_ALL )
173
+ for column in info :
174
+ print (column )
175
+ cursor .close ()
176
+ except sqlite3 .Error as error :
177
+ print (Fore .RED + "Failed to see storage database's details" , error )
178
+ elif choice_db == '2' :
179
+ try :
180
+ select_query = "SELECT creation_date, target, id, comment FROM report_storage;"
181
+ cursor .execute (select_query )
182
+ records = cursor .fetchall ()
183
+ print (Fore .YELLOW + "\n ~ DATABASE'S CONTENT ~" + Style .RESET_ALL )
184
+ for row in records :
185
+ date = row [0 ]
186
+ name = row [1 ]
187
+ id = row [2 ]
188
+ comment = row [3 ]
189
+ print (Fore .BLUE + f"Case ID: { id } | Case creation date: { date } | Case name: { name } | Case comment: { comment } " + Style .RESET_ALL )
190
+ except sqlite3 .Error as error :
191
+ print (Fore .RED + "Failed to see storage database's content" , error )
192
+ elif choice_db == "3" :
193
+ print (Fore .YELLOW + "\n ~ DATABASE'S CONTENT ~" + Style .RESET_ALL )
194
+ select_query = "SELECT creation_date, target, id, comment FROM report_storage;"
195
+ cursor .execute (select_query )
196
+ records = cursor .fetchall ()
197
+ for row in records :
198
+ date = row [0 ]
199
+ name = row [1 ]
200
+ id = row [2 ]
201
+ comment = row [3 ]
202
+ print (Fore .BLUE + f"Case ID: { id } | Case creation date: { date } | Case name: { name } | Case comment: { comment } " + Style .RESET_ALL )
203
+ id_to_extract = int (input (Fore .YELLOW + "Enter ID which report you want to extract >> " ))
204
+ cursor .execute ("SELECT report_content FROM report_storage WHERE id=?" , (id_to_extract ,))
205
+ result = cursor .fetchone ()
206
+ if result is not None :
207
+ blob_data = result [0 ]
208
+ with open ('report_extracted.pdf' , 'wb' ) as file :
209
+ file .write (blob_data )
210
+ print (Fore .GREEN + "Report was successfully recreated from report storage database as report_extracted.pdf" )
211
+ elif choice_db == "4" :
212
+ if sqlite_connection :
213
+ sqlite_connection .close ()
214
+ print (Fore .RED + "Database connection is closed" )
215
+ continue
216
+ elif choice == "5" :
130
217
print (Fore .RED + "Exiting the program." + Style .RESET_ALL )
131
218
break
132
219
else :
0 commit comments