Spaces:
Sleeping
Sleeping
Upload 14 files
Browse files- components/__init__.py +0 -0
- components/ai_models.py +632 -0
- components/assets.py +184 -0
- components/dns_recon.py +51 -0
- components/geo.py +13 -0
- components/gui.py +425 -0
- components/jwt.py +42 -0
- components/menus.py +530 -0
- components/packet_analysis.py +218 -0
- components/passbeaker.py +7 -112
- components/port_scanner.py +0 -0
- components/requirements.txt +20 -0
- components/scanner.py +63 -0
- components/subdomain.py +44 -0
components/__init__.py
ADDED
File without changes
|
components/ai_models.py
ADDED
@@ -0,0 +1,632 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import re
|
3 |
+
from typing import Any
|
4 |
+
from typing import Optional
|
5 |
+
import openai
|
6 |
+
import requests
|
7 |
+
model_engine = "gpt-3.5-turbo-0613"
|
8 |
+
|
9 |
+
|
10 |
+
class DNS_AI_MODEL():
|
11 |
+
@staticmethod
|
12 |
+
def BardAI(key: str, data: Any) -> str:
|
13 |
+
prompt = f"""
|
14 |
+
Do a DNS analysis on the provided DNS scan information
|
15 |
+
The DNS output must return in a JSON format accorging to the provided
|
16 |
+
output format. The data must be accurate in regards towards a pentest report.
|
17 |
+
The data must follow the following rules:
|
18 |
+
1) The DNS scans must be done from a pentester point of view
|
19 |
+
2) The final output must be minimal according to the format given
|
20 |
+
3) The final output must be kept to a minimal
|
21 |
+
|
22 |
+
The output format:
|
23 |
+
{{
|
24 |
+
"A": [""],
|
25 |
+
"AAA": [""],
|
26 |
+
"NS": [""],
|
27 |
+
"MX": [""],
|
28 |
+
"PTR": [""],
|
29 |
+
"SOA": [""],
|
30 |
+
"TXT": [""]
|
31 |
+
}}
|
32 |
+
DNS Data to be analyzed: {data}
|
33 |
+
"""
|
34 |
+
|
35 |
+
url = "https://generativelanguage.googleapis.com/v1beta2/models/text-bison-001:generateText?key=" + key
|
36 |
+
|
37 |
+
headers = {
|
38 |
+
"Content-Type": "application/json"
|
39 |
+
}
|
40 |
+
|
41 |
+
data = {
|
42 |
+
"prompt": {
|
43 |
+
"text": prompt
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
response = requests.post(url, json=data, headers=headers)
|
48 |
+
|
49 |
+
if response.status_code == 200:
|
50 |
+
generated_text = response.json()
|
51 |
+
data = dns_ai_data_regex(str(generated_text))
|
52 |
+
print(data)
|
53 |
+
return dns_ai_data_regex(str(generated_text))
|
54 |
+
else:
|
55 |
+
print("Error: Unable to generate text. Status Code:", response.status_code)
|
56 |
+
return "None"
|
57 |
+
|
58 |
+
@staticmethod
|
59 |
+
def llama_AI(self, data: str, mode: str, lkey, lendpoint):
|
60 |
+
api_url = 'http://localhost:5000/api/chatbot'
|
61 |
+
|
62 |
+
user_instruction = """
|
63 |
+
Do a DNS scan analysis on the provided DNS scan information. The DNS output must return in a asked format accorging to the provided output format. The data must be accurate in regards towards a pentest report.
|
64 |
+
The data must follow the following rules:
|
65 |
+
1) The DNS scans must be done from a pentester point of view
|
66 |
+
2) The final output must be minimal according to the format given
|
67 |
+
3) The final output must be kept to a minimal
|
68 |
+
4) So the analysis and provide your view according to the given format
|
69 |
+
5) Remember to provide views as a security engineer or an security analyst.
|
70 |
+
The output format:
|
71 |
+
"A":
|
72 |
+
- List the A records and security views on them
|
73 |
+
"AAA":
|
74 |
+
- List the AAA records and security views on them
|
75 |
+
"NS":
|
76 |
+
- List the NS records and security views on them
|
77 |
+
"MX":
|
78 |
+
- List the MX records and security views on them
|
79 |
+
"PTR":
|
80 |
+
- List the PTR records and security views on them
|
81 |
+
"SOA":
|
82 |
+
- List the SOA records and security views on them
|
83 |
+
"TXT":
|
84 |
+
- List the TXT records and security views on them
|
85 |
+
"""
|
86 |
+
user_message = f"""
|
87 |
+
DNS Data to be analyzed: {data}
|
88 |
+
"""
|
89 |
+
|
90 |
+
model_name = "TheBloke/Llama-2-7B-Chat-GGML"
|
91 |
+
file_name = "llama-2-7b-chat.ggmlv3.q4_K_M.bin"
|
92 |
+
if mode == "local":
|
93 |
+
bot_response = self.chat_with_api(api_url, user_message, user_instruction, model_name, file_name)
|
94 |
+
elif mode == "runpod":
|
95 |
+
prompt = f"[INST] <<SYS>> {user_instruction}<</SYS>> NMAP Data to be analyzed: {user_message} [/INST]"
|
96 |
+
bot_response = self.llama_runpod_api(prompt, lkey, lendpoint)
|
97 |
+
bot_response = self.chat_with_api(api_url, user_message, user_instruction, model_name, file_name)
|
98 |
+
print("test")
|
99 |
+
if bot_response:
|
100 |
+
return bot_response
|
101 |
+
|
102 |
+
@staticmethod
|
103 |
+
def gpt_ai(analyze: str, key: Optional[str]) -> str:
|
104 |
+
openai.api_key = key
|
105 |
+
prompt = f"""
|
106 |
+
Do a DNS analysis on the provided DNS scan information
|
107 |
+
The DNS output must return in a JSON format accorging to the provided
|
108 |
+
output format. The data must be accurate in regards towards a pentest report.
|
109 |
+
The data must follow the following rules:
|
110 |
+
1) The DNS scans must be done from a pentester point of view
|
111 |
+
2) The final output must be minimal according to the format given
|
112 |
+
3) The final output must be kept to a minimal
|
113 |
+
|
114 |
+
The output format:
|
115 |
+
{{
|
116 |
+
"A": [""],
|
117 |
+
"AAA": [""],
|
118 |
+
"NS": [""],
|
119 |
+
"MX": [""],
|
120 |
+
"PTR": [""],
|
121 |
+
"SOA": [""],
|
122 |
+
"TXT": [""]
|
123 |
+
}}
|
124 |
+
|
125 |
+
DNS Data to be analyzed: {analyze}
|
126 |
+
"""
|
127 |
+
try:
|
128 |
+
# A structure for the request
|
129 |
+
messages = [{"content": prompt, "role": "user"}]
|
130 |
+
# A structure for the request
|
131 |
+
response = openai.ChatCompletion.create(
|
132 |
+
model=model_engine,
|
133 |
+
messages=messages,
|
134 |
+
max_tokens=1024,
|
135 |
+
n=1,
|
136 |
+
stop=None,
|
137 |
+
)
|
138 |
+
response = response['choices'][0]['message']['content']
|
139 |
+
return dns_ai_data_regex(str(response))
|
140 |
+
except KeyboardInterrupt:
|
141 |
+
print("Bye")
|
142 |
+
quit()
|
143 |
+
|
144 |
+
|
145 |
+
class NMAP_AI_MODEL():
|
146 |
+
@staticmethod
|
147 |
+
def BardAI(key: str, data: Any) -> str:
|
148 |
+
prompt = f"""
|
149 |
+
Do a NMAP scan analysis on the provided NMAP scan information
|
150 |
+
The NMAP output must return in a JSON format accorging to the provided
|
151 |
+
output format. The data must be accurate in regards towards a pentest report.
|
152 |
+
The data must follow the following rules:
|
153 |
+
1) The NMAP scans must be done from a pentester point of view
|
154 |
+
2) The final output must be minimal according to the format given.
|
155 |
+
3) The final output must be kept to a minimal.
|
156 |
+
4) If a value not found in the scan just mention an empty string.
|
157 |
+
5) Analyze everything even the smallest of data.
|
158 |
+
6) Completely analyze the data provided and give a confirm answer using the output format.
|
159 |
+
|
160 |
+
The output format:
|
161 |
+
{{
|
162 |
+
"critical score": [""],
|
163 |
+
"os information": [""],
|
164 |
+
"open ports": [""],
|
165 |
+
"open services": [""],
|
166 |
+
"vulnerable service": [""],
|
167 |
+
"found cve": [""]
|
168 |
+
}}
|
169 |
+
|
170 |
+
NMAP Data to be analyzed: {data}
|
171 |
+
"""
|
172 |
+
|
173 |
+
url = "https://generativelanguage.googleapis.com/v1beta2/models/text-bison-001:generateText?key=" + key
|
174 |
+
|
175 |
+
headers = {
|
176 |
+
"Content-Type": "application/json"
|
177 |
+
}
|
178 |
+
|
179 |
+
data = {
|
180 |
+
"prompt": {
|
181 |
+
"text": prompt
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
response = requests.post(url, json=data, headers=headers)
|
186 |
+
|
187 |
+
if response.status_code == 200:
|
188 |
+
generated_text = response.json()
|
189 |
+
return nmap_ai_data_regex(str(generated_text))
|
190 |
+
else:
|
191 |
+
print("Error: Unable to generate text. Status Code:", response.status_code)
|
192 |
+
return "None"
|
193 |
+
|
194 |
+
@staticmethod
|
195 |
+
def Llama_AI(data: str, mode: str, lkey: str, lendpoint: str) -> Any:
|
196 |
+
api_url = 'http://localhost:5000/api/chatbot'
|
197 |
+
|
198 |
+
user_instruction = """
|
199 |
+
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.
|
200 |
+
The data must follow the following rules:
|
201 |
+
1) The NMAP scans must be done from a pentester point of view
|
202 |
+
2) The final output must be minimal according to the format given.
|
203 |
+
3) The final output must be kept to a minimal.
|
204 |
+
4) If a value not found in the scan just mention an empty string.
|
205 |
+
5) Analyze everything even the smallest of data.
|
206 |
+
6) Completely analyze the data provided and give a confirm answer using the output format.
|
207 |
+
7) mention all the data you found in the output format provided so that regex can be used on it.
|
208 |
+
8) avoid unnecessary explaination.
|
209 |
+
9) the critical score must be calculated based on the CVE if present or by the nature of the services open
|
210 |
+
10) the os information must contain the OS used my the target.
|
211 |
+
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.
|
212 |
+
12) the vulnerable services can be determined via speculation of the service nature or by analyzing the CVE's found.
|
213 |
+
The output format:
|
214 |
+
critical score:
|
215 |
+
- Give info on the criticality
|
216 |
+
"os information":
|
217 |
+
- List out the OS information
|
218 |
+
"open ports and services":
|
219 |
+
- List open ports
|
220 |
+
- List open ports services
|
221 |
+
"vulnerable service":
|
222 |
+
- Based on CVEs or nature of the ports opened list the vulnerable services
|
223 |
+
"found cve":
|
224 |
+
- List the CVE's found and list the main issues.
|
225 |
+
"""
|
226 |
+
user_message = f"""
|
227 |
+
NMAP Data to be analyzed: {data}
|
228 |
+
"""
|
229 |
+
model_name = "TheBloke/Llama-2-7B-Chat-GGML"
|
230 |
+
file_name = "llama-2-7b-chat.ggmlv3.q4_K_M.bin"
|
231 |
+
if mode == "local":
|
232 |
+
bot_response = chat_with_api(api_url, user_message, user_instruction, model_name, file_name)
|
233 |
+
elif mode == "runpod":
|
234 |
+
prompt = f"[INST] <<SYS>> {user_instruction}<</SYS>> NMAP Data to be analyzed: {user_message} [/INST]"
|
235 |
+
bot_response = llama_runpod_api(prompt, lkey, lendpoint)
|
236 |
+
if bot_response:
|
237 |
+
return bot_response
|
238 |
+
|
239 |
+
@staticmethod
|
240 |
+
def GPT_AI(key: str, data: Any) -> str:
|
241 |
+
openai.api_key = key
|
242 |
+
try:
|
243 |
+
prompt = f"""
|
244 |
+
Do a NMAP scan analysis on the provided NMAP scan information
|
245 |
+
The NMAP output must return in a JSON format accorging to the provided
|
246 |
+
output format. The data must be accurate in regards towards a pentest report.
|
247 |
+
The data must follow the following rules:
|
248 |
+
1) The NMAP scans must be done from a pentester point of view
|
249 |
+
2) The final output must be minimal according to the format given.
|
250 |
+
3) The final output must be kept to a minimal.
|
251 |
+
4) If a value not found in the scan just mention an empty string.
|
252 |
+
5) Analyze everything even the smallest of data.
|
253 |
+
6) Completely analyze the data provided and give a confirm answer using the output format.
|
254 |
+
|
255 |
+
The output format:
|
256 |
+
{{
|
257 |
+
"critical score": [""],
|
258 |
+
"os information": [""],
|
259 |
+
"open ports": [""],
|
260 |
+
"open services": [""],
|
261 |
+
"vulnerable service": [""],
|
262 |
+
"found cve": [""]
|
263 |
+
}}
|
264 |
+
|
265 |
+
NMAP Data to be analyzed: {data}
|
266 |
+
"""
|
267 |
+
# A structure for the request
|
268 |
+
messages = [{"content": prompt, "role": "assistant"}]
|
269 |
+
# A structure for the request
|
270 |
+
response = openai.ChatCompletion.create(
|
271 |
+
model=model_engine,
|
272 |
+
messages=messages,
|
273 |
+
max_tokens=2500,
|
274 |
+
n=1,
|
275 |
+
stop=None,
|
276 |
+
)
|
277 |
+
response = response['choices'][0]['message']['content']
|
278 |
+
rsp = str(response)
|
279 |
+
return str(nmap_ai_data_regex(rsp))
|
280 |
+
except KeyboardInterrupt:
|
281 |
+
print("Bye")
|
282 |
+
quit()
|
283 |
+
|
284 |
+
|
285 |
+
class JWT_AI_MODEL():
|
286 |
+
@staticmethod
|
287 |
+
def BardAI(key: str, jwt_data: Any) -> str:
|
288 |
+
prompt = f"""
|
289 |
+
Perform a comprehensive analysis on the provided JWT token. The analysis output must be in a JSON format according to the provided output structure. Ensure accuracy for inclusion in a penetration testing report.
|
290 |
+
Follow these guidelines:
|
291 |
+
1) Analyze the JWT token from a pentester's perspective
|
292 |
+
2) Keep the final output minimal while adhering to the given format
|
293 |
+
3) Highlight JWT-specific details and enumerate possible attacks and vulnerabilities
|
294 |
+
5) For the output "Algorithm Used" value use the Algorithm value from the JWT data.
|
295 |
+
6) For the output "Header" value use the Header value from the JWT data.
|
296 |
+
7) For the "Payload" Use the decoded payloads as a reference and then analyze any attack endpoints.
|
297 |
+
8) For "Signature" mention the signatures discovered.
|
298 |
+
9) List a few endpoints you feel are vulnerable for "VulnerableEndpoints"
|
299 |
+
|
300 |
+
The output format:
|
301 |
+
{{
|
302 |
+
"Algorithm Used": "",
|
303 |
+
"Header": "",
|
304 |
+
"Payload": "",
|
305 |
+
"Signature": "",
|
306 |
+
"PossibleAttacks": "",
|
307 |
+
"VulnerableEndpoints": ""
|
308 |
+
}}
|
309 |
+
|
310 |
+
JWT Token Data to be analyzed: {jwt_data}
|
311 |
+
"""
|
312 |
+
|
313 |
+
url = "https://generativelanguage.googleapis.com/v1beta2/models/text-bison-001:generateText?key=" + key
|
314 |
+
|
315 |
+
headers = {
|
316 |
+
"Content-Type": "application/json"
|
317 |
+
}
|
318 |
+
|
319 |
+
data = {
|
320 |
+
"prompt": {
|
321 |
+
"text": prompt
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
response = requests.post(url, json=data, headers=headers)
|
326 |
+
|
327 |
+
if response.status_code == 200:
|
328 |
+
generated_text = response.json()
|
329 |
+
jwt_analysis_data = jwt_ai_data_regex(str(generated_text))
|
330 |
+
print(jwt_analysis_data)
|
331 |
+
return jwt_analysis_data
|
332 |
+
else:
|
333 |
+
print("Error: Unable to generate text. Status Code:", response.status_code)
|
334 |
+
return "None"
|
335 |
+
|
336 |
+
@staticmethod
|
337 |
+
def llama_AI(self, jwt_data: str, mode: str, lkey, lendpoint):
|
338 |
+
api_url = 'http://localhost:5000/api/chatbot'
|
339 |
+
|
340 |
+
user_instruction = """
|
341 |
+
Perform a comprehensive analysis on the provided JWT token. The JWT analysis output must be in a asked format according to the provided output structure. Ensure accuracy for inclusion in a penetration testing report.
|
342 |
+
Follow these guidelines:
|
343 |
+
1) Analyze the JWT token from a pentester's perspective
|
344 |
+
2) Keep the final output minimal while adhering to the given format
|
345 |
+
3) Highlight JWT-specific details and enumerate possible attacks
|
346 |
+
|
347 |
+
The output format:
|
348 |
+
"Header":
|
349 |
+
- List the JWT header details and security views on them
|
350 |
+
"Payload":
|
351 |
+
- List the JWT payload details and security views on them
|
352 |
+
"Signature":
|
353 |
+
- Provide insights on the JWT signature
|
354 |
+
"PossibleAttacks":
|
355 |
+
- List possible JWT exploits and attacks
|
356 |
+
"""
|
357 |
+
user_message = f"""
|
358 |
+
JWT Token Data to be analyzed: {jwt_data}
|
359 |
+
"""
|
360 |
+
|
361 |
+
model_name = "TheBloke/Llama-2-7B-Chat-GGML"
|
362 |
+
file_name = "llama-2-7b-chat.ggmlv3.q4_K_M.bin"
|
363 |
+
if mode == "local":
|
364 |
+
bot_response = self.chat_with_api(api_url, user_message, user_instruction, model_name, file_name)
|
365 |
+
elif mode == "runpod":
|
366 |
+
prompt = f"[INST] <<SYS>> {user_instruction}<</SYS>> JWT Token Data to be analyzed: {user_message} [/INST]"
|
367 |
+
bot_response = self.llama_runpod_api(prompt, lkey, lendpoint)
|
368 |
+
bot_response = self.chat_with_api(api_url, user_message, user_instruction, model_name, file_name)
|
369 |
+
print("test")
|
370 |
+
if bot_response:
|
371 |
+
return bot_response
|
372 |
+
|
373 |
+
@staticmethod
|
374 |
+
def gpt_ai(analyze: str, api_key: Optional[str]) -> str:
|
375 |
+
openai.api_key = api_key
|
376 |
+
prompt = f"""
|
377 |
+
Perform a comprehensive analysis on the provided JWT token. The analysis output must be in a JSON format according to the provided output structure. Ensure accuracy for inclusion in a penetration testing report.
|
378 |
+
Follow these guidelines:
|
379 |
+
1) Analyze the JWT token from a pentester's perspective
|
380 |
+
2) Keep the final output minimal while adhering to the given format
|
381 |
+
3) Highlight JWT-specific details and enumerate possible attacks and vulnerabilities
|
382 |
+
5) For the output "Algorithm Used" value use the Algorithm value from the JWT data.
|
383 |
+
6) For the output "Header" value use the Header value from the JWT data.
|
384 |
+
7) For the "Payload" Use the decoded payloads as a reference and then analyze any attack endpoints.
|
385 |
+
8) For "Signature" mention the signatures discovered.
|
386 |
+
9) List a few endpoints you feel are vulnerable for "VulnerableEndpoints"
|
387 |
+
|
388 |
+
The output format:
|
389 |
+
{{
|
390 |
+
"Algorithm Used": "",
|
391 |
+
"Header": "",
|
392 |
+
"Payload": "",
|
393 |
+
"Signature": "",
|
394 |
+
"PossibleAttacks": "",
|
395 |
+
"VulnerableEndpoints": ""
|
396 |
+
}}
|
397 |
+
|
398 |
+
JWT Token Data to be analyzed: {analyze}
|
399 |
+
"""
|
400 |
+
try:
|
401 |
+
messages = [{"content": prompt, "role": "user"}]
|
402 |
+
response = openai.ChatCompletion.create(
|
403 |
+
model=model_engine,
|
404 |
+
messages=messages,
|
405 |
+
max_tokens=1024,
|
406 |
+
n=1,
|
407 |
+
stop=None,
|
408 |
+
)
|
409 |
+
response = response['choices'][0]['message']['content']
|
410 |
+
rsp = str(response)
|
411 |
+
return rsp
|
412 |
+
except KeyboardInterrupt:
|
413 |
+
print("Bye")
|
414 |
+
quit()
|
415 |
+
|
416 |
+
|
417 |
+
def chat_with_api(api_url: str, user_message: str, user_instruction: str, model_name: str, file_name: str = None) -> Any:
|
418 |
+
# Prepare the request data in JSON format
|
419 |
+
data = {
|
420 |
+
'user_message': user_message,
|
421 |
+
'model_name': model_name,
|
422 |
+
'file_name': file_name,
|
423 |
+
'user_instruction': user_instruction
|
424 |
+
}
|
425 |
+
|
426 |
+
# Send the POST request to the API
|
427 |
+
response = requests.post(api_url, json=data)
|
428 |
+
|
429 |
+
# Check if the request was successful (status code 200)
|
430 |
+
if response.status_code == 200:
|
431 |
+
return response.json()['bot_response']
|
432 |
+
else:
|
433 |
+
# If there was an error, print the error message
|
434 |
+
print(f"Error: {response.status_code} - {response.text}")
|
435 |
+
return None
|
436 |
+
|
437 |
+
|
438 |
+
def llama_runpod_api(prompt: str, lkey: str, lendpoint: str) -> Any:
|
439 |
+
url = f"https://api.runpod.ai/v2/{lendpoint}/runsync"
|
440 |
+
payload = json.dumps({
|
441 |
+
"input": {
|
442 |
+
"prompt": prompt,
|
443 |
+
"max_new_tokens": 4500,
|
444 |
+
"temperature": 0.9,
|
445 |
+
"top_k": 50,
|
446 |
+
"top_p": 0.7,
|
447 |
+
"repetition_penalty": 1.2,
|
448 |
+
"batch_size": 8,
|
449 |
+
"stop": [
|
450 |
+
"</s>"
|
451 |
+
]
|
452 |
+
}
|
453 |
+
})
|
454 |
+
headers = {
|
455 |
+
'Content-Type': 'application/json',
|
456 |
+
'Authorization': f'Bearer {lkey}',
|
457 |
+
}
|
458 |
+
response = requests.request("POST", url, headers=headers, data=payload)
|
459 |
+
response_t = json.loads(response.text)
|
460 |
+
return response_t["output"]
|
461 |
+
|
462 |
+
|
463 |
+
def dns_ai_data_regex(json_string: str) -> Any:
|
464 |
+
# Define the regular expression patterns for individual values
|
465 |
+
A_pattern = r'"A": \["(.*?)"\]'
|
466 |
+
AAA_pattern = r'"AAA: \["(.*?)"\]'
|
467 |
+
NS_pattern = r'"NS": \["(.*?)"\]'
|
468 |
+
MX_pattern = r'"MX": \["(.*?)"\]'
|
469 |
+
PTR_pattern = r'"PTR": \["(.*?)"\]'
|
470 |
+
SOA_pattern = r'"SOA": \["(.*?)"\]'
|
471 |
+
TXT_pattern = r'"TXT": \["(.*?)"\]'
|
472 |
+
|
473 |
+
# Initialize variables for extracted data
|
474 |
+
A = None
|
475 |
+
AAA = None
|
476 |
+
NS = None
|
477 |
+
MX = None
|
478 |
+
PTR = None
|
479 |
+
SOA = None
|
480 |
+
TXT = None
|
481 |
+
|
482 |
+
# Extract individual values using patterns
|
483 |
+
match = re.search(A_pattern, json_string)
|
484 |
+
if match:
|
485 |
+
A = match.group(1)
|
486 |
+
match = re.search(AAA_pattern, json_string)
|
487 |
+
if match:
|
488 |
+
AAA = match.group(1)
|
489 |
+
match = re.search(NS_pattern, json_string)
|
490 |
+
if match:
|
491 |
+
NS = match.group(1)
|
492 |
+
match = re.search(MX_pattern, json_string)
|
493 |
+
if match:
|
494 |
+
MX = match.group(1)
|
495 |
+
match = re.search(PTR_pattern, json_string)
|
496 |
+
if match:
|
497 |
+
PTR = match.group(1)
|
498 |
+
match = re.search(SOA_pattern, json_string)
|
499 |
+
if match:
|
500 |
+
SOA = match.group(1)
|
501 |
+
match = re.search(TXT_pattern, json_string)
|
502 |
+
if match:
|
503 |
+
TXT = match.group(1)
|
504 |
+
|
505 |
+
# Create a dictionary to store the extracted data
|
506 |
+
data = {
|
507 |
+
"A": A,
|
508 |
+
"AAA": AAA,
|
509 |
+
"NS": NS,
|
510 |
+
"MX": MX,
|
511 |
+
"PTR": PTR,
|
512 |
+
"SOA": SOA,
|
513 |
+
"TXT": TXT
|
514 |
+
}
|
515 |
+
|
516 |
+
# Convert the dictionary to JSON format
|
517 |
+
json_output = json.dumps(data)
|
518 |
+
|
519 |
+
return json_output
|
520 |
+
|
521 |
+
|
522 |
+
def nmap_ai_data_regex(json_string: str) -> Any:
|
523 |
+
# Define the regular expression patterns for individual values
|
524 |
+
critical_score_pattern = r'"critical score": \["(.*?)"\]'
|
525 |
+
os_information_pattern = r'"os information": \["(.*?)"\]'
|
526 |
+
open_ports_pattern = r'"open ports": \["(.*?)"\]'
|
527 |
+
open_services_pattern = r'"open services": \["(.*?)"\]'
|
528 |
+
vulnerable_service_pattern = r'"vulnerable service": \["(.*?)"\]'
|
529 |
+
found_cve_pattern = r'"found cve": \["(.*?)"\]'
|
530 |
+
# Initialize variables for extracted data
|
531 |
+
critical_score = None
|
532 |
+
os_information = None
|
533 |
+
open_ports = None
|
534 |
+
open_services = None
|
535 |
+
vulnerable_service = None
|
536 |
+
found_cve = None
|
537 |
+
|
538 |
+
# Extract individual values using patterns
|
539 |
+
match = re.search(critical_score_pattern, json_string)
|
540 |
+
if match:
|
541 |
+
critical_score = match.group(1)
|
542 |
+
|
543 |
+
match = re.search(os_information_pattern, json_string)
|
544 |
+
if match:
|
545 |
+
os_information = match.group(1)
|
546 |
+
match = re.search(open_ports_pattern, json_string)
|
547 |
+
if match:
|
548 |
+
open_ports = match.group(1)
|
549 |
+
match = re.search(open_services_pattern, json_string)
|
550 |
+
if match:
|
551 |
+
open_services = match.group(1)
|
552 |
+
|
553 |
+
match = re.search(vulnerable_service_pattern, json_string)
|
554 |
+
if match:
|
555 |
+
vulnerable_service = match.group(1)
|
556 |
+
|
557 |
+
match = re.search(found_cve_pattern, json_string)
|
558 |
+
if match:
|
559 |
+
found_cve = match.group(1)
|
560 |
+
|
561 |
+
# Create a dictionary to store the extracted data
|
562 |
+
data = {
|
563 |
+
"critical score": critical_score,
|
564 |
+
"os information": os_information,
|
565 |
+
"open ports": open_ports,
|
566 |
+
"open services": open_services,
|
567 |
+
"vulnerable service": vulnerable_service,
|
568 |
+
"found cve": found_cve
|
569 |
+
}
|
570 |
+
|
571 |
+
# Convert the dictionary to JSON format
|
572 |
+
json_output = json.dumps(data)
|
573 |
+
|
574 |
+
return json_output
|
575 |
+
|
576 |
+
|
577 |
+
def jwt_ai_data_regex(json_string: str) -> Any:
|
578 |
+
# Define the regular expression patterns for individual values
|
579 |
+
header_pattern = r'"Header": \{\s*"alg": "(.*?)",\s*"typ": "(.*?)"\s*\}'
|
580 |
+
payload_pattern = r'"Payload": \{\s*"iss": "(.*?)",\s*"sub": "(.*?)",\s*"aud": "(.*?)",\s*"exp": "(.*?)",\s*"nbf": "(.*?)",\s*"iat": "(.*?)"\s*\}'
|
581 |
+
signature_pattern = r'"Signature": "(.*?)"'
|
582 |
+
possible_attacks_pattern = r'"PossibleAttacks": "(.*?)"'
|
583 |
+
vulnerable_endpoints_pattern = r'"VulnerableEndpoints": "(.*?)"'
|
584 |
+
|
585 |
+
# Initialize variables for extracted data
|
586 |
+
header = {}
|
587 |
+
payload = {}
|
588 |
+
signature = ""
|
589 |
+
possible_attacks = ""
|
590 |
+
vulnerable_endpoints = ""
|
591 |
+
|
592 |
+
# Extract individual values using patterns
|
593 |
+
match_header = re.search(header_pattern, json_string)
|
594 |
+
if match_header:
|
595 |
+
header = {"alg": match_header.group(1), "typ": match_header.group(2)}
|
596 |
+
|
597 |
+
match_payload = re.search(payload_pattern, json_string)
|
598 |
+
if match_payload:
|
599 |
+
payload = {
|
600 |
+
"iss": match_payload.group(1),
|
601 |
+
"sub": match_payload.group(2),
|
602 |
+
"aud": match_payload.group(3),
|
603 |
+
"exp": match_payload.group(4),
|
604 |
+
"nbf": match_payload.group(5),
|
605 |
+
"iat": match_payload.group(6)
|
606 |
+
}
|
607 |
+
|
608 |
+
match_signature = re.search(signature_pattern, json_string)
|
609 |
+
if match_signature:
|
610 |
+
signature = match_signature.group(1)
|
611 |
+
|
612 |
+
match_attacks = re.search(possible_attacks_pattern, json_string)
|
613 |
+
if match_attacks:
|
614 |
+
possible_attacks = match_attacks.group(1)
|
615 |
+
|
616 |
+
match_endpoints = re.search(vulnerable_endpoints_pattern, json_string)
|
617 |
+
if match_endpoints:
|
618 |
+
vulnerable_endpoints = match_endpoints.group(1)
|
619 |
+
|
620 |
+
# Create a dictionary to store the extracted data
|
621 |
+
data = {
|
622 |
+
"Header": header,
|
623 |
+
"Payload": payload,
|
624 |
+
"Signature": signature,
|
625 |
+
"PossibleAttacks": possible_attacks,
|
626 |
+
"VulnerableEndpoints": vulnerable_endpoints
|
627 |
+
}
|
628 |
+
|
629 |
+
# Convert the dictionary to JSON format
|
630 |
+
json_output = json.dumps(data)
|
631 |
+
|
632 |
+
return json_output
|
components/assets.py
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
import platform
|
4 |
+
import subprocess
|
5 |
+
from typing import Any
|
6 |
+
from rich import print
|
7 |
+
from rich.console import Console
|
8 |
+
from rich.table import Table
|
9 |
+
from rich.panel import Panel
|
10 |
+
from rich.console import Group
|
11 |
+
from rich.align import Align
|
12 |
+
from rich import box
|
13 |
+
from rich.markdown import Markdown
|
14 |
+
|
15 |
+
console = Console()
|
16 |
+
|
17 |
+
|
18 |
+
class Assets():
|
19 |
+
def clearscr() -> None:
|
20 |
+
try:
|
21 |
+
osp = platform.system()
|
22 |
+
match osp:
|
23 |
+
case 'Darwin':
|
24 |
+
os.system("clear")
|
25 |
+
case 'Linux':
|
26 |
+
os.system("clear")
|
27 |
+
case 'Windows':
|
28 |
+
os.system("cls")
|
29 |
+
except Exception:
|
30 |
+
pass
|
31 |
+
|
32 |
+
def start_api_app():
|
33 |
+
CREATE_NEW_CONSOLE = 0x00000010
|
34 |
+
osp = platform.system()
|
35 |
+
match osp:
|
36 |
+
case 'Darwin':
|
37 |
+
subprocess.Popen(["python3", "llama_api.py"], creationflags=CREATE_NEW_CONSOLE)
|
38 |
+
case 'Linux':
|
39 |
+
subprocess.Popen(["python3", "llama_api.py"])
|
40 |
+
case 'Windows':
|
41 |
+
subprocess.Popen(["python", "llama_api.py"], creationflags=CREATE_NEW_CONSOLE)
|
42 |
+
|
43 |
+
def flatten_json(self, data: Any, separator: Any = '.') -> Any:
|
44 |
+
flattened_data = {}
|
45 |
+
for key, value in data.items():
|
46 |
+
if isinstance(value, dict):
|
47 |
+
nested_data = self.flatten_json(value, separator)
|
48 |
+
for nested_key, nested_value in nested_data.items():
|
49 |
+
flattened_data[key + separator + nested_key] = nested_value
|
50 |
+
else:
|
51 |
+
flattened_data[key] = value
|
52 |
+
return flattened_data
|
53 |
+
|
54 |
+
def help_menu() -> None:
|
55 |
+
table = Table(title="Help Menu for GVA")
|
56 |
+
table.add_column("Options", style="cyan")
|
57 |
+
table.add_column("Input Type", style="green")
|
58 |
+
table.add_column("Argument Input", style="green")
|
59 |
+
table.add_column("Discription", style="green")
|
60 |
+
table.add_column("Other internal options", style="green")
|
61 |
+
table.add_row("Attack", "--attack", "TXT/STRING",
|
62 |
+
"The Attack the user whats to run", "sub / dns / nmap / geo")
|
63 |
+
table.add_row("Target", "--target", "IP/HOSTNAME",
|
64 |
+
"The target of the user", "None")
|
65 |
+
table.add_row("Domain List", "--list", "Path to text file",
|
66 |
+
"subdomain dictionary list", "Path")
|
67 |
+
table.add_row("Profile", "--profile", "INT (1-5)",
|
68 |
+
"The type of Nmap Scan the user intends", "None")
|
69 |
+
table.add_row("AI", "--ai", "STRING",
|
70 |
+
"Choose your AI of choice", "bard / openai (default)")
|
71 |
+
table.add_row("menu", "--menu", "BOOL",
|
72 |
+
"Interactive UI menu", "True / False (Default)")
|
73 |
+
table.add_row("Rich Help", "--r", "STRING",
|
74 |
+
"Pritty Help menu", "help")
|
75 |
+
console.print(table)
|
76 |
+
|
77 |
+
def print_output(self, attack_type: str, jdata: str, ai: str) -> Any:
|
78 |
+
match attack_type:
|
79 |
+
case "Nmap":
|
80 |
+
match ai:
|
81 |
+
case 'openai':
|
82 |
+
data = json.loads(jdata)
|
83 |
+
table = Table(title=f"GVA Report for {attack_type}", show_header=True, header_style="bold magenta")
|
84 |
+
table.add_column("Variables", style="cyan")
|
85 |
+
table.add_column("Results", style="green")
|
86 |
+
|
87 |
+
for key, value in data.items():
|
88 |
+
table.add_row(key, value)
|
89 |
+
print(table)
|
90 |
+
case 'bard':
|
91 |
+
data = json.loads(jdata)
|
92 |
+
table = Table(title=f"GVA Report for {attack_type}", show_header=True, header_style="bold magenta")
|
93 |
+
table.add_column("Variables", style="cyan")
|
94 |
+
table.add_column("Results", style="green")
|
95 |
+
|
96 |
+
for key, value in data.items():
|
97 |
+
table.add_row(key, value)
|
98 |
+
print(table)
|
99 |
+
case 'llama':
|
100 |
+
ai_out = Markdown(jdata)
|
101 |
+
message_panel = Panel(
|
102 |
+
Align.center(
|
103 |
+
Group("\n", Align.center(ai_out)),
|
104 |
+
vertical="middle",
|
105 |
+
),
|
106 |
+
box=box.ROUNDED,
|
107 |
+
padding=(1, 2),
|
108 |
+
title="[b red]The GVA LLama2",
|
109 |
+
border_style="blue",
|
110 |
+
)
|
111 |
+
print(message_panel)
|
112 |
+
case 'llama-api':
|
113 |
+
ai_out = Markdown(jdata)
|
114 |
+
message_panel = Panel(
|
115 |
+
Align.center(
|
116 |
+
Group("\n", Align.center(ai_out)),
|
117 |
+
vertical="middle",
|
118 |
+
),
|
119 |
+
box=box.ROUNDED,
|
120 |
+
padding=(1, 2),
|
121 |
+
title="[b red]The GVA LLama2",
|
122 |
+
border_style="blue",
|
123 |
+
)
|
124 |
+
print(message_panel)
|
125 |
+
case "DNS":
|
126 |
+
match ai:
|
127 |
+
case 'openai':
|
128 |
+
data = json.loads(jdata)
|
129 |
+
table = Table(title=f"GVA Report for {attack_type}", show_header=True, header_style="bold magenta")
|
130 |
+
table.add_column("Variables", style="cyan")
|
131 |
+
table.add_column("Results", style="green")
|
132 |
+
|
133 |
+
for key, value in data.items():
|
134 |
+
table.add_row(key, value)
|
135 |
+
print(table)
|
136 |
+
case 'bard':
|
137 |
+
data = json.loads(jdata)
|
138 |
+
table = Table(title=f"GVA Report for {attack_type}", show_header=True, header_style="bold magenta")
|
139 |
+
table.add_column("Variables", style="cyan")
|
140 |
+
table.add_column("Results", style="green")
|
141 |
+
|
142 |
+
for key, value in data.items():
|
143 |
+
table.add_row(key, value)
|
144 |
+
print(table)
|
145 |
+
case 'llama':
|
146 |
+
ai_out = Markdown(jdata)
|
147 |
+
message_panel = Panel(
|
148 |
+
Align.center(
|
149 |
+
Group("\n", Align.center(ai_out)),
|
150 |
+
vertical="middle",
|
151 |
+
),
|
152 |
+
box=box.ROUNDED,
|
153 |
+
padding=(1, 2),
|
154 |
+
title="[b red]The GVA LLama2",
|
155 |
+
border_style="blue",
|
156 |
+
)
|
157 |
+
print(message_panel)
|
158 |
+
case 'llama-api':
|
159 |
+
ai_out = Markdown(jdata)
|
160 |
+
message_panel = Panel(
|
161 |
+
Align.center(
|
162 |
+
Group("\n", Align.center(ai_out)),
|
163 |
+
vertical="middle",
|
164 |
+
),
|
165 |
+
box=box.ROUNDED,
|
166 |
+
padding=(1, 2),
|
167 |
+
title="[b red]The GVA LLama2",
|
168 |
+
border_style="blue",
|
169 |
+
)
|
170 |
+
print(message_panel)
|
171 |
+
case "GeoIP":
|
172 |
+
data = json.loads(jdata)
|
173 |
+
table = Table(title="GVA Report for GeoIP", show_header=True, header_style="bold magenta")
|
174 |
+
table.add_column("Identifiers", style="cyan")
|
175 |
+
table.add_column("Data", style="green")
|
176 |
+
|
177 |
+
flattened_data: dict = self.flatten_json(data, separator='.')
|
178 |
+
|
179 |
+
for key, value in flattened_data.items():
|
180 |
+
value_str = str(value)
|
181 |
+
table.add_row(key, value_str)
|
182 |
+
|
183 |
+
console = Console()
|
184 |
+
console.print(table)
|
components/dns_recon.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Any, Optional
|
2 |
+
import requests
|
3 |
+
import dns.resolver as dns_resolver_module
|
4 |
+
from rich.progress import track
|
5 |
+
|
6 |
+
|
7 |
+
class DNSRecon:
|
8 |
+
def dns_resolver(self, AIModels, target: str, akey: Optional[str], bkey: Optional[str], lkey, lendpoint, AI: str) -> Any:
|
9 |
+
if target is None:
|
10 |
+
raise ValueError("InvalidTarget: Target Not Provided")
|
11 |
+
|
12 |
+
analyze = ''
|
13 |
+
record_types = ['A', 'AAAA', 'NS', 'CNAME', 'MX', 'PTR', 'SOA', 'TXT']
|
14 |
+
for record_type in track(record_types):
|
15 |
+
try:
|
16 |
+
answer = dns_resolver_module.resolve(target, record_type)
|
17 |
+
for server in answer:
|
18 |
+
st = server.to_text()
|
19 |
+
analyze += f"\n{record_type} : {st}"
|
20 |
+
except dns_resolver_module.NoAnswer:
|
21 |
+
print('No record Found')
|
22 |
+
except dns_resolver_module.NXDOMAIN:
|
23 |
+
print('NXDOMAIN record NOT Found')
|
24 |
+
except dns_resolver_module.LifetimeTimeout:
|
25 |
+
print("Timed out, check your internet")
|
26 |
+
except requests.exceptions.InvalidHeader:
|
27 |
+
pass
|
28 |
+
except KeyboardInterrupt:
|
29 |
+
print("Bye")
|
30 |
+
quit()
|
31 |
+
|
32 |
+
response = ""
|
33 |
+
match AI:
|
34 |
+
case 'openai':
|
35 |
+
if akey is None:
|
36 |
+
raise ValueError("KeyNotFound: Key Not Provided")
|
37 |
+
akey = akey.replace('\n', '')
|
38 |
+
response = AIModels.gpt_ai(akey, analyze)
|
39 |
+
case 'bard':
|
40 |
+
if bkey is None:
|
41 |
+
raise ValueError("KeyNotFound: Key Not Provided")
|
42 |
+
bkey = bkey.replace('\n', '')
|
43 |
+
response = AIModels.BardAI(bkey, analyze)
|
44 |
+
case 'llama':
|
45 |
+
response = AIModels.llama_AI(analyze, "local", lkey, lendpoint)
|
46 |
+
case 'llama-api':
|
47 |
+
response = AIModels.llama_AI(analyze, "runpod", lkey, lendpoint)
|
48 |
+
except KeyboardInterrupt:
|
49 |
+
print("Bye")
|
50 |
+
quit()
|
51 |
+
return str(response)
|
components/geo.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Any, Optional
|
2 |
+
import requests
|
3 |
+
|
4 |
+
class GeoIPRecon:
|
5 |
+
def geoip(key: Optional[str], target: str) -> Any:
|
6 |
+
if key is None:
|
7 |
+
raise ValueError("KeyNotFound: Key Not Provided")
|
8 |
+
if target is None:
|
9 |
+
raise ValueError("InvalidTarget: Target Not Provided")
|
10 |
+
|
11 |
+
url = f"https://api.ipgeolocation.io/ipgeo?apiKey={key}&ip={target}"
|
12 |
+
response = requests.get(url)
|
13 |
+
return response.text
|
components/gui.py
ADDED
@@ -0,0 +1,425 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import re
|
3 |
+
from typing import Any
|
4 |
+
from typing import Optional
|
5 |
+
|
6 |
+
import customtkinter
|
7 |
+
import dns.resolver
|
8 |
+
import nmap
|
9 |
+
import openai
|
10 |
+
import requests
|
11 |
+
from rich.progress import track
|
12 |
+
|
13 |
+
customtkinter.set_appearance_mode("dark")
|
14 |
+
customtkinter.set_default_color_theme("dark-blue")
|
15 |
+
|
16 |
+
root = customtkinter.CTk()
|
17 |
+
root.title("GVA - GUI")
|
18 |
+
root.geometry("600x400")
|
19 |
+
|
20 |
+
nm = nmap.PortScanner()
|
21 |
+
model_engine = "text-davinci-003"
|
22 |
+
|
23 |
+
|
24 |
+
def application() -> None:
|
25 |
+
try:
|
26 |
+
apikey = entry1.get()
|
27 |
+
openai.api_key = apikey
|
28 |
+
target = entry2.get()
|
29 |
+
attack = entry5.get()
|
30 |
+
outputf = str(entry4.get())
|
31 |
+
match attack:
|
32 |
+
case 'geo':
|
33 |
+
val = geoip(apikey, target)
|
34 |
+
print(val)
|
35 |
+
output_save(val, outputf)
|
36 |
+
case "nmap":
|
37 |
+
p = int(entry3.get())
|
38 |
+
match p:
|
39 |
+
case 1:
|
40 |
+
val = scanner(target, 1, apikey)
|
41 |
+
print(val)
|
42 |
+
output_save(val, outputf)
|
43 |
+
case 2:
|
44 |
+
val = scanner(target, 2, apikey)
|
45 |
+
print(val)
|
46 |
+
output_save(val, outputf)
|
47 |
+
case 3:
|
48 |
+
val = scanner(target, 3, apikey)
|
49 |
+
print(val)
|
50 |
+
output_save(val, outputf)
|
51 |
+
case 4:
|
52 |
+
val = scanner(target, 4, apikey)
|
53 |
+
print(val)
|
54 |
+
output_save(val, outputf)
|
55 |
+
case 5:
|
56 |
+
val = scanner(target, 5, apikey)
|
57 |
+
print(val)
|
58 |
+
output_save(val, outputf)
|
59 |
+
case "dns":
|
60 |
+
val = dns_recon(target, apikey)
|
61 |
+
output_save(val, outputf)
|
62 |
+
case "subd":
|
63 |
+
val = sub(target)
|
64 |
+
output_save(val, outputf)
|
65 |
+
except KeyboardInterrupt:
|
66 |
+
print("Keyboard Interrupt detected ...")
|
67 |
+
|
68 |
+
|
69 |
+
def dns_extract_data(json_string: str) -> Any:
|
70 |
+
# Define the regular expression patterns for individual values
|
71 |
+
A_pattern = r'"A": \["(.*?)"\]'
|
72 |
+
AAA_pattern = r'"AAA: \["(.*?)"\]'
|
73 |
+
NS_pattern = r'"NS": \["(.*?)"\]'
|
74 |
+
MX_pattern = r'"MX": \["(.*?)"\]'
|
75 |
+
PTR_pattern = r'"PTR": \["(.*?)"\]'
|
76 |
+
SOA_pattern = r'"SOA": \["(.*?)"\]'
|
77 |
+
TXT_pattern = r'"TXT": \["(.*?)"\]'
|
78 |
+
|
79 |
+
# Initialize variables for extracted data
|
80 |
+
A = None
|
81 |
+
AAA = None
|
82 |
+
NS = None
|
83 |
+
MX = None
|
84 |
+
PTR = None
|
85 |
+
SOA = None
|
86 |
+
TXT = None
|
87 |
+
|
88 |
+
# Extract individual values using patterns
|
89 |
+
match = re.search(A_pattern, json_string)
|
90 |
+
if match:
|
91 |
+
A = match.group(1)
|
92 |
+
|
93 |
+
match = re.search(AAA_pattern, json_string)
|
94 |
+
if match:
|
95 |
+
AAA = match.group(1)
|
96 |
+
|
97 |
+
match = re.search(NS_pattern, json_string)
|
98 |
+
if match:
|
99 |
+
NS = match.group(1)
|
100 |
+
|
101 |
+
match = re.search(MX_pattern, json_string)
|
102 |
+
if match:
|
103 |
+
MX = match.group(1)
|
104 |
+
|
105 |
+
match = re.search(PTR_pattern, json_string)
|
106 |
+
if match:
|
107 |
+
PTR = match.group(1)
|
108 |
+
|
109 |
+
match = re.search(SOA_pattern, json_string)
|
110 |
+
if match:
|
111 |
+
SOA = match.group(1)
|
112 |
+
|
113 |
+
match = re.search(TXT_pattern, json_string)
|
114 |
+
if match:
|
115 |
+
TXT = match.group(1)
|
116 |
+
|
117 |
+
# Create a dictionary to store the extracted data
|
118 |
+
data = {
|
119 |
+
"A": A,
|
120 |
+
"AAA": AAA,
|
121 |
+
"NS": NS,
|
122 |
+
"MX": MX,
|
123 |
+
"PTR": PTR,
|
124 |
+
"SOA": SOA,
|
125 |
+
"TXT": TXT
|
126 |
+
}
|
127 |
+
|
128 |
+
# Convert the dictionary to JSON format
|
129 |
+
json_output = json.dumps(data)
|
130 |
+
|
131 |
+
return json_output
|
132 |
+
|
133 |
+
|
134 |
+
def port_extract_data(json_string: str) -> Any:
|
135 |
+
# Define the regular expression patterns for individual values
|
136 |
+
critical_score_pattern = r'"critical score": \["(.*?)"\]'
|
137 |
+
os_information_pattern = r'"os information": \["(.*?)"\]'
|
138 |
+
open_ports_pattern = r'"open ports": \["(.*?)"\]'
|
139 |
+
open_services_pattern = r'"open services": \["(.*?)"\]'
|
140 |
+
vulnerable_service_pattern = r'"vulnerable service": \["(.*?)"\]'
|
141 |
+
found_cve_pattern = r'"found cve": \["(.*?)"\]'
|
142 |
+
|
143 |
+
# Initialize variables for extracted data
|
144 |
+
critical_score = None
|
145 |
+
os_information = None
|
146 |
+
open_ports = None
|
147 |
+
open_services = None
|
148 |
+
vulnerable_service = None
|
149 |
+
found_cve = None
|
150 |
+
|
151 |
+
# Extract individual values using patterns
|
152 |
+
match = re.search(critical_score_pattern, json_string)
|
153 |
+
if match:
|
154 |
+
critical_score = match.group(1)
|
155 |
+
|
156 |
+
match = re.search(os_information_pattern, json_string)
|
157 |
+
if match:
|
158 |
+
os_information = match.group(1)
|
159 |
+
|
160 |
+
match = re.search(open_ports_pattern, json_string)
|
161 |
+
if match:
|
162 |
+
open_ports = match.group(1)
|
163 |
+
|
164 |
+
match = re.search(open_services_pattern, json_string)
|
165 |
+
if match:
|
166 |
+
open_services = match.group(1)
|
167 |
+
|
168 |
+
match = re.search(vulnerable_service_pattern, json_string)
|
169 |
+
if match:
|
170 |
+
vulnerable_service = match.group(1)
|
171 |
+
|
172 |
+
match = re.search(found_cve_pattern, json_string)
|
173 |
+
if match:
|
174 |
+
found_cve = match.group(1)
|
175 |
+
|
176 |
+
# Create a dictionary to store the extracted data
|
177 |
+
data = {
|
178 |
+
"critical score": critical_score,
|
179 |
+
"os information": os_information,
|
180 |
+
"open ports": open_ports,
|
181 |
+
"open services": open_services,
|
182 |
+
"vulnerable service": vulnerable_service,
|
183 |
+
"found cve": found_cve
|
184 |
+
}
|
185 |
+
|
186 |
+
# Convert the dictionary to JSON format
|
187 |
+
json_output = json.dumps(data)
|
188 |
+
|
189 |
+
return json_output
|
190 |
+
|
191 |
+
|
192 |
+
def DnsAI(analyze: str, key: Optional[str]) -> str:
|
193 |
+
openai.api_key = key
|
194 |
+
prompt = f"""
|
195 |
+
Do a DNS analysis on the provided DNS scan information
|
196 |
+
The DNS output must return in a JSON format accorging to the provided
|
197 |
+
output format. The data must be accurate in regards towards a pentest report.
|
198 |
+
The data must follow the following rules:
|
199 |
+
1) The DNS scans must be done from a pentester point of view
|
200 |
+
2) The final output must be minimal according to the format given
|
201 |
+
3) The final output must be kept to a minimal
|
202 |
+
|
203 |
+
The output format:
|
204 |
+
{{
|
205 |
+
"A": [""],
|
206 |
+
"AAA": [""],
|
207 |
+
"NS": [""],
|
208 |
+
"MX": [""],
|
209 |
+
"PTR": [""],
|
210 |
+
"SOA": [""],
|
211 |
+
"TXT": [""]
|
212 |
+
}}
|
213 |
+
|
214 |
+
DNS Data to be analyzed: {analyze}
|
215 |
+
"""
|
216 |
+
try:
|
217 |
+
# A structure for the request
|
218 |
+
completion = openai.Completion.create(
|
219 |
+
engine=model_engine,
|
220 |
+
prompt=prompt,
|
221 |
+
max_tokens=1024,
|
222 |
+
n=1,
|
223 |
+
stop=None,
|
224 |
+
)
|
225 |
+
response = completion.choices[0].text
|
226 |
+
return dns_extract_data(str(response))
|
227 |
+
except KeyboardInterrupt:
|
228 |
+
print("Bye")
|
229 |
+
quit()
|
230 |
+
|
231 |
+
|
232 |
+
def PortAI(key: str, data: Any) -> str:
|
233 |
+
openai.api_key = key
|
234 |
+
try:
|
235 |
+
prompt = f"""
|
236 |
+
Do a NMAP scan analysis on the provided NMAP scan information
|
237 |
+
The NMAP output must return in a JSON format accorging to the provided
|
238 |
+
output format. The data must be accurate in regards towards a pentest report.
|
239 |
+
The data must follow the following rules:
|
240 |
+
1) The NMAP scans must be done from a pentester point of view
|
241 |
+
2) The final output must be minimal according to the format given.
|
242 |
+
3) The final output must be kept to a minimal.
|
243 |
+
4) If a value not found in the scan just mention an empty string.
|
244 |
+
5) Analyze everything even the smallest of data.
|
245 |
+
|
246 |
+
The output format:
|
247 |
+
{{
|
248 |
+
"critical score": [""],
|
249 |
+
"os information": [""],
|
250 |
+
"open ports": [""],
|
251 |
+
"open services": [""],
|
252 |
+
"vulnerable service": [""],
|
253 |
+
"found cve": [""]
|
254 |
+
}}
|
255 |
+
|
256 |
+
NMAP Data to be analyzed: {data}
|
257 |
+
"""
|
258 |
+
# A structure for the request
|
259 |
+
completion = openai.Completion.create(
|
260 |
+
engine=model_engine,
|
261 |
+
prompt=prompt,
|
262 |
+
max_tokens=1024,
|
263 |
+
n=1,
|
264 |
+
stop=None,
|
265 |
+
)
|
266 |
+
response = completion.choices[0].text
|
267 |
+
return port_extract_data(str(response))
|
268 |
+
except KeyboardInterrupt:
|
269 |
+
print("Bye")
|
270 |
+
quit()
|
271 |
+
|
272 |
+
|
273 |
+
def geoip(key: Optional[str], target: str) -> Any:
|
274 |
+
if key is None:
|
275 |
+
raise ValueError("KeyNotFound: Key Not Provided")
|
276 |
+
assert key is not None # This will help the type checker
|
277 |
+
if target is None:
|
278 |
+
raise ValueError("InvalidTarget: Target Not Provided")
|
279 |
+
url = f"https://api.ipgeolocation.io/ipgeo?apiKey={key}&ip={target}"
|
280 |
+
response = requests.get(url)
|
281 |
+
content = response.text
|
282 |
+
return content
|
283 |
+
|
284 |
+
|
285 |
+
def output_save(output: Any, outf: Any) -> Any:
|
286 |
+
top = customtkinter.CTkToplevel(root)
|
287 |
+
top.title("GVA Output")
|
288 |
+
top.grid_rowconfigure(0, weight=1)
|
289 |
+
top.grid_columnconfigure(0, weight=1)
|
290 |
+
top.textbox = customtkinter.CTkTextbox(
|
291 |
+
master=top, height=500, width=400, corner_radius=0)
|
292 |
+
top.textbox.grid(row=0, column=0, sticky="nsew")
|
293 |
+
|
294 |
+
try:
|
295 |
+
file = open(outf, 'x')
|
296 |
+
except FileExistsError:
|
297 |
+
file = open(outf, "r+")
|
298 |
+
file.write(str(output))
|
299 |
+
file.close
|
300 |
+
top.textbox.insert("0.0", text=output)
|
301 |
+
|
302 |
+
|
303 |
+
def sub(target: str) -> Any:
|
304 |
+
s_array = ['www', 'mail', 'ftp', 'localhost', 'webmail', 'smtp', 'hod', 'butterfly', 'ckp',
|
305 |
+
'tele2', 'receiver', 'reality', 'panopto', 't7', 'thot', 'wien', 'uat-online', 'Footer']
|
306 |
+
|
307 |
+
ss = []
|
308 |
+
out = ""
|
309 |
+
for subd in s_array:
|
310 |
+
try:
|
311 |
+
ip_value = dns.resolver.resolve(f'{subd}.{target}', 'A')
|
312 |
+
if ip_value:
|
313 |
+
ss.append(f'{subd}.{target}')
|
314 |
+
if f"{subd}.{target}" in ss:
|
315 |
+
print(f'{subd}.{target} | Found')
|
316 |
+
out += f'{subd}.{target}'
|
317 |
+
out += "\n"
|
318 |
+
out += ""
|
319 |
+
else:
|
320 |
+
pass
|
321 |
+
except dns.resolver.NXDOMAIN:
|
322 |
+
pass
|
323 |
+
except dns.resolver.NoAnswer:
|
324 |
+
pass
|
325 |
+
except KeyboardInterrupt:
|
326 |
+
print('Ended')
|
327 |
+
quit()
|
328 |
+
return out
|
329 |
+
|
330 |
+
|
331 |
+
def dns_recon(target: Optional[str], key: str) -> str:
|
332 |
+
if key is not None:
|
333 |
+
pass
|
334 |
+
else:
|
335 |
+
raise ValueError("KeyNotFound: Key Not Provided")
|
336 |
+
if target is not None:
|
337 |
+
pass
|
338 |
+
else:
|
339 |
+
raise ValueError("InvalidTarget: Target Not Provided")
|
340 |
+
analyze = ''
|
341 |
+
# The DNS Records to be enumeratee
|
342 |
+
record_types = ['A', 'AAAA', 'NS', 'CNAME', 'MX', 'PTR', 'SOA', 'TXT']
|
343 |
+
for records in track(record_types):
|
344 |
+
try:
|
345 |
+
answer = dns.resolver.resolve(target, records)
|
346 |
+
for server in answer:
|
347 |
+
st = server.to_text()
|
348 |
+
analyze += "\n"
|
349 |
+
analyze += records
|
350 |
+
analyze += " : "
|
351 |
+
analyze += st
|
352 |
+
except dns.resolver.NoAnswer:
|
353 |
+
print('No record Found')
|
354 |
+
pass
|
355 |
+
except dns.resolver.NXDOMAIN:
|
356 |
+
print('NXDOMAIN record NOT Found')
|
357 |
+
pass
|
358 |
+
except KeyboardInterrupt:
|
359 |
+
print("Bye")
|
360 |
+
quit()
|
361 |
+
try:
|
362 |
+
response = DnsAI(key, analyze)
|
363 |
+
return str(response)
|
364 |
+
except KeyboardInterrupt:
|
365 |
+
print("Bye")
|
366 |
+
quit()
|
367 |
+
|
368 |
+
|
369 |
+
def scanner(ip: Optional[str], profile: int, key: str) -> str:
|
370 |
+
if key is not None:
|
371 |
+
pass
|
372 |
+
else:
|
373 |
+
raise ValueError("KeyNotFound: Key Not Provided")
|
374 |
+
# Handle the None case
|
375 |
+
profile_argument = ""
|
376 |
+
# The port profiles or scan types user can choose
|
377 |
+
if profile == 1:
|
378 |
+
profile_argument = '-Pn -sV -T4 -O -F'
|
379 |
+
elif profile == 2:
|
380 |
+
profile_argument = '-Pn -T4 -A -v'
|
381 |
+
elif profile == 3:
|
382 |
+
profile_argument = '-Pn -sS -sU -T4 -A -v'
|
383 |
+
elif profile == 4:
|
384 |
+
profile_argument = '-Pn -p- -T4 -A -v'
|
385 |
+
elif profile == 5:
|
386 |
+
profile_argument = '-Pn -sS -sU -T4 -A -PE -PP -PS80,443 -PA3389 -PU40125 -PY -g 53 --script=vuln'
|
387 |
+
else:
|
388 |
+
raise ValueError(f"Invalid Argument: {profile}")
|
389 |
+
# The scanner with GPT Implemented
|
390 |
+
nm.scan('{}'.format(ip), arguments='{}'.format(profile_argument))
|
391 |
+
json_data = nm.analyse_nmap_xml_scan()
|
392 |
+
analyze = json_data["scan"]
|
393 |
+
try:
|
394 |
+
response = PortAI(key, analyze)
|
395 |
+
except KeyboardInterrupt:
|
396 |
+
print("Bye")
|
397 |
+
quit()
|
398 |
+
return str(response)
|
399 |
+
|
400 |
+
|
401 |
+
frame = customtkinter.CTkFrame(master=root)
|
402 |
+
frame.pack(pady=20, padx=60, fill="both", expand=True)
|
403 |
+
|
404 |
+
label = customtkinter.CTkLabel(
|
405 |
+
master=frame, text="GVA System")
|
406 |
+
label.pack(pady=12, padx=10)
|
407 |
+
|
408 |
+
entry1 = customtkinter.CTkEntry(master=frame, placeholder_text="API_KEY")
|
409 |
+
entry1.pack(pady=12, padx=10)
|
410 |
+
entry2 = customtkinter.CTkEntry(master=frame, placeholder_text="Target")
|
411 |
+
entry2.pack(pady=12, padx=10)
|
412 |
+
entry5 = customtkinter.CTkEntry(
|
413 |
+
master=frame, placeholder_text="Attack (nmap/dns)")
|
414 |
+
entry5.pack(pady=12, padx=10)
|
415 |
+
entry4 = customtkinter.CTkEntry(master=frame, placeholder_text="Savefile.json")
|
416 |
+
entry4.pack(pady=12, padx=10)
|
417 |
+
entry3 = customtkinter.CTkEntry(
|
418 |
+
master=frame, placeholder_text="Profile (Only Nmap)")
|
419 |
+
entry3.pack(pady=12, padx=10)
|
420 |
+
radiobutton_var = customtkinter.IntVar(value=1)
|
421 |
+
button = customtkinter.CTkButton(
|
422 |
+
master=frame, text="Run", command=application)
|
423 |
+
button.pack(pady=12, padx=10)
|
424 |
+
|
425 |
+
root.mainloop()
|
components/jwt.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import base64
|
3 |
+
from datetime import datetime
|
4 |
+
from typing import Optional
|
5 |
+
|
6 |
+
class JWTAnalyzer:
|
7 |
+
def analyze(self, AIModels, token, openai_api_token: Optional[str], bard_api_token: Optional[str], llama_api_token: Optional[str], llama_endpoint: Optional[str], AI: str):
|
8 |
+
try:
|
9 |
+
parts = token.split('.')
|
10 |
+
if len(parts) != 3:
|
11 |
+
raise ValueError("Invalid token format. Expected 3 parts.")
|
12 |
+
header = json.loads(base64.urlsafe_b64decode(parts[0] + '===').decode('utf-8', 'replace'))
|
13 |
+
payload = json.loads(base64.urlsafe_b64decode(parts[1] + '===').decode('utf-8', 'replace'))
|
14 |
+
algorithm_used = header.get('alg', 'Unknown Algorithm')
|
15 |
+
expiration_time = datetime.utcfromtimestamp(payload['exp']) if 'exp' in payload else None
|
16 |
+
|
17 |
+
analysis_result = {
|
18 |
+
'Algorithm Used': algorithm_used,
|
19 |
+
'Decoded Payload': payload,
|
20 |
+
'Claims': json.dumps(payload, indent=4),
|
21 |
+
'Expires At': expiration_time.strftime('%Y-%m-%d %H:%M:%S') if expiration_time else 'Not Expired'
|
22 |
+
}
|
23 |
+
|
24 |
+
response = ""
|
25 |
+
match AI:
|
26 |
+
case 'openai':
|
27 |
+
if openai_api_token is None:
|
28 |
+
raise ValueError("KeyNotFound: Key Not Provided")
|
29 |
+
response = AIModels.gpt_ai(openai_api_token, json.dumps(analysis_result))
|
30 |
+
case 'bard':
|
31 |
+
if bard_api_token is None:
|
32 |
+
raise ValueError("KeyNotFound: Key Not Provided")
|
33 |
+
response = AIModels.BardAI(bard_api_token, json.dumps(analysis_result))
|
34 |
+
case 'llama':
|
35 |
+
response = AIModels.llama_AI(json.dumps(analysis_result), "local", llama_api_token, llama_endpoint)
|
36 |
+
case 'llama-api':
|
37 |
+
response = AIModels.llama_AI(json.dumps(analysis_result), "runpod", llama_api_token, llama_endpoint)
|
38 |
+
except jwt.ExpiredSignatureError:
|
39 |
+
analysis_result = {'Error': 'Token has expired.'}
|
40 |
+
except jwt.InvalidTokenError as e:
|
41 |
+
analysis_result = {'Error': f'Invalid token: {e}'}
|
42 |
+
return response
|
components/menus.py
ADDED
@@ -0,0 +1,530 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import platform
|
3 |
+
from rich import print
|
4 |
+
from rich.console import Console
|
5 |
+
from rich.table import Table
|
6 |
+
from rich.panel import Panel
|
7 |
+
from GVA.dns_recon import DNSRecon
|
8 |
+
from GVA.geo import geo_ip_recon
|
9 |
+
from GVA.scanner import NetworkScanner
|
10 |
+
from GVA.subdomain import sub_enum
|
11 |
+
from GVA.jwt import JWTAnalyzer
|
12 |
+
from GVA.assets import Assets
|
13 |
+
from GVA.packet_analysis import PacketAnalysis
|
14 |
+
from GVA.ai_models import NMAP_AI_MODEL
|
15 |
+
from GVA.ai_models import DNS_AI_MODEL
|
16 |
+
from GVA.ai_models import JWT_AI_MODEL
|
17 |
+
|
18 |
+
assets = Assets()
|
19 |
+
dns_enum = DNSRecon()
|
20 |
+
geo_ip = geo_ip_recon()
|
21 |
+
packetanalysis = PacketAnalysis()
|
22 |
+
jwt_analyzer = JWTAnalyzer()
|
23 |
+
p_ai_models = NMAP_AI_MODEL()
|
24 |
+
dns_ai_models = DNS_AI_MODEL()
|
25 |
+
jwt_ai_model = JWT_AI_MODEL()
|
26 |
+
port_scanner = NetworkScanner()
|
27 |
+
sub_recon = sub_enum()
|
28 |
+
console = Console()
|
29 |
+
|
30 |
+
|
31 |
+
def clearscr() -> None:
|
32 |
+
try:
|
33 |
+
osp = platform.system()
|
34 |
+
match osp:
|
35 |
+
case 'Darwin':
|
36 |
+
os.system("clear")
|
37 |
+
case 'Linux':
|
38 |
+
os.system("clear")
|
39 |
+
case 'Windows':
|
40 |
+
os.system("cls")
|
41 |
+
except Exception:
|
42 |
+
pass
|
43 |
+
|
44 |
+
|
45 |
+
class Menus():
|
46 |
+
|
47 |
+
def nmap_menu(self) -> None:
|
48 |
+
try:
|
49 |
+
table = Table()
|
50 |
+
table.add_column("Options", style="cyan")
|
51 |
+
table.add_column("Utility", style="green")
|
52 |
+
table.add_row("1", "AI Options")
|
53 |
+
table.add_row("2", "Set Target")
|
54 |
+
table.add_row("3", "Set Profile")
|
55 |
+
table.add_row("4", "Show options")
|
56 |
+
table.add_row("5", "Run Attack")
|
57 |
+
table.add_row("q", "Quit")
|
58 |
+
console.print(table)
|
59 |
+
self.option = input("Enter your choice: ")
|
60 |
+
match self.option:
|
61 |
+
case "1":
|
62 |
+
clearscr()
|
63 |
+
table0 = Table()
|
64 |
+
table0.add_column("Options", style="cyan")
|
65 |
+
table0.add_column("AI Available", style="green")
|
66 |
+
table0.add_row("1", "OpenAI")
|
67 |
+
table0.add_row("2", "Bard")
|
68 |
+
table0.add_row("3", "LLama2")
|
69 |
+
print(Panel(table0))
|
70 |
+
self.ai_set_choice = input("Enter AI of Choice: ")
|
71 |
+
match self.ai_set_choice:
|
72 |
+
case "1":
|
73 |
+
self.ai_set_args, self.ai_set = "openai", "openai"
|
74 |
+
self.akey_set = input("Enter OpenAI API: ")
|
75 |
+
print(Panel(f"API-Key Set: {self.akey_set}"))
|
76 |
+
case "2":
|
77 |
+
self.ai_set_args, self.ai_set = "bard", "bard"
|
78 |
+
self.bkey_set = input("Enter Bard AI API: ")
|
79 |
+
print(Panel(f"API-Key Set: {self.bkey_set}"))
|
80 |
+
case "3":
|
81 |
+
clearscr()
|
82 |
+
tablel = Table()
|
83 |
+
tablel.add_column("Options", style="cyan")
|
84 |
+
tablel.add_column("Llama Options", style="cyan")
|
85 |
+
tablel.add_row("1", "Llama Local")
|
86 |
+
tablel.add_row("2", "Llama RunPod")
|
87 |
+
print(tablel)
|
88 |
+
self.ai_set_choice = input("Enter AI of Choice: ")
|
89 |
+
self.ai_set_args = "llama"
|
90 |
+
self.ai_set = "llama"
|
91 |
+
if self.ai_set_choice == "1":
|
92 |
+
self.ai_set = "llama"
|
93 |
+
print(Panel("No Key needed"))
|
94 |
+
print(Panel("Selected LLama"))
|
95 |
+
elif self.ai_set_choice == "2":
|
96 |
+
self.ai_set = "llama-api"
|
97 |
+
self.llamaendpoint = input("Enter Runpod Endpoint ID: ")
|
98 |
+
self.llamakey = input("Enter Runpod API Key: ")
|
99 |
+
print(Panel(f"API-Key Set: {self.llamakey}"))
|
100 |
+
print(Panel(f"Runpod Endpoint Set: {self.llamaendpoint}"))
|
101 |
+
self.nmap_menu()
|
102 |
+
case "2":
|
103 |
+
clearscr()
|
104 |
+
print(Panel("Set Target Hostname or IP"))
|
105 |
+
self.t = input("Enter Target: ")
|
106 |
+
print(Panel(f"Target Set: {self.t}"))
|
107 |
+
self.nmap_menu()
|
108 |
+
case "3":
|
109 |
+
clearscr()
|
110 |
+
table1 = Table()
|
111 |
+
table1.add_column("Options", style="cyan")
|
112 |
+
table1.add_column("Value", style="green")
|
113 |
+
table1.add_row("1", "-Pn -sV -T4 -O -F")
|
114 |
+
table1.add_row("2", "-Pn -T4 -A -v")
|
115 |
+
table1.add_row("3", "-Pn -sS -sU -T4 -A -v")
|
116 |
+
table1.add_row("4", "-Pn -p- -T4 -A -v")
|
117 |
+
table1.add_row("5", "-Pn -sS -sU -T4 -A -PE -PP -PY -g 53 --script=vuln")
|
118 |
+
table1.add_row("6", "-Pn -sV -p- -A")
|
119 |
+
table1.add_row("7", "-Pn -sS -sV -O -T4 -A")
|
120 |
+
table1.add_row("8", "-Pn -sC")
|
121 |
+
table1.add_row("9", "-Pn -p 1-65535 -T4 -A -v")
|
122 |
+
table1.add_row("10", "-Pn -sU -T4")
|
123 |
+
table1.add_row("11", "-Pn -sV --top-ports 100")
|
124 |
+
table1.add_row("12", "-Pn -sS -sV -T4 --script=default,discovery,vuln")
|
125 |
+
table1.add_row("13", "-Pn -F")
|
126 |
+
print(Panel(table1))
|
127 |
+
self.profile_num = input("Enter your Profile: ")
|
128 |
+
print(Panel(f"Profile Set {self.profile_num}"))
|
129 |
+
self.nmap_menu()
|
130 |
+
case "4":
|
131 |
+
clearscr()
|
132 |
+
table2 = Table()
|
133 |
+
table2.add_column("Options", style="cyan")
|
134 |
+
table2.add_column("Value", style="green")
|
135 |
+
table2.add_row("AI Set", str(self.ai_set_args))
|
136 |
+
table2.add_row("OpenAI API Key", str(self.akey_set))
|
137 |
+
table2.add_row("Bard AI API Key", str(self.bkey_set))
|
138 |
+
table2.add_row("Llama Runpod API Key", str(self.llamakey))
|
139 |
+
table2.add_row("Runpod Endpoint ID", str(self.llamaendpoint))
|
140 |
+
table2.add_row("Target", str(self.t))
|
141 |
+
table2.add_row("Profile", str(self.profile_num))
|
142 |
+
print(Panel(table2))
|
143 |
+
self.nmap_menu()
|
144 |
+
case "5":
|
145 |
+
clearscr()
|
146 |
+
pout: str = port_scanner.scanner(
|
147 |
+
AIModels=p_ai_models,
|
148 |
+
ip=self.t,
|
149 |
+
profile=int(self.profile_num),
|
150 |
+
akey=self.akey_set,
|
151 |
+
bkey=self.bkey_set,
|
152 |
+
lkey=self.lkey,
|
153 |
+
lendpoint=self.lendpoint,
|
154 |
+
AI=self.ai_set
|
155 |
+
)
|
156 |
+
assets.print_output("Nmap", pout, self.ai_set)
|
157 |
+
case "q":
|
158 |
+
quit()
|
159 |
+
except KeyboardInterrupt:
|
160 |
+
print(Panel("Exiting Program"))
|
161 |
+
|
162 |
+
def dns_menu(self) -> None:
|
163 |
+
try:
|
164 |
+
table = Table()
|
165 |
+
table.add_column("Options", style="cyan")
|
166 |
+
table.add_column("Utility", style="green")
|
167 |
+
table.add_row("1", "AI Option")
|
168 |
+
table.add_row("2", "Set Target")
|
169 |
+
table.add_row("3", "Show options")
|
170 |
+
table.add_row("4", "Run Attack")
|
171 |
+
table.add_row("q", "Quit")
|
172 |
+
console.print(table)
|
173 |
+
option = input("Enter your choice: ")
|
174 |
+
match option:
|
175 |
+
case "1":
|
176 |
+
clearscr()
|
177 |
+
table0 = Table()
|
178 |
+
table0.add_column("Options", style="cyan")
|
179 |
+
table0.add_column("AI Available", style="green")
|
180 |
+
table0.add_row("1", "OpenAI")
|
181 |
+
table0.add_row("2", "Bard")
|
182 |
+
table0.add_row("3", "LLama2")
|
183 |
+
print(Panel(table0))
|
184 |
+
self.ai_set_choice = input("Enter AI of Choice: ")
|
185 |
+
match self.ai_set_choice:
|
186 |
+
case "1":
|
187 |
+
self.ai_set_args, self.ai_set = "openai", "openai"
|
188 |
+
self.akey_set = input("Enter OpenAI API: ")
|
189 |
+
print(Panel(f"API-Key Set: {self.akey_set}"))
|
190 |
+
case "2":
|
191 |
+
self.ai_set_args, self.ai_set = "bard", "bard"
|
192 |
+
self.bkey_set = input("Enter Bard AI API: ")
|
193 |
+
print(Panel(f"API-Key Set: {self.bkey_set}"))
|
194 |
+
case "3":
|
195 |
+
clearscr()
|
196 |
+
tablel = Table()
|
197 |
+
tablel.add_column("Options", style="cyan")
|
198 |
+
tablel.add_column("Llama Options", style="cyan")
|
199 |
+
tablel.add_row("1", "Llama Local")
|
200 |
+
tablel.add_row("2", "Llama RunPod")
|
201 |
+
print(tablel)
|
202 |
+
self.ai_set_choice = input("Enter AI of Choice: ")
|
203 |
+
self.ai_set_args = "llama"
|
204 |
+
self.ai_set = "llama"
|
205 |
+
if self.ai_set_choice == "1":
|
206 |
+
self.ai_set = "llama"
|
207 |
+
print(Panel("No Key needed"))
|
208 |
+
print(Panel("Selected LLama"))
|
209 |
+
elif self.ai_set_choice == "2":
|
210 |
+
self.ai_set = "llama-api"
|
211 |
+
self.llamaendpoint = input("Enter Runpod Endpoint ID: ")
|
212 |
+
self.llamakey = input("Enter Runpod API Key: ")
|
213 |
+
print(Panel(f"API-Key Set: {self.llamakey}"))
|
214 |
+
print(Panel(f"Runpod Endpoint Set: {self.llamaendpoint}"))
|
215 |
+
self.dns_menu()
|
216 |
+
case "2":
|
217 |
+
clearscr()
|
218 |
+
print(Panel("Set Target Hostname or IP"))
|
219 |
+
self.t = input("Enter Target: ")
|
220 |
+
print(Panel(f"Target Set:{self.t}"))
|
221 |
+
self.dns_menu()
|
222 |
+
case "3":
|
223 |
+
clearscr()
|
224 |
+
table1 = Table()
|
225 |
+
table1.add_column("Options", style="cyan")
|
226 |
+
table1.add_column("Value", style="green")
|
227 |
+
table1.add_row("AI Set", str(self.ai_set_args))
|
228 |
+
table1.add_row("OpenAI API Key", str(self.akey_set))
|
229 |
+
table1.add_row("Bard AI API Key", str(self.bkey_set))
|
230 |
+
table1.add_row("Llama Runpod API Key", str(self.llamakey))
|
231 |
+
table1.add_row("Runpod Endpoint ID", str(self.llamaendpoint))
|
232 |
+
table1.add_row("Target", str(self.t))
|
233 |
+
print(Panel(table1))
|
234 |
+
self.dns_menu()
|
235 |
+
case "4":
|
236 |
+
clearscr()
|
237 |
+
dns_output: str = dns_enum.dns_resolver(
|
238 |
+
AIModels=dns_ai_models,
|
239 |
+
target=self.t,
|
240 |
+
akey=self.akey_set,
|
241 |
+
bkey=self.bkey_set,
|
242 |
+
lkey=self.lkey,
|
243 |
+
lendpoint=self.lendpoint,
|
244 |
+
AI=self.ai_set
|
245 |
+
)
|
246 |
+
assets.print_output("DNS", dns_output, self.ai_set)
|
247 |
+
case "q":
|
248 |
+
quit()
|
249 |
+
except KeyboardInterrupt:
|
250 |
+
print(Panel("Exiting Program"))
|
251 |
+
|
252 |
+
def jwt_menu(self) -> None:
|
253 |
+
try:
|
254 |
+
table = Table()
|
255 |
+
table.add_column("Options", style="cyan")
|
256 |
+
table.add_column("Utility", style="green")
|
257 |
+
table.add_row("1", "AI Option")
|
258 |
+
table.add_row("2", "Set Token")
|
259 |
+
table.add_row("3", "Show options")
|
260 |
+
table.add_row("4", "Run Attack")
|
261 |
+
table.add_row("q", "Quit")
|
262 |
+
console.print(table)
|
263 |
+
option = input("Enter your choice: ")
|
264 |
+
match option:
|
265 |
+
case "1":
|
266 |
+
clearscr()
|
267 |
+
table0 = Table()
|
268 |
+
table0.add_column("Options", style="cyan")
|
269 |
+
table0.add_column("AI Available", style="green")
|
270 |
+
table0.add_row("1", "OpenAI")
|
271 |
+
table0.add_row("2", "Bard")
|
272 |
+
table0.add_row("3", "LLama2")
|
273 |
+
print(Panel(table0))
|
274 |
+
self.ai_set_choice = input("Enter AI of Choice: ")
|
275 |
+
match self.ai_set_choice:
|
276 |
+
case "1":
|
277 |
+
self.ai_set_args, self.ai_set = "openai", "openai"
|
278 |
+
self.akey_set = input("Enter OpenAI API: ")
|
279 |
+
print(Panel(f"API-Key Set: {self.akey_set}"))
|
280 |
+
case "2":
|
281 |
+
self.ai_set_args, self.ai_set = "bard", "bard"
|
282 |
+
self.bkey_set = input("Enter Bard AI API: ")
|
283 |
+
print(Panel(f"API-Key Set: {self.bkey_set}"))
|
284 |
+
case "3":
|
285 |
+
clearscr()
|
286 |
+
tablel = Table()
|
287 |
+
tablel.add_column("Options", style="cyan")
|
288 |
+
tablel.add_column("Llama Options", style="cyan")
|
289 |
+
tablel.add_row("1", "Llama Local")
|
290 |
+
tablel.add_row("2", "Llama RunPod")
|
291 |
+
print(tablel)
|
292 |
+
self.ai_set_choice = input("Enter AI of Choice: ")
|
293 |
+
self.ai_set_args = "llama"
|
294 |
+
self.ai_set = "llama"
|
295 |
+
if self.ai_set_choice == "1":
|
296 |
+
self.ai_set = "llama"
|
297 |
+
print(Panel("No Key needed"))
|
298 |
+
print(Panel("Selected LLama"))
|
299 |
+
elif self.ai_set_choice == "2":
|
300 |
+
self.ai_set = "llama-api"
|
301 |
+
self.llamaendpoint = input("Enter Runpod Endpoint ID: ")
|
302 |
+
self.llamakey = input("Enter Runpod API Key: ")
|
303 |
+
print(Panel(f"API-Key Set: {self.llamakey}"))
|
304 |
+
print(Panel(f"Runpod Endpoint Set: {self.llamaendpoint}"))
|
305 |
+
self.jwt_menu()
|
306 |
+
case "2":
|
307 |
+
clearscr()
|
308 |
+
print(Panel("Set Token value"))
|
309 |
+
self.t = input("Enter TOKEN: ")
|
310 |
+
print(Panel(f"Token Set:{self.t}"))
|
311 |
+
self.jwt_menu()
|
312 |
+
case "3":
|
313 |
+
clearscr()
|
314 |
+
table1 = Table()
|
315 |
+
table1.add_column("Options", style="cyan")
|
316 |
+
table1.add_column("Value", style="green")
|
317 |
+
table1.add_row("AI Set", str(self.ai_set_args))
|
318 |
+
table1.add_row("OpenAI API Key", str(self.akey_set))
|
319 |
+
table1.add_row("Bard AI API Key", str(self.bkey_set))
|
320 |
+
table1.add_row("Llama Runpod API Key", str(self.llamakey))
|
321 |
+
table1.add_row("Runpod Endpoint ID", str(self.llamaendpoint))
|
322 |
+
table1.add_row("JWT TOKEN", str(self.t))
|
323 |
+
print(Panel(table1))
|
324 |
+
self.jwt_menu()
|
325 |
+
case "4":
|
326 |
+
clearscr()
|
327 |
+
JWT_output: str = jwt_analyzer.analyze(
|
328 |
+
AIModels=jwt_ai_model,
|
329 |
+
token=self.t,
|
330 |
+
openai_api_token=self.akey_set,
|
331 |
+
bard_api_token=self.bkey_set,
|
332 |
+
llama_api_token=self.lkey,
|
333 |
+
llama_endpoint=self.lendpoint,
|
334 |
+
AI=self.ai_set
|
335 |
+
)
|
336 |
+
assets.print_output("JWT", JWT_output, self.ai_set)
|
337 |
+
case "q":
|
338 |
+
quit()
|
339 |
+
except KeyboardInterrupt:
|
340 |
+
print(Panel("Exiting Program"))
|
341 |
+
|
342 |
+
def pcap_menu(self) -> None:
|
343 |
+
try:
|
344 |
+
table = Table()
|
345 |
+
table.add_column("Options", style="cyan")
|
346 |
+
table.add_column("Utility", style="green")
|
347 |
+
table.add_row("1", "Set Target file location")
|
348 |
+
table.add_row("2", "Set Output file location")
|
349 |
+
table.add_row("3", "Set Threads")
|
350 |
+
table.add_row("4", "Show options")
|
351 |
+
table.add_row("5", "Run Attack")
|
352 |
+
table.add_row("q", "Quit")
|
353 |
+
console.print(table)
|
354 |
+
self.option = input("Enter your choice: ")
|
355 |
+
match self.option:
|
356 |
+
case "1":
|
357 |
+
clearscr()
|
358 |
+
print(Panel("Set Target PCAP file Location"))
|
359 |
+
self.t = input("Enter Target: ")
|
360 |
+
print(Panel(f"Target Set: {self.t}"))
|
361 |
+
self.pcap_menu()
|
362 |
+
case "2":
|
363 |
+
clearscr()
|
364 |
+
print(Panel("Set Output file Location"))
|
365 |
+
self.t = input("Enter Location: ")
|
366 |
+
print(Panel(f"Output Set: {self.output_loc}"))
|
367 |
+
self.pcap_menu()
|
368 |
+
case "3":
|
369 |
+
clearscr()
|
370 |
+
print(Panel("Set Number of threads"))
|
371 |
+
self.t = input("Enter Threads: ")
|
372 |
+
print(Panel(f"Threads Set: {self.threads}"))
|
373 |
+
self.pcap_menu()
|
374 |
+
case "4":
|
375 |
+
clearscr()
|
376 |
+
table1 = Table()
|
377 |
+
table1.add_column("Options", style="cyan")
|
378 |
+
table1.add_column("Value", style="green")
|
379 |
+
table1.add_row("Target PCAP file", str(self.t))
|
380 |
+
table1.add_row("Output location", str(self.output_loc))
|
381 |
+
table1.add_row("Threads set", str(self.threads))
|
382 |
+
print(Panel(table1))
|
383 |
+
self.pcap_menu()
|
384 |
+
case "5":
|
385 |
+
clearscr()
|
386 |
+
packetanalysis.PacketAnalyzer(
|
387 |
+
cap_loc=self.t,
|
388 |
+
save_loc=self.output_loc,
|
389 |
+
max_workers=self.threads
|
390 |
+
)
|
391 |
+
case "q":
|
392 |
+
quit()
|
393 |
+
except KeyboardInterrupt:
|
394 |
+
print(Panel("Exiting Program"))
|
395 |
+
|
396 |
+
def geo_menu(self) -> None:
|
397 |
+
try:
|
398 |
+
table = Table()
|
399 |
+
table.add_column("Options", style="cyan")
|
400 |
+
table.add_column("Utility", style="green")
|
401 |
+
table.add_row("1", "ADD API Key")
|
402 |
+
table.add_row("2", "Set Target")
|
403 |
+
table.add_row("3", "Show options")
|
404 |
+
table.add_row("4", "Run Attack")
|
405 |
+
table.add_row("q", "Quit")
|
406 |
+
console.print(table)
|
407 |
+
self.option = input("Enter your choice: ")
|
408 |
+
match self.option:
|
409 |
+
case "1":
|
410 |
+
clearscr()
|
411 |
+
self.keyset = input("Enter GEO-IP API: ")
|
412 |
+
print(Panel(f"GEOIP API Key Set: {self.keyset}"))
|
413 |
+
self.geo_menu()
|
414 |
+
case "2":
|
415 |
+
clearscr()
|
416 |
+
print(Panel("Set Target Hostname or IP"))
|
417 |
+
self.t = input("Enter Target: ")
|
418 |
+
print(Panel(f"Target Set: {self.t}"))
|
419 |
+
self.geo_menu()
|
420 |
+
case "3":
|
421 |
+
clearscr()
|
422 |
+
table1 = Table()
|
423 |
+
table1.add_column("Options", style="cyan")
|
424 |
+
table1.add_column("Value", style="green")
|
425 |
+
table1.add_row("API Key", str(self.keyset))
|
426 |
+
table1.add_row("Target", str(self.t))
|
427 |
+
print(Panel(table1))
|
428 |
+
self.geo_menu()
|
429 |
+
case "4":
|
430 |
+
clearscr()
|
431 |
+
geo_output: str = geo_ip.geoip(self.keyset, self.t)
|
432 |
+
assets.print_output("GeoIP", str(geo_output), ai="None")
|
433 |
+
case "q":
|
434 |
+
quit()
|
435 |
+
except KeyboardInterrupt:
|
436 |
+
print(Panel("Exiting Program"))
|
437 |
+
|
438 |
+
def sub_menu(self) -> None:
|
439 |
+
try:
|
440 |
+
table = Table()
|
441 |
+
table.add_column("Options", style="cyan")
|
442 |
+
table.add_column("Utility", style="green")
|
443 |
+
table.add_row("1", "ADD Subdomain list")
|
444 |
+
table.add_row("2", "Set Target")
|
445 |
+
table.add_row("3", "Show options")
|
446 |
+
table.add_row("4", "Run Attack")
|
447 |
+
table.add_row("q", "Quit")
|
448 |
+
console.print(table)
|
449 |
+
self.option = input("Enter your choice: ")
|
450 |
+
match self.option:
|
451 |
+
case "1":
|
452 |
+
clearscr()
|
453 |
+
print(Panel("Set TXT subdomain file location"))
|
454 |
+
self.list_loc = input("Enter List Location: ")
|
455 |
+
print(Panel(f"Location Set: {self.list_loc}"))
|
456 |
+
self.sub_menu()
|
457 |
+
case "2":
|
458 |
+
clearscr()
|
459 |
+
print(Panel("Set Target Hostname or IP"))
|
460 |
+
self.t = input("Enter Target: ")
|
461 |
+
print(Panel(f"Target Set: {self.t}"))
|
462 |
+
self.sub_menu()
|
463 |
+
case "3":
|
464 |
+
clearscr()
|
465 |
+
table1 = Table()
|
466 |
+
table1.add_column("Options", style="cyan")
|
467 |
+
table1.add_column("Value", style="green")
|
468 |
+
table1.add_row("Location", str(self.list_loc))
|
469 |
+
table1.add_row("Target", str(self.t))
|
470 |
+
print(Panel(table1))
|
471 |
+
self.sub_menu()
|
472 |
+
case "4":
|
473 |
+
clearscr()
|
474 |
+
sub_output: str = sub_recon.sub_enumerator(self.t, self.list_loc)
|
475 |
+
console.print(sub_output, style="bold underline")
|
476 |
+
case "q":
|
477 |
+
quit()
|
478 |
+
except KeyboardInterrupt:
|
479 |
+
print(Panel("Exiting Program"))
|
480 |
+
|
481 |
+
def __init__(self, lkey, threads, output_loc, lendpoint, keyset, t, profile_num, ai_set, akey_set, bkey_set, ai_set_args, llamakey, llamaendpoint) -> None:
|
482 |
+
try:
|
483 |
+
self.lkey = lkey
|
484 |
+
self.threads = threads
|
485 |
+
self.output_loc = output_loc
|
486 |
+
self.lendpoint = lendpoint
|
487 |
+
self.keyset = keyset
|
488 |
+
self.t = t
|
489 |
+
self.profile_num = profile_num
|
490 |
+
self.ai_set = ai_set
|
491 |
+
self.akey_set = akey_set
|
492 |
+
self.bkey_set = bkey_set
|
493 |
+
self.ai_set_args = ai_set_args
|
494 |
+
self.llamakey = llamakey
|
495 |
+
self.llamaendpoint = llamaendpoint
|
496 |
+
table = Table()
|
497 |
+
table.add_column("Options", style="cyan")
|
498 |
+
table.add_column("Utility", style="green")
|
499 |
+
table.add_row("1", "Nmap Enum")
|
500 |
+
table.add_row("2", "DNS Enum")
|
501 |
+
table.add_row("3", "Subdomain Enum")
|
502 |
+
table.add_row("4", "GEO-IP Enum")
|
503 |
+
table.add_row("5", "JWT Analysis")
|
504 |
+
table.add_row("6", "PCAP Analysis")
|
505 |
+
table.add_row("q", "Quit")
|
506 |
+
console.print(table)
|
507 |
+
option = input("Enter your choice: ")
|
508 |
+
match option:
|
509 |
+
case "1":
|
510 |
+
clearscr()
|
511 |
+
self.nmap_menu()
|
512 |
+
case "2":
|
513 |
+
clearscr()
|
514 |
+
self.dns_menu()
|
515 |
+
case "3":
|
516 |
+
clearscr()
|
517 |
+
self.sub_menu()
|
518 |
+
case "4":
|
519 |
+
clearscr()
|
520 |
+
self.geo_menu()
|
521 |
+
case "5":
|
522 |
+
clearscr()
|
523 |
+
self.jwt_menu()
|
524 |
+
case "6":
|
525 |
+
clearscr()
|
526 |
+
self.pcap_menu()
|
527 |
+
case "q":
|
528 |
+
quit()
|
529 |
+
except KeyboardInterrupt:
|
530 |
+
print(Panel("Exiting Program"))
|
components/packet_analysis.py
ADDED
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from rich import print
|
2 |
+
from subprocess import run, PIPE, STDOUT
|
3 |
+
from concurrent.futures import ThreadPoolExecutor
|
4 |
+
from typing import Any
|
5 |
+
from rich.console import Console
|
6 |
+
from rich.table import Table
|
7 |
+
import json
|
8 |
+
import re
|
9 |
+
import platform
|
10 |
+
|
11 |
+
|
12 |
+
class PacketAnalysis:
|
13 |
+
tshark_loc = ""
|
14 |
+
services = []
|
15 |
+
tcp_streams = []
|
16 |
+
sources = []
|
17 |
+
destinations = []
|
18 |
+
resolved = []
|
19 |
+
dns_query_names = []
|
20 |
+
dns_resp_names = []
|
21 |
+
unique_eapol_data = []
|
22 |
+
combined_json = []
|
23 |
+
|
24 |
+
def detect_tshark(self) -> None:
|
25 |
+
try:
|
26 |
+
osp = platform.system()
|
27 |
+
match osp:
|
28 |
+
case 'Darwin':
|
29 |
+
self.tshark_loc = "tshark"
|
30 |
+
case 'Linux':
|
31 |
+
self.tshark_loc = "tshark"
|
32 |
+
case 'Windows':
|
33 |
+
self.tshark_loc = '"C:\\Program Files\\Wireshark\\tshark.exe"'
|
34 |
+
except Exception:
|
35 |
+
pass
|
36 |
+
|
37 |
+
def extract_network_info(self, json_data):
|
38 |
+
services = set()
|
39 |
+
tcp_streams = set()
|
40 |
+
source_addresses = set()
|
41 |
+
destination_addresses = set()
|
42 |
+
resolved_sources = set()
|
43 |
+
dns_query_names = set()
|
44 |
+
dns_resp_names = set()
|
45 |
+
unique_eapol_data = set()
|
46 |
+
|
47 |
+
for entry in json_data:
|
48 |
+
layers = entry.get('_source', {}).get('layers', {})
|
49 |
+
|
50 |
+
tcp_layer = layers.get('tcp', {})
|
51 |
+
if tcp_layer:
|
52 |
+
service = tcp_layer.get('tcp.srcport')
|
53 |
+
if service:
|
54 |
+
services.add(service)
|
55 |
+
if tcp_layer:
|
56 |
+
tcp_stream_val = tcp_layer.get('tcp.stream')
|
57 |
+
if service:
|
58 |
+
tcp_streams.add(tcp_stream_val)
|
59 |
+
|
60 |
+
ip_layer = layers.get('ip', {})
|
61 |
+
if ip_layer:
|
62 |
+
source_address = ip_layer.get('ip.src_host')
|
63 |
+
destination_address = ip_layer.get('ip.dst_host')
|
64 |
+
if source_address:
|
65 |
+
source_addresses.add(source_address)
|
66 |
+
if destination_address:
|
67 |
+
destination_addresses.add(destination_address)
|
68 |
+
|
69 |
+
eth_layer = layers.get('eth', {})
|
70 |
+
if eth_layer:
|
71 |
+
source_mac = eth_layer.get('eth.src')
|
72 |
+
resolved_source_mac = eth_layer.get('eth.src_tree', {}).get('eth.src_resolved')
|
73 |
+
if source_mac and resolved_source_mac:
|
74 |
+
resolved_sources.add(resolved_source_mac)
|
75 |
+
|
76 |
+
dns_layer = layers.get('dns', {})
|
77 |
+
if dns_layer:
|
78 |
+
queries = dns_layer.get('Queries', [])
|
79 |
+
if isinstance(queries, list):
|
80 |
+
for query in queries:
|
81 |
+
query_name = query.get('dns.qry.name')
|
82 |
+
if query_name:
|
83 |
+
dns_query_names.add(query_name)
|
84 |
+
elif isinstance(queries, dict):
|
85 |
+
for query_name, query_info in queries.items():
|
86 |
+
dns_query_names.add(query_info.get('dns.qry.name'))
|
87 |
+
answers = dns_layer.get('Answers', [])
|
88 |
+
if isinstance(answers, list):
|
89 |
+
for answer in answers:
|
90 |
+
resp_name = answer.get('dns.resp.name')
|
91 |
+
if resp_name:
|
92 |
+
dns_resp_names.add(resp_name)
|
93 |
+
elif isinstance(answers, dict):
|
94 |
+
for resp_name, resp_info in answers.items():
|
95 |
+
dns_resp_names.add(resp_info.get('dns.resp.name'))
|
96 |
+
|
97 |
+
eapol_layer = layers.get('eapol', {})
|
98 |
+
if eapol_layer:
|
99 |
+
eapol_data = eapol_layer.get('wlan_rsna_eapol.keydes.data', "")
|
100 |
+
unique_eapol_data.add(eapol_data)
|
101 |
+
|
102 |
+
self.services = list(services)
|
103 |
+
self.tcp_streams = list(tcp_streams)
|
104 |
+
self.source_addresses = list(source_addresses)
|
105 |
+
self.destination_addresses = list(destination_addresses)
|
106 |
+
self.resolved_sources = list(resolved_sources)
|
107 |
+
self.dns_query_names = list(dns_query_names)
|
108 |
+
self.dns_resp_names = list(dns_resp_names)
|
109 |
+
self.unique_eapol_data = list(unique_eapol_data)
|
110 |
+
|
111 |
+
def run_tshark_command(self, service, source, streams):
|
112 |
+
stream_cmd = f'{self.tshark_loc} -r test.pcap -q -z follow,tcp,raw,{streams} -Y "ip.addr=={source} and tcp.port=={service}"'
|
113 |
+
runner = run(stream_cmd, shell=True, stdout=PIPE, stderr=STDOUT, text=True)
|
114 |
+
output_lines = runner.stdout.splitlines()
|
115 |
+
node_regex = re.compile(r'Node (\d+): (.+)$')
|
116 |
+
data_regex = re.compile(r'\s+(.+)$')
|
117 |
+
node_0, node_1, data = None, None, None
|
118 |
+
for line in output_lines:
|
119 |
+
node_match = node_regex.match(line)
|
120 |
+
data_match = data_regex.match(line)
|
121 |
+
if node_match:
|
122 |
+
node_num, node_value = node_match.groups()
|
123 |
+
if node_num == '0':
|
124 |
+
node_0 = node_value
|
125 |
+
elif node_num == '1':
|
126 |
+
node_1 = node_value
|
127 |
+
elif data_match:
|
128 |
+
data = data_match.group(1)
|
129 |
+
|
130 |
+
if node_0 is not None and node_1 is not None and data is not None:
|
131 |
+
return ['Source: ' f'{node_0}', 'Destination: ' f'{node_1}', 'stream: ' f'{streams}']
|
132 |
+
else:
|
133 |
+
return []
|
134 |
+
|
135 |
+
def flatten_json(self, data: Any, separator: Any = '.') -> Any:
|
136 |
+
flattened_data = {}
|
137 |
+
for key, value in data.items():
|
138 |
+
if isinstance(value, dict):
|
139 |
+
nested_data = self.flatten_json(value, separator)
|
140 |
+
for nested_key, nested_value in nested_data.items():
|
141 |
+
flattened_data[key + separator + nested_key] = nested_value
|
142 |
+
else:
|
143 |
+
flattened_data[key] = value
|
144 |
+
return flattened_data
|
145 |
+
|
146 |
+
def stream(self, service_list, source_list, tcp_streams_list, max_workers=20):
|
147 |
+
results = []
|
148 |
+
|
149 |
+
with ThreadPoolExecutor(max_workers=max_workers) as executor:
|
150 |
+
command_params = [(service, source, streams) for service in service_list for source in source_list for streams in tcp_streams_list]
|
151 |
+
print("Total Streams combination: ", len(command_params))
|
152 |
+
print("Number of workers in progress: ", max_workers)
|
153 |
+
results = list(executor.map(lambda params: self.run_tshark_command(*params), command_params))
|
154 |
+
results = [result for result in results if result]
|
155 |
+
self.combined_json = results
|
156 |
+
|
157 |
+
def PacketAnalyzer(self, cap_loc, save_loc, max_workers):
|
158 |
+
self.detect_tshark()
|
159 |
+
print('Collecting Json Data')
|
160 |
+
raw_pcap = run(f"{self.tshark_loc} -r {cap_loc} -T json", shell=True, capture_output=True, text=True)
|
161 |
+
try:
|
162 |
+
raw_data = raw_pcap.stdout
|
163 |
+
json_data = json.loads(raw_data)
|
164 |
+
except json.JSONDecodeError as e:
|
165 |
+
print(f"Error decoding JSON: {e}")
|
166 |
+
json_data = []
|
167 |
+
print('Extracting IP details...')
|
168 |
+
print('Extracting DNS details...')
|
169 |
+
print('Extracting EAPOL details...')
|
170 |
+
self.extract_network_info(json_data)
|
171 |
+
print('Extracting TCP STREAMS details...')
|
172 |
+
print('TCP streams can take some time..')
|
173 |
+
self.stream(service_list=self.services,
|
174 |
+
source_list=self.source_addresses,
|
175 |
+
tcp_streams_list=self.tcp_streams,
|
176 |
+
max_workers=max_workers)
|
177 |
+
print("Completed")
|
178 |
+
filtered_stream_data = self.combined_json
|
179 |
+
values = {
|
180 |
+
"PacketAnalysis": {
|
181 |
+
"Services": self.services,
|
182 |
+
"TCP Streams": self.tcp_streams,
|
183 |
+
"Sources Address": self.source_addresses,
|
184 |
+
"Destination Address": self.destination_addresses,
|
185 |
+
"DNS Resolved": self.resolved,
|
186 |
+
"DNS Query": self.dns_query_names,
|
187 |
+
"DNS Response": self.dns_resp_names,
|
188 |
+
"EAPOL Data": self.unique_eapol_data,
|
189 |
+
"Stream Data": filtered_stream_data
|
190 |
+
}
|
191 |
+
}
|
192 |
+
table_val = {
|
193 |
+
"PacketAnalysis": {
|
194 |
+
"Services": self.services,
|
195 |
+
"TCP Streams": self.tcp_streams,
|
196 |
+
"Sources Address": self.source_addresses,
|
197 |
+
"Destination Address": self.destination_addresses,
|
198 |
+
"DNS Resolved": self.resolved,
|
199 |
+
"DNS Query": self.dns_query_names,
|
200 |
+
"DNS Response": self.dns_resp_names,
|
201 |
+
"EAPOL Data": self.unique_eapol_data,
|
202 |
+
" Total Streams Data": str(len(filtered_stream_data))
|
203 |
+
}
|
204 |
+
}
|
205 |
+
table = Table(title="GVA Report for PCAP", show_header=True, header_style="bold magenta")
|
206 |
+
table.add_column("Identifiers", style="cyan")
|
207 |
+
table.add_column("Data", style="green")
|
208 |
+
|
209 |
+
flattened_data: dict = self.flatten_json(table_val, separator='.')
|
210 |
+
|
211 |
+
for key, value in flattened_data.items():
|
212 |
+
value_str = str(value)
|
213 |
+
table.add_row(key, str(value_str))
|
214 |
+
|
215 |
+
console = Console()
|
216 |
+
console.print(table)
|
217 |
+
with open(f'{save_loc}', 'w+') as file:
|
218 |
+
file.write(str(json.dumps(values)))
|
components/passbeaker.py
CHANGED
@@ -1,9 +1,3 @@
|
|
1 |
-
import hashlib
|
2 |
-
import argparse
|
3 |
-
import itertools
|
4 |
-
from multiprocessing import Pool
|
5 |
-
|
6 |
-
|
7 |
class PasswordCracker:
|
8 |
def __init__(self, password_hash, wordlist_file, algorithm, salt=None, parallel=False, complexity_check=False):
|
9 |
self.password_hash = password_hash
|
@@ -12,114 +6,15 @@ class PasswordCracker:
|
|
12 |
self.salt = salt
|
13 |
self.parallel = parallel
|
14 |
self.complexity_check = complexity_check
|
15 |
-
self.total_passwords = 0
|
16 |
-
self.matched_password = None
|
17 |
-
|
18 |
-
def crack_hash(self, word):
|
19 |
-
if self.salt:
|
20 |
-
word_with_salt = f'{self.salt}{word}'
|
21 |
-
else:
|
22 |
-
word_with_salt = word
|
23 |
-
hashed_word = hashlib.new(self.algorithm, word_with_salt.encode()).hexdigest()
|
24 |
-
if hashed_word == self.password_hash:
|
25 |
-
self.matched_password = word
|
26 |
-
return True
|
27 |
-
return False
|
28 |
-
|
29 |
-
def generate_passwords(self, min_length, max_length, character_set):
|
30 |
-
passwords = []
|
31 |
-
for length in range(min_length, max_length + 1):
|
32 |
-
for combination in itertools.product(character_set, repeat=length):
|
33 |
-
password = ''.join(combination)
|
34 |
-
passwords.append(password)
|
35 |
-
return passwords
|
36 |
-
|
37 |
-
def evaluate_complexity(self, password):
|
38 |
-
has_lowercase = False
|
39 |
-
has_uppercase = False
|
40 |
-
has_digit = False
|
41 |
-
has_special = False
|
42 |
-
|
43 |
-
for char in password:
|
44 |
-
if char.islower():
|
45 |
-
has_lowercase = True
|
46 |
-
elif char.isupper():
|
47 |
-
has_uppercase = True
|
48 |
-
elif char.isdigit():
|
49 |
-
has_digit = True
|
50 |
-
else:
|
51 |
-
has_special = True
|
52 |
-
|
53 |
-
if len(password) >= 8 and has_lowercase and has_uppercase and has_digit and has_special:
|
54 |
-
return True
|
55 |
-
return False
|
56 |
-
|
57 |
-
def crack_passwords(self, passwords):
|
58 |
-
for password in passwords:
|
59 |
-
self.total_passwords += 1
|
60 |
-
if self.crack_hash(password):
|
61 |
-
break
|
62 |
-
|
63 |
-
def crack_passwords_parallel(self, passwords):
|
64 |
-
pool = Pool()
|
65 |
-
pool.map(self.crack_password, passwords)
|
66 |
-
pool.close()
|
67 |
-
|
68 |
-
def crack_password(self, password):
|
69 |
-
if self.complexity_check and not self.evaluate_complexity(password):
|
70 |
-
return
|
71 |
-
if self.matched_password is None:
|
72 |
-
if self.crack_hash(password):
|
73 |
-
return
|
74 |
|
75 |
def crack_passwords_with_wordlist(self):
|
76 |
-
|
77 |
-
|
78 |
-
if self.parallel:
|
79 |
-
self.crack_passwords_parallel(passwords)
|
80 |
-
else:
|
81 |
-
self.crack_passwords(passwords)
|
82 |
|
83 |
def crack_passwords_with_brute_force(self, min_length, max_length, character_set):
|
84 |
-
|
85 |
-
|
86 |
-
self.crack_passwords_parallel(passwords)
|
87 |
-
else:
|
88 |
-
self.crack_passwords(passwords)
|
89 |
-
|
90 |
-
def print_statistics(self):
|
91 |
-
print(f"Total Number of Passwords Tried: {self.total_passwords}")
|
92 |
-
if self.matched_password:
|
93 |
-
print(f"Password Cracked! Password: {self.matched_password}")
|
94 |
-
else:
|
95 |
-
print("Password Failed.")
|
96 |
-
|
97 |
-
|
98 |
-
def main():
|
99 |
-
parser = argparse.ArgumentParser(description='Password cracking source PassBreaker')
|
100 |
-
parser.add_argument('password_hash', help='Password hash')
|
101 |
-
parser.add_argument('wordlist_file', help='Wordlist File')
|
102 |
-
parser.add_argument('--algorithm', choices=hashlib.algorithms_guaranteed, required=True, help='Hash algorithm')
|
103 |
-
parser.add_argument('-s', '--salt', help='Salt Value')
|
104 |
-
parser.add_argument('-p', '--parallel', action='store_true', help='Use parallel processing')
|
105 |
-
parser.add_argument('-c', '--complexity', action='store_true', help='Check for password complexity')
|
106 |
-
parser.add_argument('-b', '--brute-force', action='store_true', help='Perform a brute force attack')
|
107 |
-
parser.add_argument('--min-length', type=int, default=1, help='Minimum password length for brute force attack')
|
108 |
-
parser.add_argument('--max-length', type=int, default=6, help='Minimum password length for brute force attack')
|
109 |
-
parser.add_argument('--character-set', default='abcdefghijklmnopqrstuvwxyz0123456789',
|
110 |
-
help='Character set for brute force attack')
|
111 |
-
|
112 |
-
args = parser.parse_args()
|
113 |
-
|
114 |
-
cracker = PasswordCracker(args.password_hash, args.wordlist_file, args.algorithm, args.salt, args.parallel, args.complexity)
|
115 |
-
|
116 |
-
if args.brute_force:
|
117 |
-
cracker.crack_passwords_with_brute_force(args.min_length, args.max_length, args.character_set)
|
118 |
-
else:
|
119 |
-
cracker.crack_passwords_with_wordlist()
|
120 |
-
|
121 |
-
cracker.print_statistics()
|
122 |
-
|
123 |
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
class PasswordCracker:
|
2 |
def __init__(self, password_hash, wordlist_file, algorithm, salt=None, parallel=False, complexity_check=False):
|
3 |
self.password_hash = password_hash
|
|
|
6 |
self.salt = salt
|
7 |
self.parallel = parallel
|
8 |
self.complexity_check = complexity_check
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
def crack_passwords_with_wordlist(self):
|
11 |
+
# ?????? ??? ??????? ?????? ?? ???????
|
12 |
+
pass
|
|
|
|
|
|
|
|
|
13 |
|
14 |
def crack_passwords_with_brute_force(self, min_length, max_length, character_set):
|
15 |
+
# ?????? ??? ??????? ?????? ??????? ????????
|
16 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
def get_statistics(self):
|
19 |
+
# ????? ??? ????????? ??????????
|
20 |
+
return "Statistics data"
|
components/port_scanner.py
ADDED
File without changes
|
components/requirements.txt
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
dnspython
|
17 |
+
rich
|
18 |
+
cowsay
|
19 |
+
tk
|
20 |
+
customtkinter
|
components/scanner.py
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Optional
|
2 |
+
|
3 |
+
import nmap
|
4 |
+
nm = nmap.PortScanner()
|
5 |
+
|
6 |
+
|
7 |
+
class NetworkScanner():
|
8 |
+
def scanner(self, AIModels, ip: Optional[str], profile: int, akey: Optional[str], bkey: Optional[str], lkey, lendpoint, AI: str) -> str:
|
9 |
+
profile_arguments = {
|
10 |
+
1: '-Pn -sV -T4 -O -F',
|
11 |
+
2: '-Pn -T4 -A -v',
|
12 |
+
3: '-Pn -sS -sU -T4 -A -v',
|
13 |
+
4: '-Pn -p- -T4 -A -v',
|
14 |
+
5: '-Pn -sS -sU -T4 -A -PE -PP -PY -g 53 --script=vuln',
|
15 |
+
6: '-Pn -sV -p- -A',
|
16 |
+
7: '-Pn -sS -sV -O -T4 -A',
|
17 |
+
8: '-Pn -sC',
|
18 |
+
9: '-Pn -p 1-65535 -T4 -A -v',
|
19 |
+
10: '-Pn -sU -T4',
|
20 |
+
11: '-Pn -sV --top-ports 100',
|
21 |
+
12: '-Pn -sS -sV -T4 --script=default,discovery,vuln',
|
22 |
+
13: '-Pn -F'
|
23 |
+
}
|
24 |
+
# The scanner with GPT Implemented
|
25 |
+
nm.scan('{}'.format(ip), arguments='{}'.format(profile_arguments.get(profile)))
|
26 |
+
json_data = nm.analyse_nmap_xml_scan()
|
27 |
+
analyze = json_data["scan"]
|
28 |
+
match AI:
|
29 |
+
case 'openai':
|
30 |
+
try:
|
31 |
+
if akey is not None:
|
32 |
+
pass
|
33 |
+
else:
|
34 |
+
raise ValueError("KeyNotFound: Key Not Provided")
|
35 |
+
response = AIModels.GPT_AI(akey, analyze)
|
36 |
+
except KeyboardInterrupt:
|
37 |
+
print("Bye")
|
38 |
+
quit()
|
39 |
+
case 'bard':
|
40 |
+
try:
|
41 |
+
if bkey is not None:
|
42 |
+
pass
|
43 |
+
else:
|
44 |
+
raise ValueError("KeyNotFound: Key Not Provided")
|
45 |
+
response = AIModels.BardAI(bkey, analyze)
|
46 |
+
except KeyboardInterrupt:
|
47 |
+
print("Bye")
|
48 |
+
quit()
|
49 |
+
case 'llama':
|
50 |
+
try:
|
51 |
+
response = AIModels.Llama_AI(analyze, "local", lkey, lendpoint)
|
52 |
+
except KeyboardInterrupt:
|
53 |
+
print("Bye")
|
54 |
+
quit()
|
55 |
+
case 'llama-api':
|
56 |
+
try:
|
57 |
+
response = AIModels.Llama_AI(analyze, "runpod", lkey, lendpoint)
|
58 |
+
except KeyboardInterrupt:
|
59 |
+
print("Bye")
|
60 |
+
quit()
|
61 |
+
self.response = response
|
62 |
+
text = str(self.response)
|
63 |
+
return text
|
components/subdomain.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import dns.resolver
|
2 |
+
from rich.console import Console
|
3 |
+
from rich.progress import track
|
4 |
+
from rich.table import Table
|
5 |
+
|
6 |
+
console = Console()
|
7 |
+
|
8 |
+
|
9 |
+
class sub_enum():
|
10 |
+
def display_urls(sd_data: list[str], count: int) -> None:
|
11 |
+
console = Console()
|
12 |
+
table = Table(title=f"GVA Subdomain report. found out of {count}", show_header=True, header_style="bold")
|
13 |
+
table.add_column("Index", justify="right", style="cyan")
|
14 |
+
table.add_column("URL", style="green")
|
15 |
+
for index, url in enumerate(sd_data):
|
16 |
+
table.add_row(str(index), url)
|
17 |
+
console.print(table)
|
18 |
+
|
19 |
+
def sub_enumerator(self, target: str, list: str) -> str:
|
20 |
+
sd_data = []
|
21 |
+
s_array = []
|
22 |
+
count: int = 0
|
23 |
+
with open(list, "r") as file:
|
24 |
+
for line in file:
|
25 |
+
subdomain_key = line.strip()
|
26 |
+
s_array.append(subdomain_key)
|
27 |
+
for subd in track(s_array):
|
28 |
+
try:
|
29 |
+
ip_value = dns.resolver.resolve(f'{subd}.{target}', 'A')
|
30 |
+
if ip_value:
|
31 |
+
sd_data.append(f'{subd}.{target}')
|
32 |
+
if f"{subd}.{target}" in sd_data:
|
33 |
+
count = count + 1
|
34 |
+
else:
|
35 |
+
pass
|
36 |
+
except dns.resolver.NXDOMAIN:
|
37 |
+
pass
|
38 |
+
except dns.resolver.NoAnswer:
|
39 |
+
pass
|
40 |
+
except KeyboardInterrupt:
|
41 |
+
print('Ended')
|
42 |
+
quit()
|
43 |
+
self.display_urls(sd_data, count)
|
44 |
+
return 'Done'
|