enotkrutoy commited on
Commit
53ee5fd
1 Parent(s): d4124a3

Upload 13 files

Browse files
Files changed (13) hide show
  1. .env +5 -0
  2. .pre-commit-config.yaml +35 -0
  3. CITATION.cff +12 -0
  4. CODE_OF_CONDUCT.md +32 -0
  5. CONTRIBUTING.md +42 -0
  6. GVA_gui.py +183 -0
  7. LICENSE +21 -0
  8. New Text Document.txt +15 -0
  9. README.md +548 -12
  10. SECURITY.md +7 -0
  11. gpt_vuln.py +192 -0
  12. llama_api.py +155 -0
  13. setup.cfg +24 -0
.env ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ GEOIP_API_KEY = ''
2
+ OPENAI_API_KEY = ''
3
+ BARD_API_KEY = ''
4
+ RUNPOD_ENDPOINT_ID = ''
5
+ RUNPOD_API_KEY = ''
.pre-commit-config.yaml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ default_language_version:
2
+ python: python3
3
+ repos:
4
+ - repo: https://github.com/pre-commit/pre-commit-hooks
5
+ rev: v4.0.1
6
+ hooks:
7
+ - id: check-executables-have-shebangs
8
+ - id: check-merge-conflict
9
+ - id: check-vcs-permalinks
10
+ - id: debug-statements
11
+ - id: end-of-file-fixer
12
+ - id: trailing-whitespace
13
+ - repo: https://github.com/PyCQA/flake8
14
+ rev: 3.9.2
15
+ hooks:
16
+ - id: flake8
17
+ - repo: https://github.com/pre-commit/mirrors-autopep8
18
+ rev: v1.5.7
19
+ hooks:
20
+ - id: autopep8
21
+ args: [--in-place, '--ignore=E265,E501,W504']
22
+ - repo: https://github.com/asottile/reorder_python_imports
23
+ rev: v2.6.0
24
+ hooks:
25
+ - id: reorder-python-imports
26
+ args: [--py3-plus]
27
+ - repo: https://github.com/pre-commit/mirrors-mypy
28
+ rev: v1.0.0
29
+ hooks:
30
+ - id: mypy
31
+ exclude: ^pb/
32
+ additional_dependencies:
33
+ - types-requests
34
+ - types-PyYAML
35
+ - types-python-dateutil
CITATION.cff ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ cff-version: 1.2.0
2
+ message: "POC GPT MODEL for vulnerability assessment"
3
+ authors:
4
+ - family-names: "Chiranjeevi"
5
+ given-names: "G"
6
+ - family-names: "Abhishek Reddy"
7
+ given-names: "R"
8
+ - family-names: "Shyam"
9
+ given-names: "R"
10
+ title: "GPT vuln analyzer"
11
+ date-released: 2023-03-15
12
+ url: "https://github.com/morpheuslord/GPT_Vuln-analyzer"
CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## GPT_Vuln-Analyzer Project Code of Conduct
2
+
3
+ Welcome to the GPT_Vuln-Analyzer project! We value the contributions of all our community members and strive to maintain a respectful and inclusive environment. To ensure a positive experience for everyone, we have established the following code of conduct specifically for our codebase:
4
+
5
+ ### 1. Clear and Concise Code
6
+ - Write code that is easy to understand and maintain.
7
+ - Use meaningful variable and function names to enhance code clarity.
8
+ - Document your code using appropriate comments when necessary.
9
+
10
+ ### 2. Types in Code
11
+ - Define types for variables, parameters, and return values as much as possible.
12
+ - Use type annotations to enhance code readability and maintainability.
13
+ - Aim for strong typing to catch potential errors and improve code quality.
14
+
15
+ ### 3. Constructive Feedback
16
+ - Provide feedback in a constructive and helpful manner.
17
+ - Focus on the code and its functionality rather than personal attributes or characteristics.
18
+ - Offer suggestions for improvement and engage in open discussions.
19
+
20
+ ### 4. Collaboration and Cooperation
21
+ - Foster a collaborative and supportive environment where contributors can learn from each other.
22
+ - Encourage teamwork and cooperation among community members.
23
+ - Support and mentor new contributors to help them grow and develop their skills.
24
+
25
+ ### 5. Handling Disagreements
26
+ - In the event of disagreements, remain calm and respectful.
27
+ - Seek common ground and find solutions through open and constructive communication.
28
+ - If necessary, involve project maintainers or mediators to help resolve conflicts.
29
+
30
+ By contributing to the GPT_Vuln-Analyzer project, you are expected to adhere to this code of conduct. We appreciate your cooperation in making our codebase and community a welcoming and collaborative space for all.
31
+
32
+ Thank you for your understanding and commitment to maintaining a respectful and high-quality codebase!
CONTRIBUTING.md ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## GPT_Vuln-Analyzer Project Contribution Guidelines
2
+
3
+ Hey there! 👋 Thank you for your interest in contributing to the GPT_Vuln-Analyzer project! We greatly appreciate your help in making our vulnerability analysis tool even better. Below are some guidelines to start your journey as a contributor.
4
+
5
+ ### Testing and Reporting Errors
6
+ - One of the most valuable ways you can contribute is by testing the code thoroughly.
7
+ - Identify any bugs, errors, or unexpected behaviour you encounter during your testing.
8
+ - When reporting an issue, please provide clear and detailed steps to reproduce the problem.
9
+ - Include any error messages, relevant log outputs, or screenshots that can help us understand and fix the issue.
10
+
11
+ ### Proposing Improvements
12
+ - We encourage you to suggest improvements that can enhance the functionality, performance, or usability of the GPT_Vuln-Analyzer project.
13
+ - When proposing an improvement, please clearly explain the significance or importance of the suggested change.
14
+ - Focus on the "why" rather than the "what." Could you explain how the improvement will benefit users and make the project better as a whole?
15
+ - Feel free to share your ideas informally, as if you were explaining them to a friend.
16
+
17
+ ### Keeping the Existing Codebase Intact
18
+ - As you contribute, please ensure that your changes do not break any existing functionality.
19
+ - Avoid introducing new issues or regressions into the codebase.
20
+ - Before submitting a pull request, double-check that your changes do not conflict with or duplicate any existing code.
21
+ - If you need guidance or have questions about the existing code, don't hesitate to reach out for clarification.
22
+
23
+ ### Contribution Workflow
24
+ Here's a simple workflow to help you get started:
25
+
26
+ 1. Fork the GPT_Vuln-Analyzer repository to your GitHub account.
27
+ 2. Clone your forked repository to your local development environment.
28
+ 3. Create a new branch for your changes. Be descriptive but concise with your branch name.
29
+ 4. Make your code changes and improvements in the new branch.
30
+ 5. Test your changes thoroughly to ensure they work as expected.
31
+ 6. Commit your changes with clear and meaningful commit messages.
32
+ 7. Push your branch to your forked repository.
33
+ 8. Open a pull request from your branch to the main project repository.
34
+ 9. Provide a detailed description of your changes, including any relevant context.
35
+ 10. Wait for the project maintainers to review your pull request and provide feedback.
36
+ 11. Address any feedback or comments raised during the review process.
37
+ 12. Once your pull request is approved, it will be merged into the main project repository.
38
+
39
+ ### Get in Touch
40
+ If you have any questions, need assistance, or want to discuss your ideas before getting started, please don't hesitate to reach out. You can contact us through the GitHub issue tracker or join our project's communication channels.
41
+
42
+ Thank you for your enthusiasm and for contributing to the GPT_Vuln-Analyzer project! Together, we can make vulnerability analysis more efficient and effective. Happy coding! 🎉
GVA_gui.py ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tkinter as tk
2
+ import json
3
+ from dotenv import load_dotenv
4
+ import customtkinter
5
+ import os
6
+ from components.dns_recon import DNSRecon
7
+ from components.geo import geo_ip_recon
8
+ from components.port_scanner import NetworkScanner
9
+ from components.jwt import JWTAnalyzer
10
+ from components.packet_analysis import PacketAnalysis
11
+ from components.subdomain import SubEnum
12
+
13
+ list_loc = "lists//default.txt"
14
+ load_dotenv()
15
+ gkey = os.getenv('GEOIP_API_KEY')
16
+ akey = os.getenv('OPENAI_API_KEY')
17
+ bkey = os.getenv('BARD_API_KEY')
18
+ lkey = os.getenv('RUNPOD_API_KEY')
19
+ lendpoint = os.getenv('RUNPOD_ENDPOINT_ID')
20
+
21
+ dns_enum = DNSRecon()
22
+ geo_ip = geo_ip_recon()
23
+ packet_analysis = PacketAnalysis()
24
+ port_scanner = NetworkScanner()
25
+ jwt_analyzer = JWTAnalyzer()
26
+ sub_recon = SubEnum()
27
+
28
+ customtkinter.set_appearance_mode("dark")
29
+ customtkinter.set_default_color_theme("dark-blue")
30
+
31
+ root = customtkinter.CTk()
32
+ root.title("GVA - GUI")
33
+ root.geometry("800x400")
34
+
35
+ paned_window = tk.PanedWindow(root, orient="horizontal")
36
+ paned_window.pack(fill="both", expand=True)
37
+ input_frame = customtkinter.CTkFrame(paned_window, width=400)
38
+ output_frame = customtkinter.CTkFrame(paned_window, width=400)
39
+ paned_window.add(input_frame)
40
+ paned_window.add(output_frame)
41
+ navigation_frame = customtkinter.CTkFrame(input_frame, width=100)
42
+ navigation_frame.pack(side="left", fill="y")
43
+
44
+
45
+ def application(attack, entry2, entry3, entry_ai, entry5):
46
+ try:
47
+ target = entry2.get()
48
+ profile = entry3.get() if entry3 else None
49
+ save_loc = entry5.get() if entry5 else None
50
+ ai_choices = entry_ai.get() if entry_ai else None
51
+
52
+ if attack == 'geo':
53
+ geo_output: str = geo_ip_recon.geoip(gkey, target)
54
+ output_save(str(geo_output))
55
+ elif attack == 'nmap':
56
+ p1_out = port_scanner.scanner(
57
+ ip=target,
58
+ profile=int(profile) if profile else None,
59
+ akey=akey,
60
+ bkey=bkey,
61
+ lkey=lkey,
62
+ lendpoint=lendpoint,
63
+ AI=ai_choices
64
+ )
65
+ output_save(p1_out)
66
+ elif attack == 'dns':
67
+ dns_output: str = dns_enum.dns_resolver(
68
+ target=target,
69
+ akey=akey,
70
+ bkey=bkey,
71
+ lkey=lkey,
72
+ lendpoint=lendpoint,
73
+ AI=ai_choices
74
+ )
75
+ output_save(dns_output)
76
+ elif attack == 'sub':
77
+ sub_output: str = sub_recon.sub_enumerator(target, list_loc)
78
+ output_save(sub_output)
79
+ elif attack == 'jwt':
80
+ output: str = jwt_analyzer.analyze(
81
+ token=target,
82
+ openai_api_token=akey,
83
+ bard_api_token=bkey,
84
+ llama_api_token=lkey,
85
+ llama_endpoint=lendpoint,
86
+ AI=ai_choices
87
+ )
88
+ output_save(output)
89
+ elif attack == 'pcap':
90
+ packet_analysis.perform_full_analysis(
91
+ pcap_path=target,
92
+ json_path=save_loc,
93
+ )
94
+ output_save("Done")
95
+ except KeyboardInterrupt:
96
+ print("Keyboard Interrupt detected ...")
97
+
98
+
99
+ def output_save(output: str) -> None:
100
+ if output == "Done":
101
+ output_data = "Status: Successful"
102
+ output_textbox.insert("1.0", output_data)
103
+ else:
104
+ output_textbox.delete("1.0", "end")
105
+ json_data = json.loads(output)
106
+ formatted_json = json.dumps(json_data, indent=2)
107
+ output_textbox.insert("1.0", formatted_json)
108
+
109
+
110
+ def select_frame_by_name(name):
111
+ global frame
112
+ frame.destroy()
113
+ frame = customtkinter.CTkFrame(master=input_frame)
114
+ frame.pack(pady=20, padx=20, fill="both", expand=True)
115
+
116
+ label_text = f"GVA System - {name.capitalize()}"
117
+ label = customtkinter.CTkLabel(master=frame, text=label_text)
118
+ label.pack(pady=12, padx=10)
119
+
120
+ entry2 = customtkinter.CTkEntry(master=frame, placeholder_text="Target/capfile/token")
121
+ entry2.pack(pady=12, padx=10)
122
+
123
+ if name in ["nmap", "dns", "jwt"]:
124
+ ai_choices_val = ["openai", "bard", "llama-api"]
125
+ entry_ai = customtkinter.CTkComboBox(master=frame, values=ai_choices_val, state="readonly")
126
+ entry_ai.set("Select AI Input")
127
+ entry_ai.pack(pady=12, padx=10)
128
+ else:
129
+ entry_ai = None
130
+
131
+ entry3 = None
132
+ entry5 = None
133
+ if name == "nmap":
134
+ entry3 = customtkinter.CTkEntry(master=frame, placeholder_text="Profile")
135
+ entry3.pack(pady=12, padx=10)
136
+ elif name == "sub":
137
+ entry3 = customtkinter.CTkEntry(master=frame, placeholder_text="File Location")
138
+ entry3.pack(pady=12, padx=10)
139
+ elif name == "pcap":
140
+ entry5 = customtkinter.CTkEntry(master=frame, placeholder_text="Save Location")
141
+ entry5.pack(pady=12, padx=10)
142
+
143
+ button = customtkinter.CTkButton(master=frame, text="Run", command=lambda: application(
144
+ attack=name,
145
+ entry2=entry2,
146
+ entry3=entry3,
147
+ entry_ai=entry_ai,
148
+ entry5=entry5
149
+ ))
150
+ button.pack(pady=12, padx=10)
151
+
152
+
153
+ nmap_button = customtkinter.CTkButton(navigation_frame, text="Nmap", command=lambda: select_frame_by_name("nmap"))
154
+ nmap_button.pack(side="top", pady=5, anchor="center")
155
+ dns_button = customtkinter.CTkButton(navigation_frame, text="DNS", command=lambda: select_frame_by_name("dns"))
156
+ dns_button.pack(side="top", pady=5, anchor="center")
157
+ sub_button = customtkinter.CTkButton(navigation_frame, text="Subdomain", command=lambda: select_frame_by_name("sub"))
158
+ sub_button.pack(side="top", pady=5, anchor="center")
159
+ jwt_button = customtkinter.CTkButton(navigation_frame, text="JWT Analysis", command=lambda: select_frame_by_name("jwt"))
160
+ jwt_button.pack(side="top", pady=5, anchor="center")
161
+ pcap_button = customtkinter.CTkButton(navigation_frame, text="Pcap Analysis", command=lambda: select_frame_by_name("pcap"))
162
+ pcap_button.pack(side="top", pady=5, anchor="center")
163
+ geo_button = customtkinter.CTkButton(navigation_frame, text="GeoIP Recon", command=lambda: select_frame_by_name("geo"))
164
+ geo_button.pack(side="top", pady=5, anchor="center")
165
+
166
+ frame = customtkinter.CTkFrame(master=input_frame)
167
+ frame.pack(pady=20, padx=20, fill="both", expand=True)
168
+ label = customtkinter.CTkLabel(master=frame, text="GVA System")
169
+ label.pack(pady=12, padx=10)
170
+ entry2 = customtkinter.CTkEntry(master=frame, placeholder_text="Target")
171
+ entry2.pack(pady=12, padx=10)
172
+ ai_choices = ["openai", "bard", "llama-api"]
173
+ entry_ai = customtkinter.CTkComboBox(master=frame, values=ai_choices, state="readonly")
174
+ entry_ai.set("Select AI Input")
175
+ entry_ai.pack(pady=12, padx=10)
176
+ entry3 = customtkinter.CTkEntry(master=frame, placeholder_text="Profile (Only Nmap)")
177
+ entry3.pack(pady=12, padx=10)
178
+ button = customtkinter.CTkButton(master=frame, text="Run", command=lambda: application("default", entry2, entry3, entry_ai))
179
+ button.pack(pady=12, padx=10)
180
+ output_textbox = customtkinter.CTkTextbox(master=output_frame, height=800, width=900, corner_radius=0)
181
+ output_textbox.pack(pady=12, padx=10)
182
+
183
+ root.mainloop()
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 morpheuslord
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
New Text Document.txt ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ def main():
4
+ st.title("GPT Vulnerability Analyzer")
5
+
6
+ # Пример использования функций из вашего проекта
7
+ st.write("Upload a file to analyze:")
8
+ uploaded_file = st.file_uploader("Choose a file")
9
+ if uploaded_file is not None:
10
+ # Обработайте файл и выполните анализ
11
+ result = analyze_file(uploaded_file)
12
+ st.write(result)
13
+
14
+ if __name__ == "__main__":
15
+ main()
README.md CHANGED
@@ -1,12 +1,548 @@
1
- ---
2
- title: GPT Vuln-analyzer
3
- emoji: 🌖
4
- colorFrom: pink
5
- colorTo: indigo
6
- sdk: streamlit
7
- sdk_version: 1.38.0
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GPT_Vuln-analyzer
2
+
3
+ This is a Proof Of Concept application that demostrates how AI can be used to generate accurate results for vulnerability analysis and also allows further utilization of the already super useful ChatGPT made using openai-api, python-nmap, dnsresolver python modules and also use customtkinter and tkinter for the GUI version of the code. This project also has a CLI and a GUI interface, It is capable of doing network vulnerability analysis, DNS enumeration and also subdomain enumeration.
4
+
5
+ ## Requirements
6
+
7
+ - Python 3.10 or above
8
+ - All the packages mentioned in the requirements.txt file
9
+ - OpenAI API
10
+ - Bard API (MakerSuite Palm)
11
+ - llama.cpp
12
+ - Runpod serverless endpoint
13
+ - HuggingFace token (with llama2 access )
14
+ - IPGeolocation API
15
+ - Wireshark and tshark (both added to path)
16
+
17
+ ## Usage Package
18
+
19
+ ### Import packages
20
+
21
+ ```bash
22
+ cd package && pip3/pip install .
23
+ ```
24
+
25
+ Simple import any of the 3 packages and then add define the variables accordingly
26
+
27
+ ```python
28
+ from GVA.scanner import NetworkScanner
29
+ from GVA.dns_recon import DNSRecon
30
+ from GVA.geo import geo_ip_recon
31
+ from GVA.jwt import JWTAnalyzer
32
+ from GVA.menus import Menus
33
+ from GVA.packet_analysis import PacketAnalysis
34
+ from GVA.ai_models import NMAP_AI_MODEL
35
+ from GVA.ai_models import DNS_AI_MODEL
36
+ from GVA.ai_models import JWT_AI_MODEL
37
+ from GVA.assets import Assets
38
+ from GVA.subdomain import sub_enum
39
+ from GVA import gui
40
+
41
+ # The components defined
42
+ dns_enum = DNSRecon()
43
+ geo_ip = geo_ip_recon()
44
+ p_ai_models = NMAP_AI_MODEL()
45
+ dns_ai_models = DNS_AI_MODEL()
46
+ port_scanner = NetworkScanner()
47
+ jwt_analizer = JWTAnalyzer()
48
+ sub_recon = sub_enum()
49
+ asset_codes = Assets()
50
+ packet_analysis = PacketAnalysis()
51
+
52
+ # KEEP IT BLANK IF YOU HAVE NO CLUE THE MENU WILL ASK TO FILL IT ONCE ACTIVE
53
+ lkey = "LLAMA API KEY"
54
+ lendpoint = "LLAMA ENDPOINT"
55
+ keyset = "AI API KEY"
56
+ output_loc = "OUTPUT LOCATION FOR PCAP"
57
+ threads = 200 # Default INT 200 but can be increased.
58
+ target_ip_hostname_or_token = "TARGET IP, HOSTNAME OR TOKEN"
59
+ profile_num = "PROFILE FOR NMAP SCAN"
60
+ ai_set = "AI OF CHOICE"
61
+ akey_set = "OPENAI API KEY"
62
+ bkey_set = "BARD API KEY"
63
+ ai_set_args = "" # Keep it blank at any cost
64
+ llamakey = "LLAMA RUNPOD API KEY"
65
+ llamaendpoint = "LLAMA RUNPOD ENDPOINT"
66
+
67
+ Menus(
68
+ lamma_key=lkey,
69
+ llama_api_endpoint=lendpoint,
70
+ initial_keyset=keyset,
71
+ threads=threads,
72
+ output_loc=output_loc,
73
+ target=target_ip_hostname,
74
+ profile_num=profile_num,
75
+ ai_set=ai_set,
76
+ openai_akey_set=akey_set,
77
+ bard_key_set=bkey_set,
78
+ ai_set_args=ai_set_args,
79
+ llama_runpod_key=llamakey,
80
+ llama_endpoint=llamaendpoint
81
+ )
82
+
83
+
84
+ gui.application()
85
+ ```
86
+ `update for passcracker in the package and gui is still in progress.`
87
+ ## Usage CLI
88
+
89
+ - First Change the "OPENAI_API_KEY", "GEOIP_API_KEY" and "BARD_API_KEY" part of the code with OpenAI api key and the IPGeolocation API key in the `.env` file
90
+ - For the `llama-api` option or specific the llama runpod serverless endpoint deployment option requires you to enter the `serverless endpoint ID` from runpod and also your `RUNPOD API KEY`
91
+
92
+ ```python
93
+ GEOIP_API_KEY = ''
94
+ OPENAI_API_KEY = ''
95
+ BARD_API_KEY = ''
96
+ RUNPOD_ENDPOINT_ID = ''
97
+ RUNPOD_API_KEY = ''
98
+ ```
99
+
100
+ - second install the packages
101
+
102
+ ```bash
103
+ pip3 install -r requirements.txt
104
+ or
105
+ pip install -r requirements.txt
106
+ ```
107
+
108
+ - Run the code python3 gpt_vuln.py
109
+
110
+ ```bash
111
+ # Regular Help Menu
112
+ python gpt_vuln.py --help
113
+
114
+ # Rich Help Menu
115
+ python gpt_vuln.py --r help
116
+
117
+ # Specify target with the attack
118
+ python gpt_vuln.py --target <IP/hostname/token> --attack dns/nmap/jwt
119
+
120
+ # Specify target and profile for nmap
121
+ python gpt_vuln.py --target <IP/hostname/token> --attack nmap --profile <1-13>
122
+ (Default:1)
123
+
124
+ # Specify target for DNS no profile needed
125
+ python gpt_vuln.py --target <IP/hostname/token> --attack dns
126
+
127
+ # Specify target for Subdomain Enumeration no profile used default list file
128
+ python gpt_vuln.py --target <HOSTNAME> --attack sub
129
+
130
+ # Specify target for Subdomain Enumeration no profile used custom list file
131
+ python gpt_vuln.py --target <HOSTNAME> --attack sub --sub_list <PATH to FILE>
132
+
133
+ # Specify target for geolocation lookup
134
+ python gpt_vuln.py --target <IP> --attack geo
135
+
136
+ # Specify PCAP file for packet analysis
137
+ python gpt_vuln.py --target <PCAP FILE> --attack pcap --output <OUTPUT FILE LOCATION> --thread NUM of threads <200:default>
138
+
139
+ # Specify the AI to be used for nmap
140
+ python gpt_vuln.py --target <IP> --attack nmap --profile <1-5> --ai llama /llama-api /bard / openai <default>
141
+
142
+ # Specify the AI to be used for dns
143
+ python gpt_vuln.py --target <IP> --attack dns --ai llama /llama-api /bard / openai <default>
144
+
145
+ # Specify the AI to be used for JWT analysis
146
+ python gpt_vuln.py --target <token> --attack jwt --ai llama /llama-api /bard / openai <default>
147
+
148
+ # Password Cracker
149
+ python gpt_vuln.py --password_hash <HASH> --wordlist_file <FILE LOCATION> --algorithm <ALGO FROM THE HELP MENU> --parallel --complexity
150
+
151
+ # Interactive step by step cli interface
152
+ python gpt_vuln.py --menu True
153
+ ```
154
+
155
+ #### CLI Interface Option
156
+
157
+ ```bash
158
+ ________________________
159
+ | GVA Usage in progress... |
160
+ ========================
161
+ \
162
+ \
163
+ ^__^
164
+ (oo)\_______
165
+ (__)\ )\/\
166
+ ||----w |
167
+ || ||
168
+ ┏━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
169
+ ┃ Options ┃ Utility ┃
170
+ ┡━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
171
+ │ 1 │ Nmap Enum │
172
+ │ 2 │ DNS Enum │
173
+ │ 3 │ Subdomain Enum │
174
+ │ 4 │ GEO-IP Enum │
175
+ | 5 | JWT Analysis |
176
+ | 6 | PCAP Analysis |
177
+ │ q │ Quit │
178
+ └─────────┴────────────────┘
179
+ Enter your choice:
180
+ ```
181
+
182
+ The CLI interface has a few things to note.
183
+
184
+ - The API keys must be provided manually.
185
+ - The ones defined in the `.env` files work with the args options
186
+ - The process is similar but more organized.
187
+
188
+ ### My views on Bard
189
+
190
+ Its the same as Openai GPT3.5 but faster. It can generate the same answer but in 2 times the speed.
191
+
192
+ ### OS Supported
193
+
194
+ | Preview | Code | Name | Working Status | OpenAI Status | Bard Status | LLama2 Status |
195
+ | -------------------------------------------------------------------------------------------------------------------- | ---- | --------- | -------------- | ------------- | ----------- | ----------------- |
196
+ | ![](https://raw.githubusercontent.com/EgoistDeveloper/operating-system-logos/master/src/48x48/LIN.png "LIN (48x48)") | LIN | GNU/Linux | ✅ | ✅ | ✅ | ❌ [did not test] |
197
+ | ![](https://raw.githubusercontent.com/EgoistDeveloper/operating-system-logos/master/src/48x48/WIN.png "WIN (48x48)") | WIN | Windows | ✅ | ✅ | ✅ | ✅ |
198
+
199
+ ## Understanding the code
200
+
201
+ Profiles:
202
+
203
+ | Parameter | Return data | Description | Nmap Command |
204
+ | :-------- | :---------- | :--------------------------------------------------- | :---------------------------------------------------- |
205
+ | `p1` | `json` | Effective Scan | `-Pn -sV -T4 -O -F` |
206
+ | `p2` | `json` | Simple Scan | `-Pn -T4 -A -v` |
207
+ | `p3` | `json` | Low Power Scan | `-Pn -sS -sU -T4 -A -v` |
208
+ | `p4` | `json` | Partial Intense Scan | `-Pn -p- -T4 -A -v` |
209
+ | `p5` | `json` | Complete Intense Scan | `-Pn -sS -sU -T4 -A -PE -PP -PY -g 53 --script=vuln` |
210
+ | `p6` | `json` | Comprehensive Service Version Detection | `-Pn -sV -p- -A` |
211
+ | `p7` | `json` | Aggressive Scan with OS Detection | `-Pn -sS -sV -O -T4 -A` |
212
+ | `p8` | `json` | Script Scan for Common Vulnerabilities | `-Pn -sC` |
213
+ | `p9` | `json` | Intense Scan, All TCP Ports | `-Pn -p 1-65535 -T4 -A -v` |
214
+ | `p10` | `json` | UDP Scan | `-Pn -sU -T4` |
215
+ | `p11` | `json` | Service and Version Detection for Top Ports | `-Pn -sV --top-ports 100` |
216
+ | `p12` | `json` | Aggressive Scan with NSE Scripts for Vulnerabilities | `-Pn -sS -sV -T4 --script=default,discovery,vuln` |
217
+ | `p13` | `json` | Fast Scan for Common Ports | `-Pn -F` |
218
+
219
+ The profile is the type of scan that will be executed by the nmap subprocess. The Ip or target will be provided via argparse. At first, the custom nmap scan is run which has all the crucial arguments for the scan to continue. Next, the scan data is extracted from the huge pile of data driven by nmap. the "scan" object has a list of sub-data under "tcp" each labelled according to the ports opened. once the data is extracted the data is sent to the openai API Davinci model via a prompt. the prompt specifically asks for a JSON output and the data also to be used in a certain manner.
220
+
221
+ The entire structure of request that has to be sent to the openai API is designed in the completion section of the Program.
222
+
223
+ ```python
224
+ class NetworkScanner():
225
+ profile_arguments = {
226
+ 1: '-Pn -sV -T4 -O -F',
227
+ 2: '-Pn -T4 -A -v',
228
+ 3: '-Pn -sS -sU -T4 -A -v',
229
+ 4: '-Pn -p- -T4 -A -v',
230
+ 5: '-Pn -sS -sU -T4 -A -PE -PP -PY -g 53 --script=vuln',
231
+ 6: '-Pn -sV -p- -A',
232
+ 7: '-Pn -sS -sV -O -T4 -A',
233
+ 8: '-Pn -sC',
234
+ 9: '-Pn -p 1-65535 -T4 -A -v',
235
+ 10: '-Pn -sU -T4',
236
+ 11: '-Pn -sV --top-ports 100',
237
+ 12: '-Pn -sS -sV -T4 --script=default,discovery,vuln',
238
+ 13: '-Pn -F'
239
+ }
240
+
241
+ def scanner(self, ip: Optional[str], profile: int, akey: Optional[str],
242
+ bkey: Optional[str], lkey, lendpoint, AI: str) -> str:
243
+ nm.scan(ip, arguments=self.profile_arguments.get(profile))
244
+ json_data = nm.analyse_nmap_xml_scan()
245
+ analyze = json_data["scan"]
246
+
247
+ try:
248
+ ai_methods = {
249
+ 'openai': lambda: AIModels.GPT_AI(akey, analyze),
250
+ 'bard': lambda: AIModels.BardAI(bkey, analyze),
251
+ 'llama': lambda: AIModels.Llama_AI(analyze, "local", lkey, lendpoint),
252
+ 'llama-api': lambda: AIModels.Llama_AI(analyze, "runpod", lkey, lendpoint)
253
+ }
254
+
255
+ if AI in ai_methods and (akey or bkey):
256
+ response = ai_methods[AI]()
257
+ else:
258
+ raise ValueError("Invalid AI type or missing keys")
259
+
260
+ except KeyboardInterrupt:
261
+ print("Bye")
262
+ quit()
263
+
264
+ return str(response)
265
+
266
+
267
+ ```
268
+
269
+ # Regex
270
+
271
+ We use Regex to extract only the important information from the custom prompt provided this reduces the total amount of unwanted
272
+ data
273
+
274
+ The AI code defines an output format and commands the AI to follow a few pre-determined rules to increase accuracy.
275
+ The regex extraction code does the extraction and further the main function arranges them into tables.
276
+
277
+ ## Using Bard AI
278
+
279
+ For you to use Bard AI you must sign up to the MakerSuit Palm API for developer access and generate your API key from there. For links and how this works you can use this video [MakerSuit](https://www.youtube.com/watch?v=Ce1AOchQMzA&t=128s)
280
+
281
+ Once the API is acquired just add it to the `.env` file and you are good to go.
282
+
283
+ ## Using LLama2 AI
284
+
285
+ Using LLama2 is one of the best offline and free options out there. It is currently under improvement I am working on a prompt that will better incorporate cybersecurity perspective into the AI.
286
+ I have to thank **@thisserand** and his [llama2_local](https://github.com/thisserand/llama2_local) repo and also his YT video [YT_Video](https://youtu.be/WzCS8z9GqHw). They were great resources. To be frank the llama2 code is 95% his, I just yanked the code and added a Flask API functionality to it.
287
+
288
+ The Accuracy of the AI offline and outside the codes test was great and had equal accuracy to openai or bard but while in code it was facing a few issues be because of the prompting and all. I will try and fix it.
289
+ The speed depends on your system and the GPU and CPU configs you have. currently, it is using the `TheBloke/Llama-2-7B-Chat-GGML` model and can be changed via the `portscanner` and `dnsrecon` files.
290
+
291
+ For now, the llama code and scans are handled differently. After a few tests, I found out llama needs to be trained a little to operate like how I intended it to work so it needs some time. Any suggestions on how I can do that can be added to the discussions of this repo [Discussions Link](https://github.com/morpheuslord/GPT_Vuln-analyzer/discussions). For now, the output won't be a divided list of all the data instead will be an explanation of the vulnerability or issues discovered by the AI.
292
+
293
+ The prompt for the model usage looks like this:
294
+
295
+ ```prompt
296
+ [INST] <<SYS>> {user_instruction}<</SYS>> NMAP Data to be analyzed: {user_message} [/INST]
297
+ ```
298
+ The instructions looks like this:
299
+ ```prompt
300
+ Do a NMAP scan analysis on the provided NMAP scan information. The NMAP output must return in a asked format accorging to the provided output format. The data must be accurate in regards towards a pentest report.
301
+ The data must follow the following rules:
302
+ 1) The NMAP scans must be done from a pentester point of view
303
+ 2) The final output must be minimal according to the format given.
304
+ 3) The final output must be kept to a minimal.
305
+ 4) If a value not found in the scan just mention an empty string.
306
+ 5) Analyze everything even the smallest of data.
307
+ 6) Completely analyze the data provided and give a confirm answer using the output format.
308
+ 7) mention all the data you found in the output format provided so that regex can be used on it.
309
+ 8) avoid unnecessary explaination.
310
+ 9) the critical score must be calculated based on the CVE if present or by the nature of the services open
311
+ 10) the os information must contain the OS used my the target.
312
+ 11) the open ports must include all the open ports listed in the data[tcp] and varifying if it by checking its states value. you should not negect even one open port.
313
+ 12) the vulnerable services can be determined via speculation of the service nature or by analyzing the CVE's found.
314
+ The output format:
315
+ critical score:
316
+ - Give info on the criticality
317
+ "os information":
318
+ - List out the OS information
319
+ "open ports and services":
320
+ - List open ports
321
+ - List open ports services
322
+ "vulnerable service":
323
+ - Based on CVEs or nature of the ports opened list the vulnerable services
324
+ "found cve":
325
+ - List the CVE's found and list the main issues.
326
+ ```
327
+
328
+ Using the instruction set and the data provided via the prompt the llama AI generates its output.
329
+
330
+ For the most usage I suggest you create a runpod serverless endpoint deployment of llama you can refer to this tutorial for that [tutorial](https://www.youtube.com/watch?v=Ftb4vbGUr7U). Follow the tutorial for better use.
331
+
332
+ ### Output
333
+
334
+ #### JWT Output:
335
+
336
+ ```
337
+ GVA Report for JWT
338
+ ┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
339
+ ┃ Variables ┃ Results ┃
340
+ ┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
341
+ │ Algorithm Used │ HS256 │
342
+ │ Header │ eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9 │
343
+ │ Payload │ eyJzdWIiOiAiMTIzNDU2Nzg5MCIsICJuYW1lIjogIkpvaG4gRG9lIiwgImlhdCI6IDE1MTYyMzkwMjJ9 │
344
+ │ Signature │ │
345
+ │ PossibleAttacks │ None identified │
346
+ │ VulnerableEndpoints │ Unable to determine without additional information │
347
+ └─────────────────────┴──────────────────────────────────────────────────────────────────────────────────┘
348
+ ```
349
+
350
+ #### Nmap output:
351
+
352
+ ##### OpenAI and Bard:
353
+
354
+ ```table
355
+ ┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
356
+ ┃ Elements ┃ Results ┃
357
+ ┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
358
+ │ critical score │ High │
359
+ │ os information │ Microsoft Windows 11 21H2 │
360
+ │ open ports │ 80, 22, 445, 902, 912 │
361
+ │ open services │ http, ssh, microsoft-ds, vmware-auth, vmware-auth │
362
+ │ vulnerable service │ OpenSSH │
363
+ │ found cve │ CVE-2023-28531 │
364
+ └────────────────────┴─────────────────────────────────────────────────────┘
365
+ ```
366
+
367
+ ##### LLama2
368
+
369
+ ```table
370
+ ╭───────────────────────────────────────────── The GVA LLama2 ──────────────────────────────────────────────╮
371
+ │ │
372
+ │ │
373
+ │ │
374
+ │ Based on the provided NMAP data, I have conducted a thorough analysis of the target system's open ports │
375
+ │ and services, vulnerabilities, and operating system information. Here is my findings: Critical Score: │
376
+ │ The critical score for this target system is 7 out of 10. The system has several open ports that could │
377
+ │ potentially be exploited, including port 80 (HTTP), port 135 (RPC), and port 445 (Microsoft DS). While │
378
+ │ These ports are not necessarily vulnerable, they do indicate that the system is running services that │
379
+ │ could be targeted by attackers. Additionally, the system has an outdated version of Microsoft IIS │
380
+ │ running on port 80, which could be a potential vulnerability. OS Information: The target system is │
381
+ │ running Microsoft Windows 10 1607. Open Ports and Services: The target system has the following open │
382
+ │ ports: │
383
+ │ │
384
+ │ • Port 80: HTTP (Microsoft IIS httpd) │
385
+ │ • Port 135: RPC (Microsoft Windows RPC) │
386
+ │ • Port 445: Microsoft DS │
387
+ │ • Port 8000: Splunkd httpd All of these ports are currently open and have a state of "open". │
388
+ │ Vulnerable Services: Based on the CVEs found in the NMAP data, there are several potential │
389
+ │ vulnerabilities in the target system's services. These include: │
390
+ │ • CVE-2019-1489: An elevation of privilege vulnerability in Microsoft IIS that could be exploited by │
391
+ │ an attacker to gain control of the system. This vulnerability is related to the outdated version of │
392
+ │ Microsoft IIS running on port 80. │
393
+ │ • CVE-2017-0143: A remote code execution vulnerability in Microsoft Windows RPC that could be │
394
+ │ exploited by an attacker to execute arbitrary code on the target system. This vulnerability is │
395
+ │ related to the outdated version of Microsoft Windows RPC running on port 135. │
396
+ │ • CVE-2020-1362: A remote code execution vulnerability in Microsoft DS that could be exploited by an │
397
+ │ attacker to execute arbitrary code on the target system. This vulnerability is related to the │
398
+ │ outdated version of Microsoft DS running on port 445. Found CVEs: The following C │
399
+ │ │
400
+ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
401
+ ```
402
+
403
+ #### DNS Output:
404
+
405
+ target is jainuniversity.ac.in
406
+
407
+ ```table
408
+ ┏━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
409
+ ┃ Elements ┃ Results ┃
410
+ ┡━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
411
+ │ A │ 172.67.147.95", "104.21.41.132 │
412
+ │ AAA │ │
413
+ │ NS │ mia.ns.cloudflare.com.","paul.ns.cloudflare.com. │
414
+ │ MX │ 30 aspmx5.googlemail.com.","30 aspmx4.googlemail.com.","20 alt2.aspmx.l.google.com.","30 │
415
+ │ │ aspmx3.googlemail.com.","30 aspmx2.googlemail.com.","20 alt1.aspmx.l.google.com.","10 aspmx.l.google.com. │
416
+ │ PTR │ │
417
+ │ SOA │ mia.ns.cloudflare.com. dns.cloudflare.com. 2309618668 10000 2400 604800 3600 │
418
+ │ TXT │ atlassian-sending-domain-verification=5b358ce4-5ad3-404d-b4b4-005bf933603b","include:_spf.atlassian.net │
419
+ └──────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
420
+ ```
421
+
422
+ #### GEO Location output:
423
+
424
+ ```table
425
+ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
426
+ ┃ Identifiers ┃ Data ┃
427
+ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
428
+ │ ip │ █████████████ │
429
+ │ continent_code │ AS │
430
+ │ continent_name │ Asia │
431
+ │ country_code2 │ IN │
432
+ │ country_code3 │ IND │
433
+ │ country_name │ India │
434
+ │ country_capital │ New Delhi │
435
+ │ state_prov │ Haryana │
436
+ │ state_code │ IN-HR │
437
+ │ district │ │
438
+ │ city │ Gurugram │
439
+ │ zipcode │ 122003 │
440
+ │ latitude │ 28.44324 │
441
+ │ longitude │ 77.05501 │
442
+ │ is_eu │ False │
443
+ │ calling_code │ +91 │
444
+ │ country_tld │ .in │
445
+ │ languages │ en-IN,hi,bn,te,mr,ta,ur,gu,kn,ml,or,pa,as,bh,sat,ks,ne,sd,kok,doi,mni,… │
446
+ │ country_flag │ https://ipgeolocation.io/static/flags/in_64.png │
447
+ │ geoname_id │ 9148991 │
448
+ │ isp │ Bharti Airtel Limited │
449
+ │ connection_type │ │
450
+ │ organization │ Bharti Airtel Limited │
451
+ │ currency.code │ INR │
452
+ │ currency.name │ Indian Rupee │
453
+ │ currency.symbol │ ₹ │
454
+ │ time_zone.name │ Asia/Kolkata │
455
+ │ time_zone.offset │ 5.5 │
456
+ │ time_zone.current_time │ 2023-07-11 17:08:35.057+0530 │
457
+ │ time_zone.current_time_unix │ 1689075515.057 │
458
+ │ time_zone.is_dst │ False │
459
+ │ time_zone.dst_savings │ 0 │
460
+ └─────────────────────────────┴─────────────────────────────────────────────────────────────���───────────┘
461
+ ```
462
+
463
+ #### PCAP OUTPUT
464
+
465
+ ```
466
+ Collecting Json Data
467
+ Extracting IP details...
468
+ Extracting DNS details...
469
+ Extracting EAPOL details...
470
+ Extracting TCP STREAMS details...
471
+ TCP streams can take some time..
472
+ Total Streams combination: 252
473
+ Number of workers in progress: 250
474
+ Completed
475
+ GVA Report for PCAP
476
+ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
477
+ ┃ Identifiers ┃ Data ┃
478
+ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
479
+ │ PacketAnalysis.Services │ ['49943', '49958', '49934', '49944', '49931', '443', '49957'] │
480
+ │ PacketAnalysis.TCP Streams │ ['1', '4', '5', '2', '0', '3'] │
481
+ │ PacketAnalysis.Sources Address │ ['█████████████', '1.1.1.1', '█████████████', '█████████████', '█████████████', '█████████████'] │
482
+ │ PacketAnalysis.Destination Address │ ['█████████████', '1.1.1.1', '█████████████', '█████████████', '█████████████', '█████████████'] │
483
+ │ PacketAnalysis.DNS Resolved │ [] │
484
+ │ PacketAnalysis.DNS Query │ ['oneclient.sfx.ms'] │
485
+ │ PacketAnalysis.DNS Response │ ['oneclient.sfx.ms.edgekey.net', 'e9659.dspg.akamaiedge.net', 'oneclient.sfx.ms'] │
486
+ │ PacketAnalysis.EAPOL Data │ [] │
487
+ │ PacketAnalysis. Total Streams Data │ 126 │
488
+ └────────────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────┘
489
+ ```
490
+
491
+ #### Password Cracker Output
492
+
493
+ ```
494
+ ________________________
495
+ | GVA Usage in progress... |
496
+ ========================
497
+ \
498
+ \
499
+ ^__^
500
+ (oo)\_______
501
+ (__)\ )\/\
502
+ ||----w |
503
+ || ||
504
+ Cracking... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
505
+ ╭────────────────────────────────────────────── The GVA Password Cracker ──────────────────────────────────────────────╮ │ │ │ │
506
+ │ Password Cracked! Password: legion │
507
+ │ │
508
+ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
509
+ ```
510
+
511
+ # Usage GUI
512
+
513
+ The GUI uses customtkinter for the running of the code. The interface is straightforward the only thing required to remember is:
514
+
515
+ - When using dns attack don't specify the profile
516
+
517
+ ```bash
518
+ python GVA_gui.py
519
+ ```
520
+
521
+ ### Initial window
522
+
523
+ ![init](https://github.com/morpheuslord/GPT_Vuln-analyzer/assets/70637311/6dd8bcba-b5e8-472a-b854-7cb4405e8a2b)
524
+
525
+ ### NMAP window
526
+
527
+ ![nmap](https://github.com/morpheuslord/GPT_Vuln-analyzer/assets/70637311/e53d03fd-dabf-4192-9426-84304d1680c8)
528
+
529
+ ### DNS window
530
+
531
+ ![dns](https://github.com/morpheuslord/GPT_Vuln-analyzer/assets/70637311/ceac4170-3f00-48e2-9c5f-1572fd0ce0a6)
532
+
533
+ ### GEOIP window
534
+
535
+ ![geoip](https://github.com/morpheuslord/GPT_Vuln-analyzer/assets/70637311/ca93b37b-e006-41d6-9c57-56203780e6cc)
536
+
537
+ ### PCAP window
538
+
539
+ ![pcap](https://github.com/morpheuslord/GPT_Vuln-analyzer/assets/70637311/e7b34d1f-4c36-41a0-8dc6-fd0c54b90df1)
540
+
541
+ ### SUBDOMAIN window
542
+
543
+ ![subdomain](https://github.com/morpheuslord/GPT_Vuln-analyzer/assets/70637311/34ec4f81-db63-47d3-8ed2-ed8763f7d933)
544
+
545
+ ### JWT window
546
+
547
+ ![jwt](https://github.com/morpheuslord/GPT_Vuln-analyzer/assets/70637311/aaa8fab5-9692-4b29-bdfa-9701c03928b4)
548
+
SECURITY.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Supports all Python3.10 using OS with also nmap installed
6
+
7
+ If any security issues found they can be patched and added as a merge request
gpt_vuln.py ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import os
3
+ import cowsay
4
+ import hashlib
5
+ from dotenv import load_dotenv
6
+ from rich.console import Console
7
+ from components.dns_recon import DNSRecon
8
+ from components.geo import geo_ip_recon
9
+ from components.port_scanner import NetworkScanner
10
+ from components.jwt import JWTAnalyzer
11
+ from components.packet_analysis import PacketAnalysis
12
+ from components.subdomain import SubEnum
13
+ from components.menus import Menus
14
+ from components.assets import Assets
15
+ from components.passbeaker import PasswordCracker
16
+
17
+
18
+ CURRENT_DIR = os.getcwd()
19
+ DEFAULT_OUTPUT_LOC = os.path.join(CURRENT_DIR, 'outputs', 'output.json')
20
+ DEFAULT_LIST_LOC = 'lists/default.txt'
21
+ DEFAULT_THREADS = 200
22
+
23
+ console = Console()
24
+ load_dotenv()
25
+ dns_enum = DNSRecon()
26
+ geo_ip = geo_ip_recon()
27
+ packet_analysis = PacketAnalysis()
28
+ port_scanner = NetworkScanner()
29
+ jwt_analyzer = JWTAnalyzer()
30
+ sub_recon = SubEnum()
31
+ asset_codes = Assets()
32
+
33
+
34
+ def parse_arguments():
35
+ parser = argparse.ArgumentParser(
36
+ description='Python-Nmap and chatGPT integrated Vulnerability scanner')
37
+ parser.add_argument('--target', type=str, help='Target IP, hostname, JWT token or pcap file location')
38
+ parser.add_argument('--profile', type=int, default=1, help='Enter Profile of scan 1-13 (Default: 1)')
39
+ parser.add_argument('--attack', type=str, help='Attack type: nmap, dns, sub, jwt, pcap, passcracker')
40
+ parser.add_argument('--sub_list', type=str, default=DEFAULT_LIST_LOC, help='Path to the subdomain list file (txt)')
41
+ parser.add_argument('--output', type=str, default=DEFAULT_OUTPUT_LOC, help='Pcap analysis output file')
42
+ parser.add_argument('--rich_menu', type=str, help='Shows a clean help menu using rich')
43
+ parser.add_argument('--menu', type=bool, default=False, help='Terminal Interactive Menu')
44
+ parser.add_argument('--ai', type=str, default='openai', help='AI options: openai, bard, llama, llama-api')
45
+ parser.add_argument('--password_hash', help='Password hash')
46
+ parser.add_argument('--wordlist_file', help='Wordlist File')
47
+ parser.add_argument('--algorithm', choices=hashlib.algorithms_guaranteed, required=True, help='Hash algorithm')
48
+ parser.add_argument('--salt', help='Salt Value')
49
+ parser.add_argument('--parallel', action='store_true', help='Use parallel processing')
50
+ parser.add_argument('--complexity', action='store_true', help='Check for password complexity')
51
+ parser.add_argument('--brute_force', action='store_true', help='Perform a brute force attack')
52
+ parser.add_argument('--min_length', type=int, default=1, help='Minimum password length for brute force attack')
53
+ parser.add_argument('--max_length', type=int, default=6, help='Minimum password length for brute force attack')
54
+ parser.add_argument('--character_set', default='abcdefghijklmnopqrstuvwxyz0123456789',
55
+ help='Character set for brute force attack')
56
+
57
+ return parser.parse_args()
58
+
59
+
60
+ def get_api_keys():
61
+ return {
62
+ 'geoip_api_key': os.getenv('GEOIP_API_KEY'),
63
+ 'openai_api_key': os.getenv('OPENAI_API_KEY'),
64
+ 'bard_api_key': os.getenv('BARD_API_KEY'),
65
+ 'runpod_api_key': os.getenv('RUNPOD_API_KEY'),
66
+ 'runpod_endpoint_id': os.getenv('RUNPOD_ENDPOINT_ID')
67
+ }
68
+
69
+
70
+ def handle_attack(attack_type, target, ai, api_keys, additional_params=None):
71
+ additional_params = additional_params or {}
72
+
73
+ if attack_type == 'geo':
74
+ output = geo_ip.geoip(api_keys['geoip_api_key'], target)
75
+ asset_codes.print_output(attack_type.capitalize(), str(output), ai)
76
+ elif attack_type == 'nmap':
77
+ output = port_scanner.scanner(
78
+ ip=target,
79
+ profile=additional_params.get('profile'),
80
+ akey=api_keys['openai_api_key'],
81
+ bkey=api_keys['bard_api_key'],
82
+ lkey=api_keys['runpod_api_key'],
83
+ lendpoint=api_keys['runpod_endpoint_id'],
84
+ AI=ai
85
+ )
86
+ asset_codes.print_output(attack_type.capitalize(), str(output), ai)
87
+ elif attack_type == 'dns':
88
+ output = dns_enum.dns_resolver(
89
+ target=target,
90
+ akey=api_keys['openai_api_key'],
91
+ bkey=api_keys['bard_api_key'],
92
+ lkey=api_keys['runpod_api_key'],
93
+ lendpoint=api_keys['runpod_endpoint_id'],
94
+ AI=ai
95
+ )
96
+ asset_codes.print_output(attack_type.capitalize(), str(output), ai)
97
+ elif attack_type == 'sub':
98
+ output = sub_recon.sub_enumerator(target, additional_params.get('list_loc'))
99
+ console.print(output, style="bold underline")
100
+ asset_codes.print_output(attack_type.capitalize(), str(output), ai)
101
+ elif attack_type == 'jwt':
102
+ output = jwt_analyzer.analyze(
103
+ token=target,
104
+ openai_api_token=api_keys['openai_api_key'],
105
+ bard_api_token=api_keys['bard_api_key'],
106
+ llama_api_token=api_keys['runpod_api_key'],
107
+ llama_endpoint=api_keys['runpod_endpoint_id'],
108
+ AI=ai
109
+ )
110
+ asset_codes.print_output("JWT", output, ai)
111
+ elif attack_type == 'pcap':
112
+ packet_analysis.perform_full_analysis(
113
+ pcap_path=target,
114
+ json_path=additional_params.get('output_loc'),
115
+ )
116
+ return "Done"
117
+ elif attack_type == 'passcracker':
118
+ hash = additional_params.get('password_hash')
119
+ wordlist = additional_params.get('wordlist_file')
120
+ salt = additional_params.get('salt')
121
+ parallel = additional_params.get('parallel')
122
+ complexity = additional_params.get('complexity')
123
+ min_length = additional_params.get('min_length')
124
+ max_length = additional_params.get('max_length')
125
+ character_set = additional_params.get('charecter_set')
126
+ brute_force = additional_params.get('brute_force')
127
+ algorithm = additional_params.get('algorithm')
128
+ Cracker = PasswordCracker(
129
+ password_hash=hash,
130
+ wordlist_file=wordlist,
131
+ algorithm=algorithm,
132
+ salt=salt,
133
+ parallel=parallel,
134
+ complexity_check=complexity
135
+ )
136
+ if brute_force:
137
+ Cracker.crack_passwords_with_brute_force(min_length, max_length, character_set)
138
+ else:
139
+ Cracker.crack_passwords_with_wordlist()
140
+ Cracker.print_statistics()
141
+
142
+
143
+ def main() -> None:
144
+ args = parse_arguments()
145
+ api_keys = get_api_keys()
146
+
147
+ cowsay.cow('GVA Usage in progress...')
148
+ target = args.target or '127.0.0.1'
149
+
150
+ try:
151
+ if args.rich_menu == "help":
152
+ asset_codes.help_menu()
153
+ elif args.menu:
154
+ Menus(
155
+ lkey=api_keys['runpod_api_key'],
156
+ threads=args.threads,
157
+ output_loc=args.output,
158
+ lendpoint=api_keys['runpod_endpoint_id'],
159
+ keyset="",
160
+ t="",
161
+ profile_num="",
162
+ ai_set="",
163
+ akey_set="",
164
+ bkey_set="",
165
+ ai_set_args="",
166
+ llamakey="",
167
+ llamaendpoint=""
168
+ )
169
+ else:
170
+ additional_params = {
171
+ 'profile': args.profile,
172
+ 'list_loc': args.sub_list,
173
+ 'output_loc': args.output,
174
+ 'password_hash': args.password_hash,
175
+ 'salt': args.salt,
176
+ 'parallel': args.parallel,
177
+ 'complexity': args.complexity,
178
+ 'brute_force': args.brute_force,
179
+ 'min_length': args.min_length,
180
+ 'max_lenght': args.max_length,
181
+ 'character_set': args.character_set,
182
+ 'algorithm': args.algorithm,
183
+ 'wordlist_file': args.wordlist_file
184
+ }
185
+ handle_attack(args.attack, target, args.ai, api_keys, additional_params)
186
+ except KeyboardInterrupt:
187
+ console.print_exception("Bye")
188
+ quit()
189
+
190
+
191
+ if __name__ == "__main__":
192
+ main()
llama_api.py ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import fire
3
+ from enum import Enum
4
+ from threading import Thread
5
+ from transformers import AutoModelForCausalLM, AutoTokenizer
6
+ from auto_gptq import AutoGPTQForCausalLM
7
+ from llama_cpp import Llama
8
+ from huggingface_hub import hf_hub_download
9
+ from transformers import TextIteratorStreamer
10
+ from flask import Flask, request, jsonify
11
+
12
+
13
+ BOS, EOS = "<s>", "</s>"
14
+ E_INST = "[/INST]"
15
+ B_SYS, E_SYS = "<<SYS>>\n", "\n<</SYS>>\n\n"
16
+ DEFAULT_SYSTEM_PROMPT = """\
17
+ You are a helpful, respectful and honest cybersecurity analyst. Being a security analyst you must scrutanize the details provided to ensure it is usable for penitration testing. Please ensure that your responses are socially unbiased and positive in nature.
18
+ If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information."""
19
+
20
+
21
+ def format_to_llama_chat_style(user_instructions, history) -> str:
22
+ B_INST = f"[INST]{user_instructions}"
23
+ prompt = ""
24
+ for i, dialog in enumerate(history[:-1]):
25
+ instruction, response = dialog[0], dialog[1]
26
+ if i == 0:
27
+ instruction = f"{B_SYS}{DEFAULT_SYSTEM_PROMPT}{E_SYS}" + instruction
28
+ else:
29
+ prompt += BOS
30
+ prompt += f"{B_INST} {instruction.strip()} {E_INST} {response.strip()} " + EOS
31
+
32
+ new_instruction = history[-1][0].strip()
33
+ if len(history) > 1:
34
+ prompt += BOS
35
+ else:
36
+ new_instruction = f"{B_SYS}{DEFAULT_SYSTEM_PROMPT}{E_SYS}" + \
37
+ new_instruction
38
+
39
+ prompt += f"{B_INST} {new_instruction} {E_INST}"
40
+ return prompt
41
+
42
+
43
+ class Model_Type(Enum):
44
+ gptq = 1
45
+ ggml = 2
46
+ full_precision = 3
47
+
48
+
49
+ def get_model_type(model_name):
50
+ if "gptq" in model_name.lower():
51
+ return Model_Type.gptq
52
+ elif "ggml" in model_name.lower():
53
+ return Model_Type.ggml
54
+ else:
55
+ return Model_Type.full_precision
56
+
57
+
58
+ def create_folder_if_not_exists(folder_path):
59
+ if not os.path.exists(folder_path):
60
+ os.makedirs(folder_path)
61
+
62
+
63
+ def initialize_gpu_model_and_tokenizer(model_name, model_type):
64
+ if model_type == Model_Type.gptq:
65
+ model = AutoGPTQForCausalLM.from_quantized(
66
+ model_name, device_map="auto", use_safetensors=True,
67
+ use_triton=False)
68
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
69
+ else:
70
+ model = AutoModelForCausalLM.from_pretrained(
71
+ model_name, device_map="auto", token=True)
72
+ tokenizer = AutoTokenizer.from_pretrained(model_name, token=True)
73
+ return model, tokenizer
74
+
75
+
76
+ def init_auto_model_and_tokenizer(model_name, model_type, file_name=None):
77
+ model_type = get_model_type(model_name)
78
+
79
+ if Model_Type.ggml == model_type:
80
+ models_folder = "./models"
81
+ create_folder_if_not_exists(models_folder)
82
+ file_path = hf_hub_download(
83
+ repo_id=model_name, filename=file_name, local_dir=models_folder)
84
+ model = Llama(file_path, n_ctx=4096)
85
+ tokenizer = None
86
+ else:
87
+ model, tokenizer = initialize_gpu_model_and_tokenizer(
88
+ model_name, model_type=model_type)
89
+ return model, tokenizer
90
+
91
+
92
+ app = Flask(__name__)
93
+
94
+
95
+ @app.route('/api/chatbot', methods=['POST'])
96
+ def chatbot_api():
97
+ data = request.json
98
+ user_instruction = data['user_instruction']
99
+ user_message = data['user_message']
100
+ model_name = data['model_name']
101
+ file_name = data.get('file_name')
102
+ is_chat_model = 'chat' in model_name.lower()
103
+ model_type = get_model_type(model_name)
104
+
105
+ if model_type == Model_Type.ggml:
106
+ assert file_name is not None, """
107
+ When model_name is provided for a GGML quantized model, file_name argument must also be provided."""
108
+
109
+ model, tokenizer = init_auto_model_and_tokenizer(
110
+ model_name, model_type, file_name)
111
+
112
+ if is_chat_model:
113
+ instruction = format_to_llama_chat_style(user_instruction, [[user_message, None]])
114
+ else:
115
+ instruction = user_message
116
+
117
+ history = [[user_message, None]]
118
+
119
+ response = generate_response(
120
+ model, tokenizer, instruction, history, model_type)
121
+ return jsonify({'bot_response': response})
122
+
123
+
124
+ def generate_response(model, tokenizer, instruction, history, model_type):
125
+ response = ""
126
+
127
+ kwargs = dict(temperature=0.6, top_p=0.9)
128
+ if model_type == Model_Type.ggml:
129
+ kwargs["max_tokens"] = 512
130
+ for chunk in model(prompt=instruction, stream=True, **kwargs):
131
+ token = chunk["choices"][0]["text"]
132
+ response += token
133
+
134
+ else:
135
+ streamer = TextIteratorStreamer(
136
+ tokenizer, skip_prompt=True, Timeout=5)
137
+ inputs = tokenizer(instruction, return_tensors="pt").to(model.device)
138
+ kwargs["max_new_tokens"] = 512
139
+ kwargs["input_ids"] = inputs["input_ids"]
140
+ kwargs["streamer"] = streamer
141
+ thread = Thread(target=model.generate, kwargs=kwargs)
142
+ thread.start()
143
+
144
+ for token in streamer:
145
+ response += token
146
+
147
+ return response
148
+
149
+
150
+ def run_app(port):
151
+ app.run(port=port)
152
+
153
+
154
+ if __name__ == '__main__':
155
+ fire.Fire(run_app(5000))
setup.cfg ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [flake8]
2
+ format = pylint
3
+ max-line-length = 350
4
+
5
+ [pep8]
6
+ max-line-length = 350
7
+
8
+ [mypy]
9
+ disable_error_code = import
10
+ disallow_any_generics = false
11
+ disallow_untyped_decorators = true
12
+ implicit_reexport = false
13
+ show_error_codes = true
14
+ warn_redundant_casts = true
15
+ warn_unused_configs = true
16
+ warn_unused_ignores = true
17
+ incremental = true
18
+ check_untyped_defs = true
19
+ disallow_incomplete_defs = true
20
+ disallow_untyped_calls = true
21
+ disallow_untyped_defs = true
22
+ strict_equality = true
23
+ no_implicit_optional = true
24
+ warn_unreachable = true