🤬
  • ■ ■ ■ ■ ■ ■
    gpt_vuln.py
     1 +import nmap
     2 +import openai
     3 +import argparse
     4 + 
     5 +openai.api_key = "__API__KEY"
     6 +model_engine = "text-davinci-003"
     7 +nm = nmap.PortScanner()
     8 + 
     9 +parser = argparse.ArgumentParser(description='Python-Nmap and chatGPT intigrated Vulnerability scanner')
     10 +parser.add_argument('target', metavar='target', type=str, help='Target IP or hostname')
     11 +args = parser.parse_args()
     12 + 
     13 +target = args.target
     14 + 
     15 + 
     16 +def p1(ip):
     17 + nm.scan('{}'.format(ip), arguments='-Pn -sV -T4 -O -F')
     18 + json_data = nm.analyse_nmap_xml_scan()
     19 + analize = json_data["scan"]
     20 + # Prompt about what the quary is all about
     21 + prompt = "do a vulnerability analysis of {} and return a vulnerabilty report in json".format(analize)
     22 + # A structure for the request
     23 + completion = openai.Completion.create(
     24 + engine=model_engine,
     25 + prompt=prompt,
     26 + max_tokens=1024,
     27 + n=1,
     28 + stop=None,
     29 + )
     30 + response = completion.choices[0].text
     31 + return response
     32 + 
     33 +def p2(ip):
     34 + nm.scan('{}'.format(ip), arguments='-Pn -T4 -A -v')
     35 + json_data = nm.analyse_nmap_xml_scan()
     36 + analize = json_data["scan"]
     37 + # Prompt about what the quary is all about
     38 + prompt = "do a vulnerability analysis of {} and return a vulnerabilty report in json".format(analize)
     39 + # A structure for the request
     40 + completion = openai.Completion.create(
     41 + engine=model_engine,
     42 + prompt=prompt,
     43 + max_tokens=1024,
     44 + n=1,
     45 + stop=None,
     46 + )
     47 + response = completion.choices[0].text
     48 + return response
     49 + 
     50 + 
     51 +def p3(ip):
     52 + nm.scan('{}'.format(ip), arguments='-Pn -sS -sU -T4 -A -v')
     53 + json_data = nm.analyse_nmap_xml_scan()
     54 + analize = json_data["scan"]
     55 + # Prompt about what the quary is all about
     56 + prompt = "do a vulnerability analysis of {} and return a vulnerabilty report in json".format(analize)
     57 + # A structure for the request
     58 + completion = openai.Completion.create(
     59 + engine=model_engine,
     60 + prompt=prompt,
     61 + max_tokens=1024,
     62 + n=1,
     63 + stop=None,
     64 + )
     65 + response = completion.choices[0].text
     66 + return response
     67 + 
     68 +def p4(ip):
     69 + nm.scan('{}'.format(ip), arguments='-Pn -p- -T4 -A -v')
     70 + json_data = nm.analyse_nmap_xml_scan()
     71 + analize = json_data["scan"]
     72 + # Prompt about what the quary is all about
     73 + prompt = "do a vulnerability analysis of {} and return a vulnerabilty report in json".format(analize)
     74 + # A structure for the request
     75 + completion = openai.Completion.create(
     76 + engine=model_engine,
     77 + prompt=prompt,
     78 + max_tokens=1024,
     79 + n=1,
     80 + stop=None,
     81 + )
     82 + response = completion.choices[0].text
     83 + return response
     84 + 
     85 +def p5(ip):
     86 + nm.scan('{}'.format(ip), arguments='-Pn -sS -sU -T4 -A -PE -PP -PS80,443 -PA3389 -PU40125 -PY -g 53 --script=vuln')
     87 + json_data = nm.analyse_nmap_xml_scan()
     88 + analize = json_data["scan"]
     89 + # Prompt about what the quary is all about
     90 + prompt = "do a vulnerability analysis of {} and return a vulnerabilty report in json".format(analize)
     91 + # A structure for the request
     92 + completion = openai.Completion.create(
     93 + engine=model_engine,
     94 + prompt=prompt,
     95 + max_tokens=1024,
     96 + n=1,
     97 + stop=None,
     98 + )
     99 + response = completion.choices[0].text
     100 + return response
     101 + 
     102 +def main(target):
     103 + profile = int(input("Enter profile of scan: "))
     104 + if profile == 1:
     105 + final = p1(target)
     106 + print(final)
     107 + elif profile == 2:
     108 + final = p2(target)
     109 + print(final)
     110 + elif profile == 3:
     111 + final = p3(target)
     112 + print(final)
     113 + elif profile == 4:
     114 + final = p4(target)
     115 + print(final)
     116 + elif profile == 5:
     117 + final = p5(target)
     118 + print(final)
     119 + else:
     120 + print('Error has in profile input or target input please check......')
     121 + 
     122 + 
     123 +if __name__ == "__main__":
     124 + main(target)
     125 + 
  • ■ ■ ■ ■ ■ ■
    requirements.txt
     1 +aiohttp==3.8.4
     2 +aiosignal==1.3.1
     3 +async-timeout==4.0.2
     4 +attrs==22.2.0
     5 +certifi==2022.12.7
     6 +charset-normalizer==3.0.1
     7 +frozenlist==1.3.3
     8 +idna==3.4
     9 +multidict==6.0.4
     10 +openai==0.27.0
     11 +python-nmap==0.7.1
     12 +requests==2.28.2
     13 +tqdm==4.65.0
     14 +urllib3==1.26.14
     15 +yarl==1.8.2
     16 + 
Please wait...
Page is in error, reload to recover