Skip to content

Commit

Permalink
Update config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rly0nheart authored Jun 26, 2023
1 parent 2782378 commit d39506a
Showing 1 changed file with 48 additions and 10 deletions.
58 changes: 48 additions & 10 deletions oxdork/config.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,64 @@
import os
import json
import logging
import argparse
from rich.logging import RichHandler
from oxdork.banner import ascii_banner


class Version:
def __init__(self):
"""
Initialize the Version class.
Retrieves version components from the data() function and assigns them to instance variables.
"""
self.major = data()["program"]["version"]["major"]
self.minor = data()["program"]["version"]["minor"]
self.patch = data()["program"]["version"]["patch"]
self.suffix = data()["program"]["version"]["suffix"]

def full_version(self) -> str:
"""
Return the full version string composed of the version components.
:return: The complete version string in the format "major.minor.patchsuffix".
"""
return f"{self.major}.{self.minor}.{self.patch}{self.suffix}"


def data() -> dict:
"""
Loads the program's data from data/data.json
:return: Dictionary (JSON) containing program data
"""
# Get the absolute path of the current file
current_dir = os.path.dirname(os.path.abspath(__file__))

# Construct the path to the data.json file
settings_path = os.path.join(current_dir, "data", "data.json")

# Load the settings from the file
with open(settings_path) as file:
program_data = json.load(file)

return program_data


# Create parser
def create_parser():
parser = argparse.ArgumentParser(description="Google dorking tool — by Richard Mwewa (https://about.me/rly0nheart)",
epilog="oxDork uses Google dorking techniques and Google dorks to find security holes and misconfigurations in web servers.")
parser = argparse.ArgumentParser(description=f"{data()['program']['name']} v{Version().full_version()} — by"
f" {data()['program']['developer']['name']}"
f" ({data()['program']['developer']['about']})",
epilog=data()['program']['about'])
parser.add_argument("query", help="query string or text file containing queries")
parser.add_argument("-c", "--count", help="number of results to show (default %(default)s).", default=10)
parser.add_argument("-o", "--output", help="write output to specified file.")
parser.add_argument("-v", "--version", action="version",
version=ascii_banner()[1])
version=Version().full_version())
return parser


# Parse command line arguments
parser = create_parser()
arguments = parser.parse_args()

# Configure logging
logging.basicConfig(level="NOTSET", format="%(message)s",
handlers=[RichHandler(markup=True, log_time_format='[%I:%M:%S%p]', show_level=False)])
handlers=[RichHandler(markup=True, log_time_format='%I:%M:%S%p', show_level=False)])
log = logging.getLogger("rich")

0 comments on commit d39506a

Please sign in to comment.