-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved config functionality Fixed crawling changing settings Fixed automatic imports Added warning for new python versions A minor update with simple improvements and fixes
- Loading branch information
Showing
6 changed files
with
61 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,47 @@ | ||
import os | ||
import sys | ||
import json | ||
|
||
defaults = { | ||
"crawl_depth": 0, | ||
"marker": '*', | ||
"level": 1, | ||
"technique": "RT", | ||
"crawl_domains": "S", | ||
"log_response": False, | ||
"time_based_blind_delay": 4 | ||
} | ||
config = {} | ||
|
||
config_folder = os.path.dirname(os.path.realpath(__file__)) | ||
user_config = {} | ||
|
||
# TODO: fix this | ||
with open(config_folder + "/../config.json", 'r') as stream: | ||
with open(f"{sys.path[0]}/config.json", 'r') as stream: | ||
try: | ||
config = json.load(stream) | ||
except json.JSONDecodeError as e: | ||
print(f'[!][config] {e}') | ||
|
||
base_path = os.path.expanduser(config.get("base_path", "~/.sstimap/")) | ||
log_response = config.get("log_response", False) | ||
time_based_blind_delay = config.get("time_based_blind_delay", 4) | ||
|
||
if not os.path.isdir(base_path): | ||
os.makedirs(base_path) | ||
|
||
if os.path.exists(f"{base_path}/config.json"): | ||
with open(f"{base_path}/config.json", 'r') as stream: | ||
try: | ||
user_config = json.load(stream) | ||
except json.JSONDecodeError as e: | ||
print(f'[!][user config] {e}') | ||
|
||
|
||
def config_update(base, added): | ||
for i in added: | ||
if added[i] is not None or i not in base: | ||
base[i] = added[i] | ||
|
||
|
||
def config_args(args): | ||
res = defaults.copy() | ||
config_update(res, config) | ||
config_update(res, user_config) | ||
config_update(res, args) | ||
return res |