From 6faae05bab16ad3e03a14a235fe753f393c27683 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 24 May 2019 13:04:30 +0200 Subject: [PATCH] Minor update (for importing) --- identYwaf.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/identYwaf.py b/identYwaf.py index 481a071..fb63eac 100755 --- a/identYwaf.py +++ b/identYwaf.py @@ -66,7 +66,7 @@ sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout) NAME = "identYwaf" -VERSION = "1.0.108" +VERSION = "1.0.109" BANNER = """ ` __ __ ` ____ ___ ___ ____ ______ `| T T` __ __ ____ _____ @@ -87,7 +87,7 @@ PAYLOADS = [] SIGNATURES = {} DATA_JSON = {} -DATA_JSON_FILE = "data.json" +DATA_JSON_FILE = os.path.join(os.path.dirname(__file__), "data.json") MAX_HELP_OPTION_LENGTH = 18 IS_TTY = sys.stdout.isatty() COLORIZE = not IS_WIN and IS_TTY @@ -339,14 +339,10 @@ def _(self, *args): if getattr(options, key, None) is None: setattr(options, key, DEFAULTS[key]) -def init(): +def load_data(): global WAF_RECOGNITION_REGEX - os.chdir(os.path.abspath(os.path.dirname(__file__))) - if os.path.isfile(DATA_JSON_FILE): - print(colorize("[o] loading data...")) - with codecs.open(DATA_JSON_FILE, "rb", encoding="utf8") as f: DATA_JSON.update(json.load(f)) @@ -363,6 +359,9 @@ def init(): else: exit(colorize("[x] file '%s' is missing" % DATA_JSON_FILE)) +def init(): + os.chdir(os.path.abspath(os.path.dirname(__file__))) + print(colorize("[o] initializing handlers...")) # Reference: https://stackoverflow.com/a/28052583 @@ -577,6 +576,8 @@ def main(): init() run() +load_data() + if __name__ == "__main__": try: main()