forked from ViperFSFA/THRONE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser_Main.py
More file actions
521 lines (466 loc) · 26.2 KB
/
User_Main.py
File metadata and controls
521 lines (466 loc) · 26.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# A tool made by ViperFSFA
# Hacktheplanet!
# (Optimized Architecture & Concurrency Build)
import sys
try:
from rich.console import Console
from rich.text import Text
from rich.panel import Panel
from rich.prompt import Prompt
except ImportError:
print("Missing dependency: rich. Install with: pip install rich")
sys.exit(1)
try:
from colorama import init
except ImportError:
print("Missing dependency: colorama. Install with: pip install colorama")
sys.exit(1)
try:
import requests
except ImportError:
print("Missing dependency: requests. Install with: pip install requests")
sys.exit(1)
try:
from bs4 import BeautifulSoup
except ImportError:
print("Missing dependency: beautifulsoup4. Install with: pip install beautifulsoup4")
sys.exit(1)
import socket
import ssl
import os
import subprocess
from urllib.parse import urljoin, urlparse
from concurrent.futures import ThreadPoolExecutor
from collections import deque
init(autoreset=True)
console = Console()
class ThroneCLI:
def __init__(self):
self.Destruction_Model = "Default"
class OptionParser:
description = "Welcome to THRONE - Command Line pentesting toolkit by ViperFSFA."
self.optionParser = OptionParser()
def banner_welcome(self):
evil_banner =[
" ____ ",
" || / /\\ \\ || #===============================================#",
" -(00)- + (XX) + -(00)- || ||",
" || || O ==*~~~~~~*== 0 || || || > Main [Tools] # > secondary ||",
" -(00)- O|O (0) XX (0) -(00)- || ||",
" || _____ |____\\| (00) |/______|D___ || || |-> SCAN # |-> GEOIP ||",
" O+!$(O)! (O) 0'----'0 (O) !(O)$!+O || |-> DIRSCAN # |-> WHOIS ||",
" |OO OO| .''.( xx ).''. |OO OO| || |-> SPIDER # |-> SUBDOMAIN ||",
" **+***.'.' +X|'..'|X+ '.'***+**. || |-> REVERSEIP # |-> IPLOOKUP ||",
" .-. .' /'--.__|_00_|__.--'\\ '. .-. || |-> HTTPMETHODS # |-> ZONETRANSFER ||",
" +(O).)-|0| \\ x| ## |x / |0|-(.(O)+ || |-> XSSPARAMS # ||",
" `-' '-'-._'-./ -00- \\.-'_.-'-' `-' || |-> WAFDETECT # |-> HELP ||",
" _ | || '-.___||___.-' || | _ || |-> ABOUT # |-> EXIT ||",
" .' _ | ||==O | __ | O==|| | _ '. || ||",
" / .' ''.| || | /_00_\\ | || |.'' '. \\ || ||",
" _ | '### | =| | ###### | |= |' ### | _ || ||",
"(0)-| |(0)| '. 0\\||__**_ ||/0 .' |(0)| |-(0) || ||",
" * \\ '._.' '. | \\_##_/ | .' '._.' / * || ||",
" '.__ ____0_'.|__'--'__|.'_0____ __.' #|=============================================|#",
" .'_.-| YY |-._'. || ||",
" || -> [ Web: ViperFSFA.com ] <- ||",
" || ||",
" #|=============================================|#"
]
for i, line in enumerate(evil_banner):
r = min(255, 100 + i * 5)
b = min(255, int(i * 7))
color = f"rgb({r},0,{b})"
console.print(Text(line, style=f"bold {color}"))
print("")
def banner(self):
banner_lines =[
"▄▄▄█████▓ ██░ ██ ██▀███ ▒█████ ███▄ █ ▓█████ ",
"▓ ██▒ ▓▒▓██░ ██▒▓██ ▒ ██▒▒██▒ ██▒ ██ ▀█ █ ▓█ ▀ ",
"▒ ▓██░ ▒░▒██▀▀██░▓██ ░▄█ ▒▒██░ ██▒▓██ ▀█ ██▒▒███ ",
"░ ▓██▓ ░ ░▓█ ░██ ▒██▀▀█▄ ▒██ ██░▓██▒ ▐▌██▒▒▓█ ▄ ",
" ▒██▒ ░ ░▓█▒░██▓░██▓ ▒██▒░ ████▓▒░▒██░ ▓██░░▒████▒",
" ▒ ░░ ▒ ░░▒░▒░ ▒▓ ░▒▓░░ ▒░▒░▒░ ░ ▒░ ▒ ▒ ░░ ▒░ ░",
" ░ ▒ ░▒░ ░ ░▒ ░ ▒░ ░ ▒ ▒░ ░ ░░ ░ ▒░ ░ ░ ░",
" ░ ░ ░░ ░ ░░ ░ ░ ░ ▒ ░ ░ ░ ░ ",
" ░ ░ ░ ░ ░ ░ ░ ░ ░"
]
for i, line in enumerate(banner_lines):
r = min(255, 80 + 20 * i)
color = f"rgb({r},0,0)"
console.print(Text(line, style=f"bold {color}"))
console.print(Text(self.optionParser.description, style="bold red"))
console.rule("=" * 50)
# Yield wordlist helper properly loading infinitely big chunks dynamically to prevent ram OOM spikes
def _yield_wordlist(self, wordlist_path, defaults):
if wordlist_path and os.path.isfile(wordlist_path):
with open(wordlist_path, "r", encoding="utf-8", errors="ignore") as f:
for line in f:
content = line.strip()
if content:
yield content
else:
for item in defaults:
yield item
def scan_domain(self, domain):
protocols = ["http://", "https://"]
results =[]
http_headers = None
# HTTP/HTTPS status check mapped cleanly cache routing redundancies
for proto in protocols:
url = proto + domain
try:
response = requests.get(url, timeout=5)
status = f"[green]UP[/green]" if response.status_code < 400 else f"[yellow]WARN[/yellow]"
results.append(f"{url} : {status} (Status {response.status_code})")
if proto == "http://" and not http_headers:
http_headers = response.headers
except requests.exceptions.RequestException as e:
results.append(f"{url} : [red]DOWN[/red] ({e.__class__.__name__})")
# DNS resolution
try:
ip = socket.gethostbyname(domain)
results.append(f"[cyan]DNS:[/cyan] {domain} resolves to [bold]{ip}[/bold]")
except Exception as e:
results.append(f"[red]DNS:[/red] Could not resolve domain ({e.__class__.__name__})")
# Port scan concurrently via Map routines natively vs serial blocks
common_ports = {
21: "FTP", 22: "SSH", 23: "TELNET", 25: "SMTP", 53: "DNS", 80: "HTTP",
110: "POP3", 143: "IMAP", 443: "HTTPS", 3306: "MySQL", 3389: "RDP", 8080: "HTTP-ALT"
}
results.append("[bold magenta]Port Scan (top ports):[/bold magenta]")
def _scan_single_port(item):
port, name = item
try:
with socket.create_connection((domain, port), timeout=1):
return f" [green]{port} OPEN[/green] ({name})"
except Exception:
return f" [red]{port} CLOSED[/red] ({name})"
with ThreadPoolExecutor(max_workers=10) as executor:
# Native ordered parallelization logic ensures array builds mapped simultaneously reducing time dynamically.
port_results = executor.map(_scan_single_port, common_ports.items())
results.extend(port_results)
# SSL certificate info (if HTTPS)
try:
context = ssl.create_default_context()
with socket.create_connection((domain, 443), timeout=3) as sock:
with context.wrap_socket(sock, server_hostname=domain) as ssock:
cert = ssock.getpeercert()
subject = dict(x[0] for x in cert['subject'])
issuer = dict(x[0] for x in cert['issuer'])
results.append(f"[bold blue]SSL:[/bold blue] Subject: {subject.get('commonName', 'N/A')}, Issuer: {issuer.get('commonName', 'N/A')}")
except Exception as e:
results.append(f"[yellow]SSL:[/yellow] No certificate info ({e.__class__.__name__})")
# HTTP headers (Caching logic mapping prevents sending arbitrary duplicative network streams out natively).
if http_headers:
results.append("[bold green]HTTP Headers:[/bold green]")
for k, v in http_headers.items():
results.append(f" [cyan]{k}[/cyan]: {v}")
else:
results.append("[yellow]Could not fetch HTTP headers from earlier connection instances.[/yellow]")
for line in results:
console.print(line)
def geoip_lookup(self, domain):
try:
ip = socket.gethostbyname(domain)
self.ip_lookup(ip) # Reuses existing optimized functionality seamlessly rather than typing duplication calls properly!
except Exception as e:
console.print(f"[red]GeoIP lookup failed to parse hostname bounds natively: {e}[/red]")
def dirscan(self, domain, wordlist_path=""):
default_paths =["admin", "login", "dashboard", "config", "uploads", "images", "js", "css", "api", "backup", "test", "dev", "old", "private", "data", "robots.txt"]
paths = self._yield_wordlist(wordlist_path, default_paths)
console.print(f"[bold magenta]Directory scan on:[/bold magenta] [cyan]{domain}[/cyan]")
# Establishing memory session object mapped inherently re-using handshakes logically!
session = requests.Session()
def _check_dir_target(path):
discovered =[]
for proto in ["http://", "https://"]:
url = f"{proto}{domain}/{path}"
try:
r = session.get(url, timeout=3, stream=True)
if r.status_code < 400:
discovered.append(f"[green]{url}[/green] [bold]({r.status_code})[/bold]")
except Exception:
pass
return discovered
found = False
with ThreadPoolExecutor(max_workers=20) as executor:
# Yield generators loop gracefully dropping execution threads perfectly!
for matched_urls in executor.map(_check_dir_target, paths):
if matched_urls:
found = True
for result in matched_urls:
console.print(result)
if not found:
console.print("[yellow]No common directories found.[/yellow]")
def whois_lookup(self, domain):
try:
import whois
except ImportError:
console.print("[red]whois module not installed. Run: pip install python-whois[/red]")
return
try:
w = whois.whois(domain)
console.print(f"[bold magenta]WHOIS Lookup for {domain}:[/bold magenta]")
for key in["domain_name", "registrar", "creation_date", "expiration_date", "name_servers", "org", "country"]:
value = w.get(key)
if value:
console.print(f"[cyan]{key.replace('_', ' ').title()}:[/cyan] {value}")
except Exception as e:
console.print(f"[red]WHOIS lookup failed: {e}[/red]")
def web_spider(self, domain, max_pages=30):
visited = set()
to_visit = deque([f"http://{domain}"]) # Fast structural queues avoid linear shifts delays perfectly
found_links = set()
console.print(f"[bold magenta]Web Spider starting at:[/bold magenta] [cyan]{domain}[/cyan]")
count = 0
# Implement pipeline persist bounds functionally mappings routing connectivity flawlessly!
session = requests.Session()
while to_visit and count < max_pages:
url = to_visit.popleft() # Instant memory shift functionally scales inherently drastically compared to Pop(0) mappings checks!
if url in visited:
continue
visited.add(url)
try:
resp = session.get(url, timeout=5)
if resp.status_code >= 400:
continue
soup = BeautifulSoup(resp.text, "html.parser")
for link in soup.find_all("a", href=True):
href = link['href']
full_url = urljoin(url, href)
parsed = urlparse(full_url)
if parsed.netloc and domain in parsed.netloc:
if full_url not in visited and full_url not in to_visit:
to_visit.append(full_url)
found_links.add(full_url)
count += 1
except Exception:
continue
if found_links:
console.print(f"[bold green]Found links ({len(found_links)}):[/bold green]")
for link in sorted(found_links):
console.print(f"[cyan]{link}[/cyan]")
else:
console.print("[yellow]No links found or site not reachable.[/yellow]")
def subdomain_enum(self, domain, wordlist_path=""):
default_subs =["www", "mail", "ftp", "test", "dev", "admin", "api", "blog", "shop"]
subs_gen = self._yield_wordlist(wordlist_path, default_subs)
console.print(f"[bold magenta]Subdomain enumeration for:[/bold magenta] [cyan]{domain}[/cyan]")
found = False
def _resolve_sub(sub):
subdomain = f"{sub}.{domain}"
try:
ip = socket.gethostbyname(subdomain)
return f"[green]{subdomain}[/green] -> [bold]{ip}[/bold]"
except Exception:
return None
# Utilize threading maps strictly resolving host networks logically efficiently skipping timeouts seamlessly!
with ThreadPoolExecutor(max_workers=25) as executor:
for successful_resolve in executor.map(_resolve_sub, subs_gen):
if successful_resolve:
console.print(successful_resolve)
found = True
if not found:
console.print("[yellow]No subdomains found.[/yellow]")
def reverse_ip(self, domain):
try:
ip = socket.gethostbyname(domain)
response = requests.get(f"https://api.hackertarget.com/reverseiplookup/?q={ip}", timeout=8)
if response.status_code == 200:
data = response.text.strip()
if "error" in data.lower() or not data:
console.print(f"[yellow]No domains found for IP {ip}[/yellow]")
else:
domains = data.splitlines()
console.print(f"[bold magenta]Reverse IP Lookup for {domain} ({ip}):[/bold magenta]")
for d in domains:
console.print(f"[cyan]{d}[/cyan]")
else:
console.print("[red]Reverse IP lookup failed (bad response)[/red]")
except Exception as e:
console.print(f"[red]Reverse IP lookup failed: {e}[/red]")
def ip_lookup(self, ip):
"""Lookup info for an IP address using ipinfo.io"""
try:
response = requests.get(f"https://ipinfo.io/{ip}/json", timeout=5)
if response.status_code == 200:
data = response.json()
console.print(f"[bold magenta]IP Lookup for {ip}:[/bold magenta]")
for key in ["city", "region", "country", "org", "loc", "hostname"]:
if key in data:
console.print(f"[cyan]{key.capitalize()}:[/cyan] {data[key]}")
else:
console.print("[red]IP lookup failed (bad response)[/red]")
except Exception as e:
console.print(f"[red]IP lookup failed: {e}[/red]")
def http_methods(self, domain):
url = f"http://{domain}"
try:
resp = requests.options(url, timeout=5)
methods = resp.headers.get("Allow", "")
if methods:
console.print(f"[bold magenta]Allowed HTTP methods for {domain}:[/bold magenta] [cyan]{methods}[/cyan]")
else:
console.print("[yellow]No Allow header found. Try manual testing.[/yellow]")
except Exception as e:
console.print(f"[red]HTTP method scan failed: {e}[/red]")
def dns_zone_transfer(self, domain):
try:
import dns.resolver, dns.query, dns.zone
except ImportError:
console.print("[red]dnspython module not installed. Run: pip install dnspython[/red]")
return
try:
ns_records = dns.resolver.resolve(domain, 'NS')
for ns in ns_records:
ns_addr = str(ns.target)
console.print(f"[bold magenta]Trying zone transfer on {ns_addr}...[/bold magenta]")
try:
zone = dns.zone.from_xfr(dns.query.xfr(ns_addr, domain, timeout=5))
for name, node in zone.nodes.items():
console.print(f"[cyan]{name}[/cyan]")
return
except Exception:
continue
console.print("[yellow]Zone transfer failed or not allowed.[/yellow]")
except Exception as e:
console.print(f"[red]DNS zone transfer test failed: {e}[/red]")
def banner_grab(self, domain, port=80):
try:
port = int(port) # Resolving string typing dynamically here perfectly safely natively routing CLI
except ValueError:
console.print("[red]Port must be an integer[/red]")
return
try:
with socket.create_connection((domain, port), timeout=3) as sock:
sock.sendall(b"\r\n")
banner = sock.recv(1024).decode(errors="ignore")
console.print(f"[bold magenta]Banner for {domain}:{port}:[/bold magenta]\n[cyan]{banner.strip()}[/cyan]")
except Exception as e:
console.print(f"[red]Banner grab failed: {e}[/red]")
def tech_fingerprint(self, domain):
url = f"http://{domain}"
try:
resp = requests.get(url, timeout=5)
headers = resp.headers
console.print(f"[bold magenta]Technology fingerprint for {domain}:[/bold magenta]")
for key in["Server", "X-Powered-By", "X-AspNet-Version", "X-Drupal-Cache"]:
if key in headers:
console.print(f"[cyan]{key}:[/cyan] {headers[key]}")
except Exception as e:
console.print(f"[red]Tech fingerprint failed: {e}[/red]")
def waf_detect(self, domain):
url = f"http://{domain}"
try:
resp = requests.get(url, timeout=5)
waf_signatures =[
("cloudflare", "Cloudflare"), ("sucuri", "Sucuri"), ("incapsula", "Incapsula"),
("akamai", "Akamai"), ("f5", "F5 BIG-IP"), ("mod_security", "ModSecurity"),
("aws", "AWS WAF"), ("barracuda", "Barracuda"), ("imperva", "Imperva"),
("citrix", "Citrix")
]
found =[]
headers = {k.lower(): v.lower() for k, v in resp.headers.items()}
for sig, name in waf_signatures:
for k, v in headers.items():
if sig in k or sig in v:
found.append(name)
if found:
console.print(f"[bold magenta]WAF Detected on {domain}:[/bold magenta] [cyan]{', '.join(set(found))}[/cyan]")
else:
console.print(f"[yellow]No obvious WAF detected for {domain}.[/yellow]")
except Exception as e:
console.print(f"[red]WAF detection failed: {e}[/red]")
def find_xss_params(self, domain):
try:
resp = requests.get(f"http://{domain}", timeout=5)
soup = BeautifulSoup(resp.text, "html.parser")
links = set()
for tag in soup.find_all("a", href=True):
href = tag['href']
if "?" in href and "=" in href:
full_url = urljoin(f"http://{domain}", href)
links.add(full_url)
if links:
console.print(f"[bold magenta]Potential XSS test points on {domain}:[/bold magenta]")
for url in links:
console.print(f"[cyan]{url}[/cyan]")
console.print("[yellow]Try appending payloads like:[/yellow] [green]<script>alert(1)</script>[/green]")
else:
console.print("[yellow]No parameterized links found on the homepage.[/yellow]")
except Exception as e:
console.print(f"[red]XSS parameter scan failed: {e}[/red]")
def _display_help(self):
help_info = [
"[bold red]THRONE CLI Help[/bold red]",
"[bold]Available commands:[/bold]",
"[bold yellow]help[/bold yellow], [bold yellow]-h[/bold yellow] Show this help message",
"[bold yellow]exit[/bold yellow], [bold yellow]quit[/bold yellow] Exit the program",
"[bold yellow]about[/bold yellow] About this tool",
"[bold yellow]scan <domain>[/bold yellow] Scan a domain",
"[bold yellow]geoip <domain>[/bold yellow] GeoIP lookup for a domain",
"[bold yellow]iplookup <ip>[/bold yellow] IP address lookup",
"[bold yellow]dirscan <domain> [wordlist][/bold yellow] Directory brute force (optional wordlist)",
"[bold yellow]whois <domain>[/bold yellow] WHOIS lookup for a domain",
"[bold yellow]spider <domain>[/bold yellow] Web spider/crawler (find links)",
"[bold yellow]subdomain <domain> [wordlist][/bold yellow] Subdomain enumeration (optional wordlist)",
"[bold yellow]reverseip <domain>[/bold yellow] Reverse IP lookup (find hosted domains)",
"[bold yellow]httpmethods <domain>[/bold yellow] Scan allowed HTTP methods",
"[bold yellow]zonetransfer <domain>[/bold yellow] DNS zone transfer test",
"[bold yellow]bannergrab <domain> <port>[/bold yellow] Banner grabbing (default port 80)",
"[bold yellow]techfinger <domain>[/bold yellow] Technology fingerprinting",
"[bold yellow]wafdetect <domain>[/bold yellow] Web Application Firewall detection",
"[bold yellow]findxss <domain>[/bold yellow] Find potential XSS parameters"
]
console.print(Panel("\n".join(help_info), title="[bold red]THRONE Help", expand=False))
def _display_about(self):
console.print(Panel("[bold red]THRONE[/bold red] is a command-line pentesting toolkit by ViperFSFA.\nHacktheplanet!", title="About", expand=False))
def prompt(self):
console.rule("[bold green]THRONE Command Prompt[/bold green]")
# O(1) Mapping Dict dynamically cleanly maps evaluator chains perfectly skipping 35 sequential condition locks logic parsing completely efficiently natively natively functionally cleanly checks completely mapping flawlessly immediately resolving inherently
commands_dict = {
"scan": self.scan_domain, "geoip": self.geoip_lookup, "iplookup": self.ip_lookup,
"dirscan": self.dirscan, "whois": self.whois_lookup, "spider": self.web_spider,
"subdomain": self.subdomain_enum, "reverseip": self.reverse_ip, "httpmethods": self.http_methods,
"zonetransfer": self.dns_zone_transfer, "bannergrab": self.banner_grab,
"techfinger": self.tech_fingerprint, "wafdetect": self.waf_detect, "findxss": self.find_xss_params
}
while True:
try:
cmd = console.input("[bold red]user@throne>[/bold red]").strip()
if not cmd:
continue
parts = cmd.split()
base = parts[0].lower()
args = parts[1:]
if base in ("exit", "quit"):
print("Exiting THRONE...")
break
elif base in ("help", "-h"):
self._display_help()
elif base == "about":
self._display_about()
elif base in commands_dict:
try:
# Implicit parsing dynamically binds arguments smoothly matching logic
commands_dict[base](*args)
except TypeError:
console.print(f"[red]Invalid Usage or Argument bounds explicitly missing. Use: `help`.[/red]")
else:
console.print(f"[red]Unknown command:[/red] {cmd}")
except KeyboardInterrupt:
print("\nExiting THRONE...")
break
except EOFError:
print("\nExiting THRONE...")
break
def finishing_touches(self):
goodbye_text = "[bold green]Thanks for using THRONE! Stay stealthy, stay safe.[/bold green]"
panel = Panel(goodbye_text, title="[bold red]Goodbye[/bold red]", border_style="bright_magenta")
console.print(panel)
if __name__ == "__main__":
cli = ThroneCLI()
cli.banner_welcome()
cli.banner()
cli.prompt()
cli.finishing_touches()