Skip to content

Commit d2c28bd

Browse files
Updated dpulse.py to 0.5b
1 parent 8a0bf86 commit d2c28bd

File tree

1 file changed

+91
-4
lines changed

1 file changed

+91
-4
lines changed

dpulse.py

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
from rich.console import Console
1616
import sys
1717
import webbrowser
18+
import sqlite3
19+
import os
1820
except ImportError:
1921
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)
2022
sys.exit()
@@ -33,7 +35,7 @@ def run(self):
3335
console = Console()
3436
fig = Figlet(font='univers')
3537
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)
3739
print(Fore.BLUE + Back.WHITE + 'Developed by: OSINT-TECHNOLOGIES (https://github.com/OSINT-TECHNOLOGIES)' + Style.RESET_ALL + '\n\n')
3840

3941
def print_main_menu():
@@ -42,8 +44,8 @@ def print_main_menu():
4244
print(Fore.GREEN + "1. Determine target and start scan")
4345
print(Fore.GREEN + "2. Settings")
4446
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')
4749
def print_settings_menu():
4850
print('\n')
4951
print(Fore.BLUE + '[SETTINGS MENU]')
@@ -66,6 +68,13 @@ def print_help_menu():
6668
print(Fore.GREEN + "2. DPULSE config parameters and their meanings")
6769
print(Fore.RED + "3. Return to main menu" + Style.RESET_ALL + '\n')
6870

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+
6978
def change_setting(filename):
7079
cfg_context = open(filename).read()
7180

@@ -94,11 +103,12 @@ def change_setting(filename):
94103
short_domain = str(input(Fore.YELLOW + "Enter target's domain name >> "))
95104
url = "http://" + short_domain + "/"
96105
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) >> "))
97107
print(Fore.GREEN + 'Determined target >> {}\nShow {} Google Dorking result'.format(short_domain, dorking_results_amount) + Style.RESET_ALL)
98108
spinner_thread = ProgressBar()
99109
spinner_thread.start()
100110
try:
101-
rc.create_report(short_domain, url, dorking_results_amount)
111+
rc.create_report(short_domain, url, dorking_results_amount, case_comment)
102112
finally:
103113
spinner_thread.do_run = False
104114
spinner_thread.join()
@@ -126,7 +136,84 @@ def change_setting(filename):
126136
webbrowser.open('https://github.com/OSINT-TECHNOLOGIES/dpulse/wiki/DPULSE-config-parameters-and-their-meanings')
127137
elif choice_help == '3':
128138
continue
139+
129140
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":
130217
print(Fore.RED + "Exiting the program." + Style.RESET_ALL)
131218
break
132219
else:

0 commit comments

Comments
 (0)