Skip to content

Commit

Permalink
Some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
atao committed Feb 5, 2024
1 parent 59ea0ca commit f834bcd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions shodan2db.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@


class Shodan2DB():
# Constructor initializes the database and export file with the appropriate extensions
def __init__(self, database, exportfile):
if not database.endswith(".db"):
self.database = "{}.db".format(database)
if not exportfile.endswith(".html"):
self.exportfile = "{}.html".format(exportfile)

# Static method to create tables and views in the SQLite database
@staticmethod
def prepare_database(verbose, database):
if not database.endswith(".db"):
database = "{}.db".format(database)
# Create database
try:
if verbose:
Expand Down Expand Up @@ -48,6 +43,8 @@ def prepare_database(verbose, database):
# Static method to parse a JSON file and insert data into the database
@staticmethod
def parser(verbose, inputfile, database):
if not database.endswith(".db"):
database = "{}.db".format(database)
if verbose:
print("[+] Parsing file...")
try:
Expand Down Expand Up @@ -148,6 +145,10 @@ def parser(verbose, inputfile, database):
# Static method to generate an HTML report from the database data
@staticmethod
def export(verbose, exportfile, database):
if not exportfile.endswith(".html"):
exportfile = "{}.html".format(exportfile)
if not database.endswith(".db"):
database = "{}.db".format(database)
try:
conn = sqlite3.connect(database)
cursor = conn.cursor()
Expand Down
2 changes: 1 addition & 1 deletion templates/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<br>
<nav class="navbar is-fixed-top is-transparent mx-4">
<div class="navbar-brand">
<a class="navbar-item has-text-weight-semibold" href="#top">
<a class="navbar-item has-text-weight-semibold" href="#top" title="top">
Shodan2DB
</a>
<a role="button" class="navbar-burger" data-target="navMenu" aria-label="menu" aria-expanded="false">
Expand Down

0 comments on commit f834bcd

Please sign in to comment.