Created
March 10, 2024 13:01
-
-
Save th3happybit/206864e349a800fb80890e73224e87e9 to your computer and use it in GitHub Desktop.
Prefect Automation
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
from prefect import flow, task | |
import subprocess | |
@task | |
def run_nikto_scan(target): | |
# Nikto web server scanner | |
command = ["nikto", "-h", target] | |
result = subprocess.run(command, capture_output=True, text=True) | |
return result.stdout | |
@task | |
def run_wfuzz_scan(target): | |
# Wfuzz web content scanner | |
# Example uses a simple wordlist and script; adjust as needed for your use case | |
command = ["wfuzz", "-c", "-z", "file,/usr/share/wfuzz/wordlist/general/common.txt", "--sc", "200", target] | |
result = subprocess.run(command, capture_output=True, text=True) | |
return result.stdout | |
@task | |
def run_whatweb_scan(target): | |
# WhatWeb identifies websites | |
command = ["whatweb", target] | |
result = subprocess.run(command, capture_output=True, text=True) | |
return result.stdout | |
@task | |
def combine_results(nikto_result, wfuzz_result, whatweb_result, filename="combined_results.txt"): | |
# Combine results into one file | |
with open(filename, "w") as file: | |
file.write("Nikto Scan Results:\n") | |
file.write(nikto_result + "\n") | |
file.write("Wfuzz Scan Results:\n") | |
file.write(wfuzz_result + "\n") | |
file.write("WhatWeb Scan Results:\n") | |
file.write(whatweb_result + "\n") | |
return filename | |
@flow(name="Web Scanning Flow") | |
def web_scanning_flow(target): | |
nikto_result = run_nikto_scan(target) | |
wfuzz_result = run_wfuzz_scan(target) | |
whatweb_result = run_whatweb_scan(target) | |
results_file = combine_results(nikto_result, wfuzz_result, whatweb_result) | |
print(f"Combined results saved to {results_file}") | |
# if __name__ == "__main__": | |
# web_scanning_flow("https://exmaple.com/") | |
# if __name__=="__main__": | |
# web_scanning_flow.serve( | |
# name="web_scanning_flow-deployment", | |
# # every 2 minutes (cron syntax) | |
# cron="*/2 * * * *", | |
# tags=["web-scan"], | |
# description="Web Scanning", | |
# version="web_scanning_flow/deployments", | |
# ) | |
if __name__=="__main__": | |
web_scanning_flow.serve( | |
name="web_scanning_flow-deployment", | |
tags=["web-scan"], | |
description="Web Scanning", | |
version="web_scanning_flow/deployments", | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment