-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatic.py
More file actions
407 lines (334 loc) · 13.3 KB
/
static.py
File metadata and controls
407 lines (334 loc) · 13.3 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
#!/usr/bin/env python3
"""
Static v1.5 - Typosquatting Scout
Finds unregistered typo domains for security testing.
Usage: python static.py -d target.com
"""
import sys
import os
import argparse
import socket
import http.client
import ssl
from urllib.parse import urlparse
import time
import signal
import threading
from datetime import datetime
# ========== GLOBAL FLAGS AND COUNTERS ==========
SCAN_INTERRUPTED = False
SCAN_STATS = {
'current': 0,
'total': 0,
'potentially_available': 0,
'redirects': 0,
'taken': 0,
'running': False
}
# ========== THREAD LOCK FOR SAFETY ==========
stats_lock = threading.Lock()
def signal_handler(sig, frame):
"""Handle Ctrl+C gracefully."""
global SCAN_INTERRUPTED
SCAN_INTERRUPTED = True
with stats_lock:
SCAN_STATS['running'] = False
print(f"\n\n{Colors.RED}{Colors.BOLD}[!] SIGINT RECEIVED | ABORTING SCAN{Colors.END}")
time.sleep(0.3)
# Register signal handler
signal.signal(signal.SIGINT, signal_handler)
# ========== CROSS-PLATFORM CLEAR SCREEN ==========
def clear_screen():
"""Clear terminal screen for Windows, Linux, macOS."""
os.system('cls' if os.name == 'nt' else 'clear')
# ========== ANSI COLOR CODES ==========
class Colors:
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
CYAN = '\033[96m'
MAGENTA = '\033[95m'
BLUE = '\033[94m'
WHITE = '\033[97m'
GRAY = '\033[90m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'
# ========== BANNER WITH COLORS ==========
def banner():
clear_screen()
print(f"""{Colors.CYAN}{Colors.BOLD}
88
,d ,d ""
88 88
,adPPYba, MM88MMM ,adPPYYba, MM88MMM 88 ,adPPYba,
I8[ "" 88 "" `Y8 88 88 a8" ""
`"Y8ba, 88 ,adPPPPP88 88 88 8b
aa ]8I 88, 88, ,88 88, 88 "8a, ,aa
`"YbbdP"' "Y888 `"8bbdP"Y8 "Y888 88 `"Ybbd8"'
{Colors.MAGENTA}{Colors.BOLD}│------------------------------------------------│
│ static.py │ By URDev │ v1.5 │
│------------------------------------------------│{Colors.END}
""")
# ========== PROGRESS DISPLAY THREAD ==========
def progress_display():
"""Display thread that updates progress independently every 250ms."""
frames = ['◐', '◓', '◑', '◒']
frame_idx = 0
start_time = time.time()
while True:
with stats_lock:
if not SCAN_STATS['running']:
break
current = SCAN_STATS['current']
total = SCAN_STATS['total']
potentially_available = SCAN_STATS['potentially_available']
redirects = SCAN_STATS['redirects']
taken = SCAN_STATS['taken']
elapsed = time.time() - start_time
# Update frame
frame_idx = (frame_idx + 1) % len(frames)
spinner = frames[frame_idx]
# Progress bar
progress_width = 20
if total > 0:
filled = int((current / total) * progress_width)
else:
filled = 0
bar = f"{Colors.GREEN}{'█' * filled}{Colors.GRAY}{'░' * (progress_width - filled)}{Colors.END}"
# Build single display line
current_date = datetime.now().strftime("%Y-%m-%d")
time_str = f"{int(elapsed // 60):02d}:{int(elapsed % 60):02d}"
# Single line with everything
line = (
f"{Colors.CYAN}{Colors.BOLD}{spinner} Scanning{Colors.END} "
f"{bar} "
f"{Colors.WHITE}[{current}/{total}]{Colors.END} "
f"{Colors.YELLOW}[{time_str}]{Colors.END} "
f"{Colors.MAGENTA}[{current_date}]{Colors.END}"
)
# Clear and redraw single line
sys.stdout.write('\r\033[K') # Clear current line
sys.stdout.write(line)
sys.stdout.flush()
time.sleep(0.25) # Refresh every 250ms
# Clean up display when thread ends
sys.stdout.write('\r\033[K') # Clear the line
sys.stdout.flush()
# ========== TYPO GENERATION ==========
def generate_typos(domain):
"""Generate typo-based domain variations."""
variants = set()
base = domain.lower()
tld = ''
if '.' in base:
base, tld = base.rsplit('.', 1)
tld = '.' + tld
# 1. Character deletion
for i in range(len(base)):
variants.add(base[:i] + base[i+1:] + tld)
# 2. Character duplication
for i in range(len(base)):
variants.add(base[:i] + base[i] + base[i] + base[i+1:] + tld)
# 3. Adjacent character swap
for i in range(len(base)-1):
swapped = list(base)
swapped[i], swapped[i+1] = swapped[i+1], swapped[i]
variants.add(''.join(swapped) + tld)
# 4. QWERTY adjacent replacement
for i, char in enumerate(base):
if char in QWERTY_ADJACENT:
for replacement in QWERTY_ADJACENT[char]:
variants.add(base[:i] + replacement + base[i+1:] + tld)
# 5. TLD variations
if tld:
for new_tld in TLD_VARIANTS:
if new_tld != tld:
variants.add(base + new_tld)
# Apply to full domain
full_domain = base + tld
if full_domain.count('.') > 1:
for i in range(len(full_domain)):
if full_domain[i] == '.' and i > 0:
variants.add(full_domain[:i] + full_domain[i+1:])
return sorted([v for v in variants if v != domain])
# ========== DOMAIN CHECKING ==========
def check_dns(domain):
"""Check DNS resolution."""
try:
socket.gethostbyname(domain)
return True
except socket.gaierror:
try:
socket.getaddrinfo(domain, None)
return True
except:
return False
def check_http(domain, timeout=3):
"""Check HTTP/HTTPS response. Falls back to GET if HEAD fails."""
schemes = ['http', 'https']
for scheme in schemes:
try:
if scheme == 'http':
conn = http.client.HTTPConnection(domain, timeout=timeout)
else:
conn = http.client.HTTPSConnection(domain, timeout=timeout, context=ssl._create_unverified_context())
# Try HEAD first
conn.request('HEAD', '/')
response = conn.getresponse()
status = response.status
location = response.getheader('Location', '')
conn.close()
if 100 <= status < 400:
return status, location if location else None
except:
# Fallback to GET if HEAD fails or times out
try:
if scheme == 'http':
conn = http.client.HTTPConnection(domain, timeout=timeout)
else:
conn = http.client.HTTPSConnection(domain, timeout=timeout, context=ssl._create_unverified_context())
conn.request('GET', '/', headers={'User-Agent': 'static.py/1.5'})
response = conn.getresponse()
status = response.status
location = response.getheader('Location', '')
conn.close()
if 100 <= status < 400:
return status, location if location else None
except:
continue
return None, None
def verify_domain(domain):
"""Verify a single domain for availability."""
if SCAN_INTERRUPTED:
return 'INTERRUPTED', None, None
# Check DNS
dns_ok = check_dns(domain)
if not dns_ok:
# POTENTIALLY_AVAILABLE - No DNS doesn't guarantee it's actually available
return 'POTENTIALLY_AVAILABLE', f'http://{domain}', None
# Check HTTP/HTTPS
status, redirect = check_http(domain)
if status is None:
return 'TAKEN', None, None # DNS resolves but no HTTP
if redirect:
redirect_domain = urlparse(redirect).netloc
if domain not in redirect_domain and redirect_domain:
return 'REDIRECT', f'http://{domain}', redirect
return 'TAKEN', None, None
# ========== QWERTY KEYBOARD ADJACENCY ==========
QWERTY_ADJACENT = {
'q': ['w', 'a'], 'w': ['q', 'e', 's'], 'e': ['w', 'r', 'd'], 'r': ['e', 't', 'f'],
't': ['r', 'y', 'g'], 'y': ['t', 'u', 'h'], 'u': ['y', 'i', 'j'], 'i': ['u', 'o', 'k'],
'o': ['i', 'p', 'l'], 'p': ['o', 'l'], 'a': ['q', 's', 'z'], 's': ['a', 'w', 'd', 'x'],
'd': ['s', 'e', 'f', 'c'], 'f': ['d', 'r', 'g', 'v'], 'g': ['f', 't', 'h', 'b'],
'h': ['g', 'y', 'j', 'n'], 'j': ['h', 'u', 'k', 'm'], 'k': ['j', 'i', 'l'],
'l': ['k', 'o', 'p'], 'z': ['a', 's', 'x'], 'x': ['z', 's', 'd', 'c'],
'c': ['x', 'd', 'f', 'v'], 'v': ['c', 'f', 'g', 'b'], 'b': ['v', 'g', 'h', 'n'],
'n': ['b', 'h', 'j', 'm'], 'm': ['n', 'j', 'k']
}
TLD_VARIANTS = ['.com', '.net', '.org', '.co', '.io']
def main():
parser = argparse.ArgumentParser(description='Static v1.5 - Find available typo domains')
parser.add_argument('-d', '--domain', required=True, help='Target domain (e.g., google.com)')
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
banner()
print(f"{Colors.CYAN}[{Colors.GREEN}+{Colors.CYAN}] Target: {Colors.BOLD}{args.domain}{Colors.END}")
print(f"{Colors.BLUE}{'='*70}{Colors.END}")
# Generate variants
variants = generate_typos(args.domain)
if not variants:
print(f"{Colors.YELLOW}[!] No variants generated.{Colors.END}")
return
print(f"{Colors.CYAN}[{Colors.GREEN}+{Colors.CYAN}] Generated {len(variants)} typo variants.{Colors.END}")
print(f"{Colors.GRAY}[*] Press Ctrl+C to abort scan at any time{Colors.END}\n")
# Initialize stats
with stats_lock:
SCAN_STATS.update({
'total': len(variants),
'current': 0,
'potentially_available': 0,
'redirects': 0,
'taken': 0,
'running': True
})
# Start progress display thread
progress_thread = threading.Thread(target=progress_display, daemon=True)
progress_thread.start()
# Start scanning
potentially_available = []
redirects = []
start_time = time.time()
scan_start = datetime.now().strftime("%Y-%m-%d %H:%M")
try:
for i, variant in enumerate(variants, 1):
if SCAN_INTERRUPTED:
break
# Update current counter
with stats_lock:
SCAN_STATS['current'] = i
# Verify domain
status, url, redirect_url = verify_domain(variant)
# Update stats and collect results
with stats_lock:
if status == 'POTENTIALLY_AVAILABLE':
SCAN_STATS['potentially_available'] += 1
potentially_available.append(url)
elif status == 'REDIRECT':
SCAN_STATS['redirects'] += 1
redirects.append((url, redirect_url))
elif status == 'TAKEN':
SCAN_STATS['taken'] += 1
except Exception as e:
print(f"\n{Colors.RED}[!] Error during scan: {e}{Colors.END}")
finally:
# Stop progress display
with stats_lock:
SCAN_STATS['running'] = False
# Wait for progress thread to finish
progress_thread.join(timeout=1)
# Clear progress area
sys.stdout.write('\n')
sys.stdout.flush()
# Calculate final stats
total_time = time.time() - start_time
# Show interruption message if needed
if SCAN_INTERRUPTED:
print(f"{Colors.RED}{Colors.BOLD}[✗] SCAN INTERRUPTED BY USER{Colors.END}")
print(f"{Colors.RED}[!] Partial results shown below{Colors.END}")
else:
print(f"{Colors.GREEN}{Colors.BOLD}[✓] SCAN COMPLETED{Colors.END}")
print(f"{Colors.CYAN}[*] Duration: {int(total_time // 60):02d}:{int(total_time % 60):02d} | Started: {scan_start}{Colors.END}")
print(f"{Colors.BLUE}{'='*70}{Colors.END}")
# Show POTENTIALLY_AVAILABLE domains
if potentially_available:
print(f"\n{Colors.GREEN}{Colors.BOLD}[+] POTENTIALLY AVAILABLE DOMAINS ({len(potentially_available)}){Colors.END}")
print(f"{Colors.GRAY}[!] No DNS resolution - may be actually available{Colors.END}")
for url in potentially_available:
print(f" {Colors.GREEN}→ {url}{Colors.END}")
else:
print(f"\n{Colors.GRAY}[~] No potentially available domains found{Colors.END}")
# Show REDIRECTS
if redirects:
print(f"\n{Colors.YELLOW}{Colors.BOLD}[~] REDIRECTING DOMAINS ({len(redirects)}){Colors.END}")
for url, redirect_url in redirects:
print(f" {Colors.YELLOW}[{url}] → {redirect_url}{Colors.END}")
# Show summary
print(f"\n{Colors.CYAN}{Colors.BOLD}[*] FINAL STATS{Colors.END}")
print(f" {Colors.GREEN}Potentially Available: {len(potentially_available)}{Colors.END}")
print(f" {Colors.YELLOW}Redirects: {len(redirects)}{Colors.END}")
print(f" {Colors.RED}Taken: {SCAN_STATS['taken']}{Colors.END}")
print(f" {Colors.WHITE}Total: {len(variants)}{Colors.END}")
print(f" {Colors.MAGENTA}Time: {int(total_time // 60):02d}:{int(total_time % 60):02d}{Colors.END}")
print(f" {Colors.BLUE}Speed: {len(variants)/total_time if total_time > 0 else 0:.1f} domains/sec{Colors.END}")
# Footer
print(f"\n{Colors.GRAY}{'─'*70}{Colors.END}")
print(f"{Colors.WHITE}[!] static.py v1.5 | github.com/urdev4ever | {datetime.now().strftime('%Y-%m-%d')}{Colors.END}")
# Exit code
if SCAN_INTERRUPTED:
sys.exit(130)
if __name__ == '__main__':
main()