Skip to content

Commit

Permalink
execute as python script for windows compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jgor committed Feb 25, 2019
1 parent 1bb1656 commit 432f5ef
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions dorkbot/scanners/wapiti.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,22 +19,27 @@ def run(args, target):


report = os.path.join(tempfile.gettempdir(), target.hash + ".json") report = os.path.join(tempfile.gettempdir(), target.hash + ".json")


scan_cmd = [os.path.join(wapiti_path, "wapiti")] args = [os.path.join(wapiti_path, "wapiti")]
scan_cmd += ["--url", target.url] args += ["--url", target.url]
scan_cmd += ["--module", modules] args += ["--module", modules]
scan_cmd += ["--scope", "page"] args += ["--scope", "page"]
scan_cmd += ["--flush-session"] args += ["--flush-session"]
scan_cmd += ["--format", "json"] args += ["--format", "json"]
scan_cmd += ["--output", report] args += ["--output", report]


try: for cmd in ["python3", "python"]:
subprocess.check_call(scan_cmd, cwd=wapiti_path) try:
except OSError as e: subprocess.check_call([cmd] + args)
if "No such file or directory" in str(e): except OSError as e:
print("Could not find wapiti. If not in PATH, then download the wapiti project and unpack it in /path/to/dorkbot_directory/tools/ as \"wapiti\" (e.g. ~/.config/dorkbot/tools/wapiti/) such that it contains an executable bin/wapiti, or set wapiti_dir option to correct directory.", file=sys.stderr) if "No such file or directory" in str(e) or "The system cannot find the file specified" in str(e):
sys.exit(1) if cmd is "python3":
except subprocess.CalledProcessError: continue
return False else:
print("Could not run script with \"python3\" or \"python\".", file=sys.stderr)
sys.exit(1)
except subprocess.CalledProcessError:
print("Error executing wapiti.", file=sys.stderr)
return False


with io.open(report, encoding="utf-8") as data_file: with io.open(report, encoding="utf-8") as data_file:
contents = data_file.read() contents = data_file.read()
Expand Down

0 comments on commit 432f5ef

Please sign in to comment.