Skip to content

Commit fb0aaa5

Browse files
committed
v0.10.2
### [30. June 2024] - Version 0.10.2 - **Custom Configuration Path**: Added support for specifying a custom configuration file path using the `--config` or `-c` command-line argument. - **Platform-Specific Directories**: Added support for platform-specific (*nix, macOS, Windows) configuration directories. - **Debug Mode**: Improved debug output for configuration file loading. Fixed #22
1 parent ca0d381 commit fb0aaa5

File tree

3 files changed

+50
-24
lines changed

3 files changed

+50
-24
lines changed

README.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ Create a `config.json` file in one of the following locations with your API keys
8383
- `~/.sploitscan/`
8484
- `~/.config/sploitscan/`
8585
- `/etc/sploitscan/`
86+
- `~/Library/Application Support/sploitscan/` (macOS)
87+
- `%APPDATA%/sploitscan/` (Windows)
88+
89+
You can also specify a custom configuration file path using the `--config` or `-c` command-line argument.
8690

8791
```json
8892
{
@@ -102,15 +106,15 @@ $ sploitscan.py -h
102106
╚════██║██╔═══╝ ██║ ██║ ██║██║ ██║ ╚════██║██║ ██╔══██║██║╚██╗██║
103107
███████║██║ ███████╗╚██████╔╝██║ ██║ ███████║╚██████╗██║ ██║██║ ╚████║
104108
╚══════╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═══╝
105-
v0.10.1 / Alexander Hagenah / @xaitax / [email protected]
109+
v0.10.2 / Alexander Hagenah / @xaitax / [email protected]
106110

107-
usage: sploitscan.py [-h] [-e {json,JSON,csv,CSV,html,HTML}] [-t {nessus,nexpose,openvas,docker}] [-i IMPORT_FILE] [-d] [cve_ids ...]
111+
usage: sploitscan.py [-h] [-e {json,JSON,csv,CSV,html,HTML}] [-t {nessus,nexpose,openvas,docker}] [-i IMPORT_FILE] [-c CONFIG] [-d] [cve_ids ...]
108112

109113
SploitScan: Retrieve and display vulnerability data as well as public exploits for given CVE ID(s).
110114

111115
positional arguments:
112116
cve_ids Enter one or more CVE IDs to fetch data. Separate multiple CVE IDs with spaces. Format for each ID: CVE-YYYY-NNNNN. This argument is optional if an import file is provided
113-
using the -n option.
117+
using the -i option.
114118

115119
options:
116120
-h, --help show this help message and exit
@@ -120,6 +124,8 @@ options:
120124
Specify the type of the import file: 'nessus', 'nexpose', 'openvas' or 'docker'.
121125
-i IMPORT_FILE, --import-file IMPORT_FILE
122126
Path to an import file from a vulnerability scanner. If used, CVE IDs can be omitted from the command line arguments.
127+
-c CONFIG, --config CONFIG
128+
Path to a custom config file.
123129
-d, --debug Enable debug output.
124130
```
125131
@@ -252,6 +258,12 @@ This system assists users in making informed decisions on which vulnerabilities
252258

253259
## 📆 Changelog
254260

261+
### [30. June 2024] - Version 0.10.2
262+
263+
- **Custom Configuration Path**: Added support for specifying a custom configuration file path using the `--config` or `-c` command-line argument.
264+
- **Platform-Specific Directories**: Added support for platform-specific (*nix, macOS, Windows) configuration directories.
265+
- **Debug Mode**: Improved debug output for configuration file loading.
266+
255267
### [26. June 2024] - Version 0.10
256268

257269
- **HackerOne Integration**: Added support for searching through HackerOne and displays if the CVE was used in any Bug Bounty program including its rank and severity distribution.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "sploitscan"
7-
version = "0.10.1"
7+
version = "0.10.2"
88
description = "SploitScan is a sophisticated cybersecurity utility designed to provide detailed information on vulnerabilities and associated exploits."
99
authors = [ { name = "Alexander Hagenah", email = "[email protected]" } ]
1010
license = { file = "LICENSE" }

sploitscan/sploitscan.py

+34-20
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from jinja2 import Environment, FileSystemLoader
1818

1919

20-
VERSION = "0.10.1"
20+
VERSION = "0.10.2"
2121

2222
BLUE = "\033[94m"
2323
GREEN = "\033[92m"
@@ -482,30 +482,37 @@ def template(data):
482482
"priority": priority}, template)
483483

484484

