cybortx 2.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- core/__init__.py +0 -0
- core/engine.py +108 -0
- core/origin.py +130 -0
- core/scanner.py +95 -0
- core/validator.py +67 -0
- cybortx-2.1.0.dist-info/METADATA +6 -0
- cybortx-2.1.0.dist-info/RECORD +14 -0
- cybortx-2.1.0.dist-info/WHEEL +5 -0
- cybortx-2.1.0.dist-info/entry_points.txt +2 -0
- cybortx-2.1.0.dist-info/top_level.txt +3 -0
- cybortx.py +68 -0
- utils/__init__.py +0 -0
- utils/reporter.py +31 -0
- utils/ui.py +36 -0
core/__init__.py
ADDED
|
File without changes
|
core/engine.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import socket
|
|
2
|
+
import ssl
|
|
3
|
+
import concurrent.futures
|
|
4
|
+
|
|
5
|
+
from utils.ui import C_GREEN, C_YELLOW, C_RESET, C_DIM
|
|
6
|
+
|
|
7
|
+
TOP_PORTS = [
|
|
8
|
+
21, 22, 23, 25, 53, 80, 110, 111, 135, 139, 143, 443, 445, 993, 995,
|
|
9
|
+
1723, 3306, 3389, 5900, 8080, 8443, 20, 69, 79, 88, 102, 110, 119,
|
|
10
|
+
123, 137, 138, 161, 162, 179, 389, 427, 443, 444, 465, 500, 512,
|
|
11
|
+
513, 514, 515, 520, 548, 554, 587, 623, 626, 631, 636, 646, 873,
|
|
12
|
+
990, 993, 995, 1025, 1026, 1027, 1028, 1029, 1080, 1194, 1433,
|
|
13
|
+
1434, 1521, 1701, 1723, 1755, 1812, 1813, 1883, 1900, 2000, 2049,
|
|
14
|
+
2082, 2083, 2086, 2087, 2095, 2096, 2222, 2483, 2484, 3000, 3128,
|
|
15
|
+
3260, 3306, 3389, 3689, 3690, 4000, 4369, 5000, 5060, 5222, 5269,
|
|
16
|
+
5353, 5432, 5555, 5601, 5672, 5900, 5901, 5984, 6000, 6379, 6667,
|
|
17
|
+
7000, 7077, 8000, 8008, 8080, 8081, 8443, 8888, 9000, 9090, 9200,
|
|
18
|
+
9300, 10000, 11211, 27017, 27018, 50000, 50070
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
SERVICES = {
|
|
22
|
+
20: "ftp-data", 21: "ftp", 22: "ssh", 23: "telnet", 25: "smtp",
|
|
23
|
+
53: "dns", 80: "http", 110: "pop3", 111: "rpcbind", 135: "msrpc",
|
|
24
|
+
139: "netbios-ssn", 143: "imap", 443: "https", 445: "smb", 465: "smtps",
|
|
25
|
+
587: "smtp-submission", 993: "imaps", 995: "pop3s", 1723: "pptp",
|
|
26
|
+
2082: "cpanel", 2083: "cpanel-ssl", 2086: "whm", 2087: "whm-ssl",
|
|
27
|
+
2095: "webmail", 2096: "webmail-ssl", 3306: "mysql", 3389: "rdp",
|
|
28
|
+
5432: "postgresql", 5900: "vnc", 6379: "redis", 8080: "http-proxy",
|
|
29
|
+
8443: "https-alt", 27017: "mongodb"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
SSL_PORTS = [443, 465, 993, 995, 2083, 2087, 2096, 8443]
|
|
33
|
+
WEB_PORTS = [80, 443, 8080, 8000, 8008, 2082, 2083, 2086, 2087, 2095, 2096, 8443]
|
|
34
|
+
|
|
35
|
+
def parse_ports(port_str):
|
|
36
|
+
if not port_str or port_str.lower() == "top":
|
|
37
|
+
return sorted(list(set(TOP_PORTS)))
|
|
38
|
+
|
|
39
|
+
ports = set()
|
|
40
|
+
for part in port_str.split(","):
|
|
41
|
+
part = part.strip()
|
|
42
|
+
if "-" in part:
|
|
43
|
+
try:
|
|
44
|
+
start, end = part.split("-")
|
|
45
|
+
ports.update(range(int(start), int(end) + 1))
|
|
46
|
+
except ValueError:
|
|
47
|
+
return []
|
|
48
|
+
else:
|
|
49
|
+
try:
|
|
50
|
+
ports.add(int(part))
|
|
51
|
+
except ValueError:
|
|
52
|
+
return []
|
|
53
|
+
|
|
54
|
+
return sorted([p for p in ports if 1 <= p <= 65535])
|
|
55
|
+
|
|
56
|
+
def scan_and_grab(ip, port, timeout=1.5):
|
|
57
|
+
try:
|
|
58
|
+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
59
|
+
s.settimeout(timeout)
|
|
60
|
+
result = s.connect_ex((ip, port))
|
|
61
|
+
|
|
62
|
+
if result != 0:
|
|
63
|
+
s.close()
|
|
64
|
+
return port, False, None
|
|
65
|
+
|
|
66
|
+
banner = None
|
|
67
|
+
try:
|
|
68
|
+
if port in SSL_PORTS:
|
|
69
|
+
context = ssl.create_default_context()
|
|
70
|
+
context.check_hostname = False
|
|
71
|
+
context.verify_mode = ssl.CERT_NONE
|
|
72
|
+
s = context.wrap_socket(s, server_hostname=ip)
|
|
73
|
+
|
|
74
|
+
if port in WEB_PORTS:
|
|
75
|
+
req = f"GET / HTTP/1.1\r\nHost: {ip}\r\nUser-Agent: Mozilla/5.0\r\nConnection: close\r\n\r\n"
|
|
76
|
+
s.sendall(req.encode())
|
|
77
|
+
|
|
78
|
+
data = s.recv(1024)
|
|
79
|
+
if data:
|
|
80
|
+
banner = data.decode('utf-8', errors='ignore').strip().split('\n')[0]
|
|
81
|
+
if len(banner) > 70:
|
|
82
|
+
banner = banner[:70] + "..."
|
|
83
|
+
except Exception:
|
|
84
|
+
pass
|
|
85
|
+
|
|
86
|
+
s.close()
|
|
87
|
+
return port, True, banner
|
|
88
|
+
except Exception:
|
|
89
|
+
return port, False, None
|
|
90
|
+
|
|
91
|
+
def run_scanner(ip, ports):
|
|
92
|
+
open_ports = []
|
|
93
|
+
|
|
94
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=50) as executor:
|
|
95
|
+
futures = {executor.submit(scan_and_grab, ip, port): port for port in ports}
|
|
96
|
+
|
|
97
|
+
for future in concurrent.futures.as_completed(futures):
|
|
98
|
+
port, is_open, banner_text = future.result()
|
|
99
|
+
if is_open:
|
|
100
|
+
open_ports.append(port)
|
|
101
|
+
service_name = SERVICES.get(port, "unknown")
|
|
102
|
+
|
|
103
|
+
print(f"{C_GREEN}[+]{C_RESET} {C_BOLD if 'C_BOLD' in globals() else ''}{ip}:{port}{C_RESET} [OPEN] - {C_YELLOW}{service_name}{C_RESET}")
|
|
104
|
+
|
|
105
|
+
if banner_text:
|
|
106
|
+
print(f" {C_DIM}└─ {banner_text}{C_RESET}")
|
|
107
|
+
|
|
108
|
+
return open_ports
|
core/origin.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import socket
|
|
2
|
+
import ssl
|
|
3
|
+
import ipaddress
|
|
4
|
+
import requests
|
|
5
|
+
import re
|
|
6
|
+
from utils.ui import C_GREEN, C_YELLOW, C_RED, C_RESET, C_DIM, C_CYAN, C_BOLD
|
|
7
|
+
|
|
8
|
+
# Official Cloudflare IPv4 ranges (can be fetched dynamically, hardcoded for reliability)
|
|
9
|
+
CLOUDFLARE_CIDRS = [
|
|
10
|
+
"103.21.244.0/22", "103.22.200.0/22", "103.31.4.0/22", "104.16.0.0/13",
|
|
11
|
+
"104.24.0.0/14", "108.162.192.0/18", "131.0.72.0/22", "141.101.64.0/18",
|
|
12
|
+
"162.158.0.0/15", "172.64.0.0/13", "173.245.48.0/20", "188.114.96.0/20",
|
|
13
|
+
"190.93.240.0/20", "197.234.240.0/22", "198.41.128.0/17"
|
|
14
|
+
]
|
|
15
|
+
CLOUDFLARE_NETS = [ipaddress.ip_network(cidr) for cidr in CLOUDFLARE_CIDRS]
|
|
16
|
+
|
|
17
|
+
def is_cloudflare_ip(ip_str):
|
|
18
|
+
try:
|
|
19
|
+
ip = ipaddress.ip_address(ip_str)
|
|
20
|
+
return any(ip in net for net in CLOUDFLARE_NETS)
|
|
21
|
+
except ValueError:
|
|
22
|
+
return False
|
|
23
|
+
|
|
24
|
+
def get_candidates_from_crtsh(domain):
|
|
25
|
+
candidates = set()
|
|
26
|
+
try:
|
|
27
|
+
r = requests.get(f"https://crt.sh/?q=%25.{domain}&output=json", timeout=15)
|
|
28
|
+
if r.status_code == 200:
|
|
29
|
+
for entry in r.json():
|
|
30
|
+
for sub in entry.get('name_value', '').split('\n'):
|
|
31
|
+
sub = sub.strip().lower()
|
|
32
|
+
if sub and '*' not in sub:
|
|
33
|
+
try:
|
|
34
|
+
ip = socket.gethostbyname(sub)
|
|
35
|
+
if not is_cloudflare_ip(ip):
|
|
36
|
+
candidates.add(ip)
|
|
37
|
+
except socket.gaierror:
|
|
38
|
+
pass
|
|
39
|
+
except Exception:
|
|
40
|
+
pass
|
|
41
|
+
return candidates
|
|
42
|
+
|
|
43
|
+
def get_candidates_from_spf(domain):
|
|
44
|
+
candidates = set()
|
|
45
|
+
try:
|
|
46
|
+
import dns.resolver
|
|
47
|
+
answers = dns.resolver.resolve(domain, 'TXT')
|
|
48
|
+
for rdata in answers:
|
|
49
|
+
txt = b''.join(rdata.strings).decode('utf-8', errors='ignore')
|
|
50
|
+
if 'v=spf1' in txt:
|
|
51
|
+
for match in re.finditer(r'ip[46]:([0-9a-fA-F.:]+)', txt):
|
|
52
|
+
ip = match.group(1)
|
|
53
|
+
if not is_cloudflare_ip(ip):
|
|
54
|
+
candidates.add(ip)
|
|
55
|
+
except Exception:
|
|
56
|
+
pass
|
|
57
|
+
return candidates
|
|
58
|
+
|
|
59
|
+
def get_candidates_from_mx(domain):
|
|
60
|
+
candidates = set()
|
|
61
|
+
try:
|
|
62
|
+
import dns.resolver
|
|
63
|
+
answers = dns.resolver.resolve(domain, 'MX')
|
|
64
|
+
for rdata in answers:
|
|
65
|
+
mx_host = str(rdata.exchange).rstrip('.')
|
|
66
|
+
try:
|
|
67
|
+
ip = socket.gethostbyname(mx_host)
|
|
68
|
+
if not is_cloudflare_ip(ip):
|
|
69
|
+
candidates.add(ip)
|
|
70
|
+
except socket.gaierror:
|
|
71
|
+
pass
|
|
72
|
+
except Exception:
|
|
73
|
+
pass
|
|
74
|
+
return candidates
|
|
75
|
+
|
|
76
|
+
def verify_origin(ip, domain, timeout=3):
|
|
77
|
+
try:
|
|
78
|
+
headers = {"Host": domain, "User-Agent": "Mozilla/5.0"}
|
|
79
|
+
r = requests.get(f"http://{ip}/", headers=headers, timeout=timeout, allow_redirects=False)
|
|
80
|
+
if r.status_code in [200, 301, 302, 403]:
|
|
81
|
+
return True, r.status_code
|
|
82
|
+
except Exception:
|
|
83
|
+
pass
|
|
84
|
+
return False, None
|
|
85
|
+
|
|
86
|
+
def find_origin(domain):
|
|
87
|
+
print(f"\n{C_CYAN}[*]{C_RESET} Checking if {domain} is behind Cloudflare...")
|
|
88
|
+
try:
|
|
89
|
+
resolved_ip = socket.gethostbyname(domain)
|
|
90
|
+
except socket.gaierror:
|
|
91
|
+
print(f"{C_RED}[-]{C_RESET} Could not resolve {domain}")
|
|
92
|
+
return None
|
|
93
|
+
|
|
94
|
+
if not is_cloudflare_ip(resolved_ip):
|
|
95
|
+
print(f"{C_DIM} Not behind Cloudflare (resolved to {resolved_ip}).{C_RESET}")
|
|
96
|
+
return resolved_ip
|
|
97
|
+
|
|
98
|
+
print(f"{C_YELLOW}[!]{C_RESET} Cloudflare detected ({resolved_ip}). Searching for origin...")
|
|
99
|
+
|
|
100
|
+
candidates = set()
|
|
101
|
+
print(f"{C_DIM} - Querying crt.sh...{C_RESET}")
|
|
102
|
+
candidates.update(get_candidates_from_crtsh(domain))
|
|
103
|
+
print(f"{C_DIM} - Parsing SPF records...{C_RESET}")
|
|
104
|
+
candidates.update(get_candidates_from_spf(domain))
|
|
105
|
+
print(f"{C_DIM} - Checking MX records...{C_RESET}")
|
|
106
|
+
candidates.update(get_candidates_from_mx(domain))
|
|
107
|
+
|
|
108
|
+
if not candidates:
|
|
109
|
+
print(f"{C_RED}[-]{C_RESET} No candidate IPs found.")
|
|
110
|
+
return None
|
|
111
|
+
|
|
112
|
+
print(f"{C_GREEN}[+]{C_RESET} Found {len(candidates)} candidate(s). Verifying...")
|
|
113
|
+
|
|
114
|
+
verified = []
|
|
115
|
+
for ip in candidates:
|
|
116
|
+
success, status = verify_origin(ip, domain)
|
|
117
|
+
if success:
|
|
118
|
+
verified.append((ip, status))
|
|
119
|
+
print(f" {C_GREEN}✓{C_RESET} {C_BOLD}{ip}{C_RESET} (HTTP {status})")
|
|
120
|
+
else:
|
|
121
|
+
print(f" {C_DIM}✗ {ip} (no web response){C_RESET}")
|
|
122
|
+
|
|
123
|
+
if verified:
|
|
124
|
+
print(f"\n{C_GREEN}[+]{C_RESET} Origin candidate(s) found:")
|
|
125
|
+
for ip, status in verified:
|
|
126
|
+
print(f" {C_BOLD}{ip}{C_RESET} (HTTP {status})")
|
|
127
|
+
return verified[0][0]
|
|
128
|
+
else:
|
|
129
|
+
print(f"{C_RED}[-]{C_RESET} Could not verify any origin IP.")
|
|
130
|
+
return None
|
core/scanner.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import ipaddress
|
|
3
|
+
import socket
|
|
4
|
+
import time
|
|
5
|
+
from typing import Iterable
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
DEFAULT_PORTS = [
|
|
9
|
+
21, 22, 23, 25, 53, 80, 110, 111, 135, 139, 143, 443, 445,
|
|
10
|
+
993, 995, 1433, 1521, 1723, 2049, 2082, 2083, 2181, 2375,
|
|
11
|
+
2376, 3000, 3128, 3306, 3389, 4444, 5000, 5432, 5555, 5601,
|
|
12
|
+
5672, 5900, 5984, 6379, 6443, 7001, 7077, 8000, 8008, 8080,
|
|
13
|
+
8081, 8443, 8888, 9000, 9090, 9200, 9300, 10000, 11211,
|
|
14
|
+
27017, 27018, 50000, 50070,
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def parse_targets(target: str) -> list[str]:
|
|
19
|
+
"""Accept IP, CIDR, hostname, or comma-separated list."""
|
|
20
|
+
targets = []
|
|
21
|
+
for part in target.split(","):
|
|
22
|
+
part = part.strip()
|
|
23
|
+
if not part:
|
|
24
|
+
continue
|
|
25
|
+
try:
|
|
26
|
+
net = ipaddress.ip_network(part, strict=False)
|
|
27
|
+
targets.extend(str(ip) for ip in net.hosts())
|
|
28
|
+
continue
|
|
29
|
+
except ValueError:
|
|
30
|
+
pass
|
|
31
|
+
try:
|
|
32
|
+
infos = socket.getaddrinfo(part, None)
|
|
33
|
+
ips = sorted({i[4][0] for i in infos})
|
|
34
|
+
targets.extend(ips)
|
|
35
|
+
except socket.gaierror:
|
|
36
|
+
raise ValueError(f"Cannot resolve target: {part}")
|
|
37
|
+
return targets
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def parse_ports(spec: str) -> list[int]:
|
|
41
|
+
"""Accept '80', '1-1000', '22,80,443', or 'top'."""
|
|
42
|
+
if spec.lower() == "top":
|
|
43
|
+
return DEFAULT_PORTS
|
|
44
|
+
ports = set()
|
|
45
|
+
for chunk in spec.split(","):
|
|
46
|
+
chunk = chunk.strip()
|
|
47
|
+
if "-" in chunk:
|
|
48
|
+
a, b = chunk.split("-", 1)
|
|
49
|
+
ports.update(range(int(a), int(b) + 1))
|
|
50
|
+
else:
|
|
51
|
+
ports.add(int(chunk))
|
|
52
|
+
return sorted(p for p in ports if 1 <= p <= 65535)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
async def _check_port(ip: str, port: int, timeout: float) -> tuple[int, float] | None:
|
|
56
|
+
start = time.perf_counter()
|
|
57
|
+
try:
|
|
58
|
+
reader, writer = await asyncio.wait_for(
|
|
59
|
+
asyncio.open_connection(ip, port), timeout=timeout
|
|
60
|
+
)
|
|
61
|
+
latency = (time.perf_counter() - start) * 1000
|
|
62
|
+
writer.close()
|
|
63
|
+
try:
|
|
64
|
+
await writer.wait_closed()
|
|
65
|
+
except Exception:
|
|
66
|
+
pass
|
|
67
|
+
return port, round(latency, 2)
|
|
68
|
+
except (asyncio.TimeoutError, ConnectionRefusedError, OSError):
|
|
69
|
+
return None
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
async def _scan_ip(ip: str, ports: Iterable[int], concurrency: int, timeout: float):
|
|
73
|
+
sem = asyncio.Semaphore(concurrency)
|
|
74
|
+
|
|
75
|
+
async def limited(p):
|
|
76
|
+
async with sem:
|
|
77
|
+
return await _check_port(ip, p, timeout)
|
|
78
|
+
|
|
79
|
+
results = await asyncio.gather(*(limited(p) for p in ports))
|
|
80
|
+
return ip, [r for r in results if r]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
async def scan_async(targets: list[str], ports: list[int],
|
|
84
|
+
concurrency: int = 1000, timeout: float = 1.0,
|
|
85
|
+
on_ip_done=None) -> dict:
|
|
86
|
+
sem = asyncio.Semaphore(concurrency)
|
|
87
|
+
|
|
88
|
+
async def run(ip):
|
|
89
|
+
res = await _scan_ip(ip, ports, concurrency, timeout)
|
|
90
|
+
if on_ip_done:
|
|
91
|
+
on_ip_done(*res)
|
|
92
|
+
return res
|
|
93
|
+
|
|
94
|
+
all_results = await asyncio.gather(*(run(ip) for ip in targets))
|
|
95
|
+
return {ip: open_ports for ip, open_ports in all_results if open_ports}
|
core/validator.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from urllib.parse import urlsplit
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def validate_domain(value):
|
|
6
|
+
|
|
7
|
+
if not isinstance(value, str):
|
|
8
|
+
return None
|
|
9
|
+
|
|
10
|
+
value = value.strip()
|
|
11
|
+
|
|
12
|
+
if not value or any(ord(c) < 32 for c in value):
|
|
13
|
+
return None
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
if "://" not in value:
|
|
17
|
+
value = "//" + value
|
|
18
|
+
|
|
19
|
+
parsed = urlsplit(value)
|
|
20
|
+
|
|
21
|
+
if parsed.scheme and parsed.scheme.lower() not in (
|
|
22
|
+
"http", "https"
|
|
23
|
+
):
|
|
24
|
+
return None
|
|
25
|
+
|
|
26
|
+
if parsed.username or parsed.password:
|
|
27
|
+
return None
|
|
28
|
+
|
|
29
|
+
host = parsed.hostname
|
|
30
|
+
|
|
31
|
+
if not host:
|
|
32
|
+
return None
|
|
33
|
+
|
|
34
|
+
# Validate supplied port.
|
|
35
|
+
if parsed.port is not None:
|
|
36
|
+
if not 1 <= parsed.port <= 65535:
|
|
37
|
+
return None
|
|
38
|
+
|
|
39
|
+
# Convert internationalized domains.
|
|
40
|
+
domain = host.rstrip(".").encode("idna").decode("ascii").lower()
|
|
41
|
+
|
|
42
|
+
if len(domain) > 253:
|
|
43
|
+
return None
|
|
44
|
+
|
|
45
|
+
labels = domain.split(".")
|
|
46
|
+
|
|
47
|
+
if len(labels) < 2:
|
|
48
|
+
return None
|
|
49
|
+
|
|
50
|
+
for label in labels:
|
|
51
|
+
if (
|
|
52
|
+
not label
|
|
53
|
+
or len(label) > 63
|
|
54
|
+
or not re.fullmatch(
|
|
55
|
+
r"[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",
|
|
56
|
+
label
|
|
57
|
+
)
|
|
58
|
+
):
|
|
59
|
+
return None
|
|
60
|
+
|
|
61
|
+
if not re.fullmatch(r"[a-z]{2,63}", labels[-1]):
|
|
62
|
+
return None
|
|
63
|
+
|
|
64
|
+
return domain
|
|
65
|
+
|
|
66
|
+
except (ValueError, UnicodeError):
|
|
67
|
+
return None
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
cybortx.py,sha256=KmXT1Bu_8oetUShLyUQNSY7dajfUW2_MdrW0xQitgt0,2292
|
|
2
|
+
core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
core/engine.py,sha256=JZRRKI4SdXuDO5DoVkUZRWRQd91cJHZ1Nkbzpp0PQ78,4159
|
|
4
|
+
core/origin.py,sha256=vrHJ1ffqyowsKX0iHfE4ARYyo030_K7pBQoNhGXksU0,4693
|
|
5
|
+
core/scanner.py,sha256=kyLczESmlxx4vaZM2CQye7md2QqoeB8Hyxmzh4hLCjk,3010
|
|
6
|
+
core/validator.py,sha256=M_vpdsqv9_5OptyayJGo-hkbvpgA8S7XdjKUiObDmdE,1474
|
|
7
|
+
utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
utils/reporter.py,sha256=hZ_grvYoIDauO3ATPUWMbLgmN4834NSdvWlFToFdoyI,980
|
|
9
|
+
utils/ui.py,sha256=UGZHC-E_pCBcCXX9O3ugQatVaeF7tezu3bHOrzUqtd0,1249
|
|
10
|
+
cybortx-2.1.0.dist-info/METADATA,sha256=nxzp4O2TX94InVupqm482XgGGVDcRw3PyW2XaVqjq-g,184
|
|
11
|
+
cybortx-2.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
12
|
+
cybortx-2.1.0.dist-info/entry_points.txt,sha256=hIJwXTtfJnFTrqm7k_ug_xhGsJZyB7wa8xQLdrvWO04,41
|
|
13
|
+
cybortx-2.1.0.dist-info/top_level.txt,sha256=hP5TZJSaHRyLzTJFni2wziCeFUSPQkO6czNupiXX0Q8,19
|
|
14
|
+
cybortx-2.1.0.dist-info/RECORD,,
|
cybortx.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import sys
|
|
5
|
+
import socket
|
|
6
|
+
import time
|
|
7
|
+
|
|
8
|
+
from utils.ui import print_banner, print_help, C_GREEN, C_RED, C_RESET, C_BOLD, C_YELLOW
|
|
9
|
+
from core.engine import parse_ports, run_scanner
|
|
10
|
+
from core.origin import find_origin
|
|
11
|
+
|
|
12
|
+
def main():
|
|
13
|
+
parser = argparse.ArgumentParser(add_help=False)
|
|
14
|
+
parser.add_argument("target", nargs="?", help="Target IP or Domain")
|
|
15
|
+
parser.add_argument("-p", "--ports", help="Ports to scan")
|
|
16
|
+
parser.add_argument("-h", "--help", action="store_true")
|
|
17
|
+
args = parser.parse_args()
|
|
18
|
+
|
|
19
|
+
if args.help or not args.target:
|
|
20
|
+
print_banner()
|
|
21
|
+
print_help()
|
|
22
|
+
sys.exit(0)
|
|
23
|
+
|
|
24
|
+
print_banner()
|
|
25
|
+
target = args.target
|
|
26
|
+
|
|
27
|
+
# --- Cloudflare Origin Discovery (Automatic) ---
|
|
28
|
+
scan_ip = target
|
|
29
|
+
if not target.replace('.', '').isdigit(): # It's a domain, not a raw IP
|
|
30
|
+
origin_ip = find_origin(target)
|
|
31
|
+
if origin_ip:
|
|
32
|
+
scan_ip = origin_ip
|
|
33
|
+
print(f"\n{C_GREEN}[*]{C_RESET} Using discovered IP for scanning: {C_BOLD}{scan_ip}{C_RESET}\n")
|
|
34
|
+
else:
|
|
35
|
+
# Fall back to normal resolution
|
|
36
|
+
try:
|
|
37
|
+
scan_ip = socket.gethostbyname(target)
|
|
38
|
+
print(f"\n{C_RESET}[*] Falling back to resolved IP: {C_BOLD}{scan_ip}{C_RESET}\n")
|
|
39
|
+
except socket.gaierror:
|
|
40
|
+
print(f"{C_RED}[ERROR]{C_RESET} Could not resolve IP for: {target}")
|
|
41
|
+
sys.exit(1)
|
|
42
|
+
else:
|
|
43
|
+
scan_ip = target
|
|
44
|
+
|
|
45
|
+
# --- Port Scanning ---
|
|
46
|
+
ports_to_scan = parse_ports(args.ports)
|
|
47
|
+
if not ports_to_scan:
|
|
48
|
+
print(f"{C_RED}[ERROR]{C_RESET} Invalid port format.")
|
|
49
|
+
sys.exit(1)
|
|
50
|
+
|
|
51
|
+
print(f"{C_RESET}[*] Scanning {len(ports_to_scan)} Ports on {C_BOLD}{scan_ip}{C_RESET}...\n")
|
|
52
|
+
start_time = time.time()
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
open_ports = run_scanner(scan_ip, ports_to_scan)
|
|
56
|
+
except KeyboardInterrupt:
|
|
57
|
+
print(f"\n{C_RESET}[!] Scan interrupted by user.")
|
|
58
|
+
sys.exit(1)
|
|
59
|
+
|
|
60
|
+
elapsed = round(time.time() - start_time, 2)
|
|
61
|
+
if not open_ports:
|
|
62
|
+
print(f"{C_RESET}[-] No open ports found.")
|
|
63
|
+
|
|
64
|
+
print(f"\n{C_RESET}[*] Scan completed in {elapsed} seconds.")
|
|
65
|
+
print(f"{C_RESET}[*] Found {C_GREEN}{len(open_ports)}{C_RESET} open port(s) on {C_BOLD}{scan_ip}{C_RESET}")
|
|
66
|
+
|
|
67
|
+
if __name__ == "__main__":
|
|
68
|
+
main()
|
utils/__init__.py
ADDED
|
File without changes
|
utils/reporter.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import re
|
|
4
|
+
from datetime import datetime, timezone
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def save_report(target: str, results: dict) -> str:
|
|
9
|
+
data_home = Path(
|
|
10
|
+
os.environ.get("XDG_DATA_HOME", Path.home() / ".local" / "share")
|
|
11
|
+
)
|
|
12
|
+
reports_dir = data_home / "cybortx" / "reports"
|
|
13
|
+
reports_dir.mkdir(parents=True, exist_ok=True)
|
|
14
|
+
|
|
15
|
+
safe = re.sub(r"[^a-zA-Z0-9.-]", "_", target)[:60]
|
|
16
|
+
ts = datetime.now(timezone.utc).strftime("%Y%m%d_%H%M%S")
|
|
17
|
+
filepath = reports_dir / f"{safe}_{ts}.json"
|
|
18
|
+
|
|
19
|
+
report = {
|
|
20
|
+
"tool": "CYBORT X",
|
|
21
|
+
"version": "2.0.0",
|
|
22
|
+
"target": target,
|
|
23
|
+
"timestamp": datetime.now(timezone.utc).isoformat(),
|
|
24
|
+
"results": {
|
|
25
|
+
ip: [{"port": p, "latency_ms": l} for p, l in ports]
|
|
26
|
+
for ip, ports in results.items()
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
with open(filepath, "w", encoding="utf-8") as f:
|
|
30
|
+
json.dump(report, f, indent=4, ensure_ascii=False, default=str)
|
|
31
|
+
return str(filepath)
|
utils/ui.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
C_GREEN = "\033[92m"
|
|
2
|
+
C_CYAN = "\033[96m"
|
|
3
|
+
C_YELLOW = "\033[93m"
|
|
4
|
+
C_RED = "\033[91m"
|
|
5
|
+
C_BOLD = "\033[1m"
|
|
6
|
+
C_RESET = "\033[0m"
|
|
7
|
+
C_DIM = "\033[2m"
|
|
8
|
+
|
|
9
|
+
VERSION = "2.1.0"
|
|
10
|
+
AUTHOR = "Abdulbasid Yakubu"
|
|
11
|
+
CODENAME = "cybort"
|
|
12
|
+
|
|
13
|
+
BANNER_ART = r"""
|
|
14
|
+
___ __ __ ___ ___ ____ _____ __ __
|
|
15
|
+
/ __| \ \/ / _ ) / _ \| _ \_ _|\ \/ /
|
|
16
|
+
| (__ > / | _ \| (_) | |_) || | > <
|
|
17
|
+
\___| /_ \___/ \___/|____/ |_| /_/\_\
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def print_banner():
|
|
21
|
+
print(f"{C_BOLD}{C_CYAN}{BANNER_ART}{C_RESET} {C_DIM}v{VERSION}{C_RESET}\n")
|
|
22
|
+
print(f" Author: {C_BOLD}{AUTHOR}{C_RESET} | Codename: {C_DIM}{CODENAME}{C_RESET}\n")
|
|
23
|
+
print(f"{C_RESET}[!] Use with caution. You are responsible for your actions.")
|
|
24
|
+
print(f"{C_RESET}[!] Developers assume no liability and are not responsible for any misuse or damage.\n")
|
|
25
|
+
|
|
26
|
+
def print_help():
|
|
27
|
+
print(f"{C_CYAN}Usage:{C_RESET}")
|
|
28
|
+
print(f" cybortX <target> [options]\n")
|
|
29
|
+
print(f"{C_CYAN}Options:{C_RESET}")
|
|
30
|
+
print(f" -p, --ports Ports to scan (e.g. 80,443 or 1-1000 or 'top')")
|
|
31
|
+
print(f" -h, --help Show this help menu\n")
|
|
32
|
+
print(f"{C_CYAN}Examples:{C_RESET}")
|
|
33
|
+
print(f" cybortX example.com")
|
|
34
|
+
print(f" cybortX 127.0.0.1 -p 1-1000")
|
|
35
|
+
print(f" cybortX example.com -p 80,443,8080")
|
|
36
|
+
print()
|