-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinteractive_cli.py
More file actions
621 lines (499 loc) · 20.2 KB
/
interactive_cli.py
File metadata and controls
621 lines (499 loc) · 20.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
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
#!/usr/bin/env python3
"""
SEC-SUITE Interactive CLI
A user-friendly menu-driven interface for the security toolkit
"""
import os
import sys
import time
from typing import List, Dict, Any
# Add the current directory to path so imports work
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from utils.banner import show_banner
from utils.crypto import hash_password, identify_hash_type
from utils.password_analyzer import analyze_password_strength
from attacks.dictionary import DictionaryAttack
from attacks.markov import MarkovAttack, AdvancedPasswordGenerator
from attacks.bruteforce import BruteForceAttack
from attacks.rainbow import RainbowAttack
from tools.network_scanner import NetworkScanner
class InteractiveCLI:
"""Interactive menu-driven interface for SEC-SUITE"""
def __init__(self):
self.current_menu = "main"
self.menu_history = []
self.screen_width = 80
def clear_screen(self):
"""Clear the terminal screen"""
os.system("cls" if os.name == "nt" else "clear")
def print_header(self, title: str):
"""Print a formatted header"""
print("╔" + "═" * (self.screen_width - 2) + "╗")
print("║" + title.center(self.screen_width - 2) + "║")
print("╚" + "═" * (self.screen_width - 2) + "╝")
print()
def print_menu(self, title: str, options: List[Dict[str, Any]]):
"""Print a formatted menu"""
self.print_header(title)
for i, option in enumerate(options, 1):
print(f" {i}. {option['text']}")
print(f"\n 0. {'Back' if self.menu_history else 'Exit'}")
print("\n" + "─" * self.screen_width)
def get_user_choice(self, max_option: int) -> int:
"""Get and validate user choice"""
while True:
try:
choice = input(f"\nEnter your choice (0-{max_option}): ").strip()
if not choice:
continue
choice_num = int(choice)
if 0 <= choice_num <= max_option:
return choice_num
else:
print(f"Please enter a number between 0 and {max_option}")
except ValueError:
print("Please enter a valid number")
except KeyboardInterrupt:
print("\n\nOperation cancelled by user.")
return 0
def wait_for_enter(self, message: str = "Press Enter to continue..."):
"""Wait for user to press Enter"""
input(f"\n{message}")
def main_menu(self):
"""Main menu"""
options = [
{"text": "Password Cracking Tools", "action": self.cracking_menu},
{"text": "Password Analysis & Hashing", "action": self.analysis_menu},
{"text": "Security Tools", "action": self.security_tools_menu},
{"text": "Encoding/Decoding Tools", "action": self.encoding_menu},
{"text": "About & Help", "action": self.about_menu},
]
while True:
self.clear_screen()
show_banner()
self.print_menu("SEC-SUITE Main Menu", options)
choice = self.get_user_choice(len(options))
if choice == 0:
print("\nThank you for using SEC-SUITE! Goodbye!")
break
else:
self.menu_history.append(self.main_menu)
options[choice - 1]["action"]()
def cracking_menu(self):
"""Password cracking menu"""
options = [
{"text": "Dictionary Attack", "action": self.dictionary_attack},
{"text": "Markov Chain Attack", "action": self.markov_attack},
{"text": "Brute Force Attack", "action": self.brute_force_attack},
{"text": "Rainbow Table Attack", "action": self.rainbow_attack},
{"text": "Generate Rainbow Table", "action": self.generate_rainbow_table_interactive},
]
while True:
self.clear_screen()
self.print_menu("Password Cracking Tools", options)
choice = self.get_user_choice(len(options))
if choice == 0:
self.menu_history.pop()
break
else:
options[choice - 1]["action"]()
def analysis_menu(self):
"""Password analysis and hashing menu"""
options = [
{"text": "Password Strength Analysis", "action": self.password_analysis},
{"text": "Password Hashing", "action": self.password_hashing},
{"text": "Hash Type Identification", "action": self.hash_identification},
]
while True:
self.clear_screen()
self.print_menu("Password Analysis & Hashing", options)
choice = self.get_user_choice(len(options))
if choice == 0:
self.menu_history.pop()
break
else:
options[choice - 1]["action"]()
def security_tools_menu(self):
"""Security tools menu"""
options = [
{"text": "Network Port Scanner", "action": self.network_scanner},
{"text": "Generate Password List", "action": self.generate_passwords},
]
while True:
self.clear_screen()
self.print_menu("Security Tools", options)
choice = self.get_user_choice(len(options))
if choice == 0:
self.menu_history.pop()
break
else:
options[choice - 1]["action"]()
def encoding_menu(self):
"""Encoding/decoding menu"""
options = [
{
"text": "Base64 Encoding/Decoding",
"action": lambda: self.encoding_tool("base64"),
},
{
"text": "URL Encoding/Decoding",
"action": lambda: self.encoding_tool("url"),
},
{
"text": "HTML Encoding/Decoding",
"action": lambda: self.encoding_tool("html"),
},
{
"text": "Hex Encoding/Decoding",
"action": lambda: self.encoding_tool("hex"),
},
]
while True:
self.clear_screen()
self.print_menu("Encoding/Decoding Tools", options)
choice = self.get_user_choice(len(options))
if choice == 0:
self.menu_history.pop()
break
else:
options[choice - 1]["action"]()
def about_menu(self):
"""About and help menu"""
self.clear_screen()
self.print_header("About SEC-SUITE")
about_text = [
"SEC-SUITE v2.0 - Advanced Security Testing Toolkit",
"",
"Features:",
" • Multiple password cracking methods",
" • Modern hash algorithm support",
" • Multi-threaded attacks",
" • Network security tools",
" • Encoding/decoding utilities",
"",
"Legal Notice:",
" This tool is for educational and authorized",
" security testing only. Use responsibly!",
"",
"GitHub: https://github.com/gab-dev-7/sec-suite",
]
for line in about_text:
print(f" {line}")
self.wait_for_enter()
self.menu_history.pop()
def dictionary_attack(self):
"""Interactive dictionary attack"""
self.clear_screen()
self.print_header("Dictionary Attack")
target_hash = input("Enter target hash: ").strip()
if not target_hash:
print("Hash cannot be empty!")
self.wait_for_enter()
return
# Auto-detect hash type
hash_type = identify_hash_type(target_hash)
if hash_type:
print(f"Auto-detected hash type: {hash_type}")
use_auto = input("Use auto-detected type? (y/n): ").lower().strip()
if use_auto != "y":
hash_type = None
if not hash_type:
hash_type = input(
"Enter hash type (md5, sha1, sha256, sha512, bcrypt): "
).strip()
wordlist = (
input("Enter wordlist path [data/rockyou.txt]: ").strip()
or "data/rockyou.txt"
)
threads = input("Enter number of threads [4]: ").strip() or "4"
print(f"\nStarting dictionary attack...")
print(f"Target: {target_hash}")
print(f"Type: {hash_type}")
print(f"Wordlist: {wordlist}")
print(f"Threads: {threads}")
print("-" * 50)
try:
attack = DictionaryAttack(wordlist, hash_type, max_processes=int(threads))
result = attack.crack(target_hash)
if result:
print(f"\n[+] Password found: {result}")
else:
print(f"\n[-] Password not found in wordlist")
except Exception as e:
print(f"\n[!] {e}")
self.wait_for_enter()
def markov_attack(self):
"""Interactive Markov chain attack"""
self.clear_screen()
self.print_header("Markov Chain Attack")
target_hash = input("Enter target hash: ").strip()
if not target_hash:
print("Hash cannot be empty!")
self.wait_for_enter()
return
hash_type = input("Enter hash type (md5, sha1, sha256, sha512): ").strip()
training_file = (
input("Enter training file [data/rockyou.txt]: ").strip()
or "data/rockyou.txt"
)
max_passwords = (
input("Enter max passwords to generate [50000]: ").strip() or "50000"
)
threads = input("Enter number of threads [4]: ").strip() or "4"
print(f"\nStarting Markov chain attack...")
print("This may take a while as we generate password candidates...")
try:
attack = MarkovAttack(
training_file, hash_type, int(threads), int(max_passwords)
)
result = attack.crack(target_hash)
if result:
print(f"\n[+] Password found: {result}")
else:
print(f"\n[-] Password not found with Markov attack")
except Exception as e:
print(f"\n[!] {e}")
self.wait_for_enter()
def brute_force_attack(self):
"""Interactive brute force attack"""
self.clear_screen()
self.print_header("Brute Force Attack")
target_hash = input("Enter target hash: ").strip()
if not target_hash:
print("Hash cannot be empty!")
self.wait_for_enter()
return
hash_type = input("Enter hash type (md5, sha1, sha256, sha512): ").strip()
print("\nCharacter sets:")
print(" l - lowercase letters (abc...)")
print(" u - uppercase letters (ABC...)")
print(" d - digits (012...)")
print(" s - special characters (!@#...)")
charset = input("Enter character sets [lud]: ").strip() or "lud"
min_len = input("Enter minimum length [1]: ").strip() or "1"
max_len = input("Enter maximum length [6]: ").strip() or "6"
threads = input("Enter number of threads [4]: ").strip() or "4"
print(f"\nStarting brute force attack...")
print(
f"This will test up to {BruteForceAttack(hash_type, charset, int(min_len), int(max_len), max_processes=1).calculate_total_combinations()} combinations"
)
print("This may take a very long time!")
proceed = input("Proceed? (y/n): ").lower().strip()
if proceed != "y":
print("Attack cancelled.")
self.wait_for_enter()
return
try:
attack = BruteForceAttack(
hash_type, charset, int(min_len), int(max_len), max_processes=int(threads)
)
result = attack.crack(target_hash)
if result:
print(f"\n[+] Password found: {result}")
else:
print(f"\n[-] Password not found with brute force")
except Exception as e:
print(f"\n[!] {e}")
self.wait_for_enter()
def rainbow_attack(self):
"""Interactive rainbow table attack"""
self.clear_screen()
self.print_header("Rainbow Table Attack")
target_hash = input("Enter target hash: ").strip()
if not target_hash:
print("Hash cannot be empty!")
self.wait_for_enter()
return
rainbow_table = input("Enter rainbow table file path: ").strip()
if not rainbow_table:
print("Rainbow table path required!")
self.wait_for_enter()
return
print(f"\nStarting rainbow table attack...")
try:
attack = RainbowAttack(rainbow_table)
result = attack.crack(target_hash)
if result:
print(f"\n[+] Password found: {result}")
else:
print(f"\n[-] Hash not found in rainbow table")
except Exception as e:
print(f"\n[!] {e}")
self.wait_for_enter()
def generate_rainbow_table_interactive(self):
"""Interactive rainbow table generation"""
self.clear_screen()
self.print_header("Generate Rainbow Table")
wordlist = input("Enter wordlist path: ").strip()
if not wordlist:
print("Wordlist path cannot be empty!")
self.wait_for_enter()
return
output_path = input("Enter output path for rainbow table [rainbow.json]: ").strip() or "rainbow.json"
hash_type = input("Enter hash type (md5, sha1, sha256, sha512) [md5]: ").strip() or "md5"
valid_hash_types = ["md5", "sha1", "sha256", "sha512"]
if hash_type not in valid_hash_types:
print(f"Invalid hash type! Choose from: {', '.join(valid_hash_types)}")
self.wait_for_enter()
return
print(f"\nStarting rainbow table generation...")
print(f"Wordlist: {wordlist}")
print(f"Output: {output_path}")
print(f"Type: {hash_type}")
print("-" * 50)
try:
attack = RainbowAttack()
attack.generate_rainbow_table(wordlist, output_path, hash_type)
if os.path.exists(output_path):
print(f"\n[+] Rainbow table generated at {output_path}")
else:
print(f"\n[!] Failed to generate rainbow table. Check the error above.")
except Exception as e:
print(f"\n[!] {e}")
self.wait_for_enter()
def password_analysis(self):
"""Interactive password strength analysis"""
self.clear_screen()
self.print_header("Password Strength Analysis")
password = input("Enter password to analyze: ").strip()
if not password:
print("Password cannot be empty!")
self.wait_for_enter()
return
print(f"\nAnalyzing password: {password}")
print("-" * 50)
try:
analyze_password_strength(password)
except Exception as e:
print(f"\n[!] {e}")
self.wait_for_enter()
def password_hashing(self):
"""Interactive password hashing"""
self.clear_screen()
self.print_header("Password Hashing")
password = input("Enter password to hash: ").strip()
if not password:
print("Password cannot be empty!")
self.wait_for_enter()
return
algorithm = (
input(
"Enter algorithm (md5, sha1, sha256, sha512, bcrypt) [sha256]: "
).strip()
or "sha256"
)
print(f"\nHashing password with {algorithm}...")
try:
hashed = hash_password(password, algorithm)
print(f"Hash ({algorithm.upper()}): {hashed}")
except Exception as e:
print(f"\n[!] {e}")
self.wait_for_enter()
def hash_identification(self):
"""Interactive hash type identification"""
self.clear_screen()
self.print_header("Hash Type Identification")
hash_input = input("Enter hash to identify: ").strip()
if not hash_input:
print("Hash cannot be empty!")
self.wait_for_enter()
return
print(f"\nAnalyzing hash: {hash_input}")
print("-" * 50)
try:
hash_type = identify_hash_type(hash_input)
if hash_type:
print(f"[*] Identified hash type: {hash_type}")
else:
print("[-] Could not identify hash type")
print("This might be an unsupported or custom hash format")
except Exception as e:
print(f"\n[!] {e}")
self.wait_for_enter()
def network_scanner(self):
"""Interactive network scanner"""
self.clear_screen()
self.print_header("Network Port Scanner")
target = input("Enter target IP or range (e.g., 192.168.1.1 or 192.168.1.0/24): ").strip()
if not target:
print("Target cannot be empty!")
self.wait_for_enter()
return
ports = input("Enter port range [1-1000]: ").strip() or "1-1000"
threads = input("Enter number of threads [50]: ").strip() or "50"
timeout = input("Enter timeout in seconds [1.0]: ").strip() or "1.0"
print(f"\nStarting network scan on {target}...")
print(f"Ports: {ports}")
print(f"Threads: {threads}")
print(f"Timeout: {timeout}s")
print("-" * 50)
try:
scanner = NetworkScanner(target, ports, int(threads), float(timeout))
scanner.scan()
except Exception as e:
print(f"\n[!] {e}")
self.wait_for_enter()
def generate_passwords(self):
"""Interactive password generation"""
self.clear_screen()
self.print_header("Password List Generation")
training_file = (
input("Enter training file [data/rockyou.txt]: ").strip()
or "data/rockyou.txt"
)
if not os.path.exists(training_file):
print(f"Error: Training file {training_file} not found.")
self.wait_for_enter()
return
count = input("Enter number of passwords to generate [10]: ").strip() or "10"
min_len = input("Enter minimum length [8]: ").strip() or "8"
max_len = input("Enter maximum length [12]: ").strip() or "12"
print(f"\nTraining model and generating passwords...")
print("This may take a moment depending on the training file size.")
try:
generator = AdvancedPasswordGenerator(training_file)
passwords = generator.generate_passwords(int(count), int(min_len), int(max_len))
print(f"\nGenerated {len(passwords)} passwords:")
print("-" * 50)
for i, pwd in enumerate(passwords, 1):
# Using strength analyzer for each generated password
score = analyze_password_strength(pwd)
print(f"{i:2d}. {pwd} (Score: {score}/100)")
print("-" * 20)
except Exception as e:
print(f"\n[!] {e}")
self.wait_for_enter()
def encoding_tool(self, encoding_type: str):
"""Interactive encoding/decoding tool"""
self.clear_screen()
self.print_header(f"{encoding_type.upper()} Encoding/Decoding")
operation = input("Choose operation (1=encode, 2=decode): ").strip()
if operation not in ["1", "2"]:
print("Invalid operation!")
self.wait_for_enter()
return
data = input("Enter data: ").strip()
if not data:
print("Data cannot be empty!")
self.wait_for_enter()
return
from tools.encoder import encode_decode
try:
op_type = "encode" if operation == "1" else "decode"
result = encode_decode(data, op_type, encoding_type)
print(f"\nResult: {result}")
except Exception as e:
print(f"\n[!] {e}")
self.wait_for_enter()
def main():
"""Main entry point for interactive CLI"""
try:
cli = InteractiveCLI()
cli.main_menu()
except KeyboardInterrupt:
print("\n\nThank you for using SEC-SUITE! Goodbye!")
except Exception as e:
print(f"\n[!] Unexpected error: {e}")
print("Please report this issue on GitHub.")
if __name__ == "__main__":
main()