485-
def load_config(debug=False):
485+
def load_config(config_path=None, debug=False):
486486
default_config = {"vulncheck_api_key": None, "openai_api_key": None}
487-
base_path = os.path.dirname(os.path.abspath(__file__))
488-
config_paths = [
489-
os.path.join(base_path, "config.json"),
487+
config_env_var = "SPLOITSCAN_CONFIG_PATH"
488+
489+
config_paths = [config_path] if config_path else []
490+
config_paths += [
491+
os.getenv(config_env_var),
492+
os.path.join(os.path.dirname(os.path.abspath(__file__)), "config.json"),
490493
os.path.expanduser("~/.sploitscan/config.json"),
491494
os.path.expanduser("~/.config/sploitscan/config.json"),
495+
os.path.expanduser("~/Library/Application Support/sploitscan/config.json"),
496+
os.path.join(os.getenv("APPDATA", ""), "sploitscan", "config.json"),
492497
"/etc/sploitscan/config.json",
493498
]
494499

495-
for config_path in config_paths:
496-
if os.path.exists(config_path):
500+
config_paths = [path for path in config_paths if path]
501+
502+
for path in config_paths:
503+
if path and os.path.exists(path):
497504
try:
498505
if debug:
499-
print(f"⚠️ Attempting to load config file from: {config_path}")
500-
with open(config_path, "r", encoding="utf-8") as file:
506+
print(f"⚠️ Attempting to load config file from: {path}")
507+
with open(path, "r", encoding="utf-8") as file:
501508
config = json.load(file)
502509
if debug:
503-
print(f"⚠️ Successfully loaded config file: {config_path}")
510+
print(f"⚠️ Successfully loaded config file: {path}")
504511
return config
505512
except json.JSONDecodeError as e:
506-
print(f"⚠️ Error decoding JSON from the config file {config_path}: {e}")
513+
print(f"⚠️ Error decoding JSON from the config file {path}: {e}")
507514
except Exception as e:
508-
print(f"⚠️ Unexpected error reading config file {config_path}: {e}")
515+
print(f"⚠️ Unexpected error reading config file {path}: {e}")
509516

510517
print("⚠️ Config file not found in any checked locations, using default settings.")
511518
return default_config
@@ -813,7 +820,13 @@ def print_cve_header(cve_id):
813820
print(f"{GREEN}{line}{ENDC}\n")
814821

815822

816-
def main(cve_ids, export_format=None, import_file=None, import_type=None):
823+
def main(cve_ids, export_format=None, import_file=None, import_type=None, config_path=None, debug=False):
824+
global config
825+
if config_path:
826+
config = load_config(config_path=config_path, debug=debug)
827+
else:
828+
config = load_config(debug=debug)
829+
817830
all_results = []
818831
if export_format:
819832
export_format = export_format.lower()
@@ -1014,7 +1027,6 @@ def main(cve_ids, export_format=None, import_file=None, import_type=None):
10141027
elif export_format == "html":
10151028
export_to_html(all_results, cve_ids)
10161029

1017-
10181030
def cli():
10191031
display_banner()
10201032
parser = argparse.ArgumentParser(
@@ -1025,7 +1037,7 @@ def cli():
10251037
type=str,
10261038
nargs="*",
10271039
default=[],
1028-
help="Enter one or more CVE IDs to fetch data. Separate multiple CVE IDs with spaces. Format for each ID: CVE-YYYY-NNNNN. This argument is optional if an import file is provided using the -n option.",
1040+
help="Enter one or more CVE IDs to fetch data. Separate multiple CVE IDs with spaces. Format for each ID: CVE-YYYY-NNNNN. This argument is optional if an import file is provided using the -i option.",
10291041
)
10301042
parser.add_argument(
10311043
"-e",
@@ -1045,6 +1057,12 @@ def cli():
10451057
type=str,
10461058
help="Path to an import file from a vulnerability scanner. If used, CVE IDs can be omitted from the command line arguments.",
10471059
)
1060+
parser.add_argument(
1061+
"-c",
1062+
"--config",
1063+
type=str,
1064+
help="Path to a custom config file.",
1065+
)
10481066
parser.add_argument(
10491067
"-d",
10501068
"--debug",
@@ -1054,11 +1072,7 @@ def cli():
10541072

10551073
args = parser.parse_args()
10561074

1057-
global config
1058-
config = load_config(args.debug)
1059-
1060-
main(args.cve_ids, args.export, args.import_file, args.type)
1061-
1075+
main(args.cve_ids, args.export, args.import_file, args.type, args.config, args.debug)
10621076

10631077
if __name__ == "__main__":
10641078
cli()

0 commit comments

Comments
 (0)