-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecryptx_cli.py
106 lines (95 loc) Β· 4.2 KB
/
decryptx_cli.py
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
import argparse
from decryptx.decryptx import DecryptX
from decryptx.utils.logger import decryptXLogger
def main():
"""
Main entry point for the DecryptX utility.
This tool allows users to crack password hashes or decrypt protected ZIP files
using wordlist-based attacks. It supports various hash algorithms and multithreading
for enhanced performance.
Usage:
python decryptx.py --mode <hash|zip> <target> [options]
Modes:
hash: Crack a password hash (requires --hash-type).
zip: Decrypt a password-protected ZIP file.
Command-Line Arguments:
--mode (str): Operation mode: 'hash' to crack a hash, or 'zip' to crack a ZIP file (required).
<target>: For 'hash' mode, provide the hash to crack. For 'zip' mode, provide the ZIP file path.
--hash-type (str): For 'hash' mode, specify the hash algorithm (default: md5).
--max-workers (int): Number of threads for parallel processing (default: 4).
--chunk-size (int): Number of passwords per thread chunk. Leave empty for sequential processing.
--wordlist (str): Path to a custom wordlist. If not provided, the default wordlist will be used.
Returns:
None. Outputs the result to the console.
Logging:
[+] Indicates a successfully cracked password or ZIP file.
[-] Indicates no matches were found.
[!] Logs errors, including invalid input or unexpected issues.
"""
parser = argparse.ArgumentParser(
description="π DecryptX: Crack hashes or decrypt ZIP files for security assessments."
)
parser.add_argument(
'--mode',
required=True,
choices=['hash', 'zip'],
help="Operation mode: 'hash' to crack a password hash or 'zip' to crack a protected ZIP file."
)
parser.add_argument('target', help="The hash to crack (in 'hash' mode) or the path to the ZIP file (in 'zip' mode).")
parser.add_argument(
'--hash-type',
help='The type of hash algorithm to use (e.g., md5, sha256, bcrypt). Default is md5. (Only for hash mode)',
default='md5'
)
parser.add_argument(
'--max-workers',
type=int,
default=4,
help='Number of threads to use for parallel processing (default: 4). (Only for hash mode)'
)
parser.add_argument(
'--chunk-size',
type=int,
help='Number of passwords to process per thread chunk. Leave empty for sequential processing. (Only for hash mode)'
)
parser.add_argument(
'--wordlist',
type=str,
help='Path to a custom wordlist. If not provided, the default wordlist will be used.'
)
args = parser.parse_args()
cracker = DecryptX(wordlist_path=args.wordlist)
if args.mode == 'hash':
# Crack the hash
try:
decryptXLogger.info("π Starting hash cracking process...")
result = cracker.crack_hash(
hash_value=args.target,
hash_type=args.hash_type,
max_workers=args.max_workers,
chunk_size=args.chunk_size
)
if result:
decryptXLogger.info(f"[+] Password found for hash: {result} π")
else:
decryptXLogger.warning("[-] No matches found for the hash. π")
except ValueError as e:
decryptXLogger.error(f"[!] Error: {e} β")
except Exception as e:
decryptXLogger.critical(f"[!] An unexpected error occurred: {e} π₯")
elif args.mode == 'zip':
try:
decryptXLogger.info("π Starting ZIP cracking process...")
result = cracker.crack_zip(args.target)
if result:
decryptXLogger.info(f"[+] Password found for ZIP file: {result} π")
else:
decryptXLogger.warning("[-] No matches found for the ZIP file. π")
except FileNotFoundError as e:
decryptXLogger.error(f"[!] ZIP file error: {e} β")
except Exception as e:
decryptXLogger.critical(f"[!] An unexpected error occurred while cracking the ZIP file: {e} π₯")
else:
decryptXLogger.error("[!] Invalid mode specified. Use 'hash' or 'zip'. β")
if __name__ == "__main__":
main()