tchef-cli 1.0.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.
tchef.py ADDED
@@ -0,0 +1,238 @@
1
+ from itertools import cycle
2
+ from colorama import Style, Fore, Back, init
3
+ import hashlib
4
+ import codecs
5
+ import base64
6
+ from urllib.parse import quote_plus, unquote_plus
7
+ import argparse
8
+ import sys
9
+ init(autoreset=True)
10
+
11
+ OPERATIONS = {}
12
+
13
+ def register(op_name):
14
+ def decorator(func):
15
+ OPERATIONS[op_name] = func
16
+ return func
17
+ return decorator
18
+
19
+ @register("magic")
20
+ def magic(data,args):
21
+ candidate_opies = ["dec_b64","dec_hex","dec_url","dec_utf8","dec_rot13","dec_b32"]
22
+ suxesful = []
23
+ suxesful.append(f"MAGIC's results for {data[:20]}...")
24
+ suxesful.append("-" * 35)
25
+
26
+ for op in candidate_opies:
27
+ try:
28
+ func = OPERATIONS[op]
29
+ result = func(data,args)
30
+ if result and result != data:
31
+ preview_data = result[:60] +"..." if len(result) > 60 else result
32
+ suxesful.append(Fore.GREEN + f"[+] Possible match: {op} ------> {preview_data}")
33
+ for op2 in candidate_opies:
34
+ try:
35
+ result2 = OPERATIONS[op2](result, args)
36
+ if result2 and result2 != result:
37
+ preview_data2 = result2[:60] +"..." if len(result2) > 60 else result2
38
+ suxesful.append(Fore.GREEN + Style.BRIGHT + f"[+] DIPPER match: {op2} ------> {preview_data2}")
39
+ except Exception as e:
40
+ pass
41
+
42
+ except Exception as e:
43
+ pass
44
+ if len(suxesful) > 2:
45
+ return "\n".join(suxesful)
46
+ else:
47
+ return Fore.RED + "MAGIC could not find any matches :( Data might be encyrpted."
48
+
49
+
50
+ @register("hash_md5")
51
+ def hash_md5(data, args):
52
+ if isinstance(data,str):
53
+ data = bytes(data,"utf-8")
54
+ return hashlib.md5(data).hexdigest()
55
+
56
+ @register("hash_sha1")
57
+ def hash_sha1(data, args):
58
+ if isinstance(data,str):
59
+ data = bytes(data,"utf-8")
60
+ return hashlib.sha1(data).hexdigest()
61
+
62
+ @register("hash_sha256")
63
+ def hash_sha256(data, args):
64
+ if isinstance(data,str):
65
+ data = bytes(data,"utf-8")
66
+ return hashlib.sha256(data).hexdigest()
67
+
68
+ @register("hash_sha512")
69
+ def hash_sha512(data, args):
70
+ if isinstance(data,str):
71
+ data = bytes(data, "utf-8")
72
+ return hashlib.sha512(data).hexdigest()
73
+
74
+ @register("en_utf8")
75
+ def en_utf8(data, args):
76
+ data = data.encode("utf-8")
77
+ return str(data)[2:-1]
78
+
79
+ @register("dec_utf8")
80
+ def dec_utf8(data, args):
81
+ bytes_input = codecs.escape_decode(data.encode("utf-8"))[0]
82
+ decoded_input = codecs.decode(bytes_input, encoding="utf-8", errors="strict")
83
+ return decoded_input
84
+
85
+ @register("en_b64")
86
+ def en_b64(data, args):
87
+ data = bytes(data,"utf-8")
88
+ to_base64 = base64.b64encode(data).decode("utf-8")
89
+ return to_base64
90
+
91
+ @register("dec_b64")
92
+ def dec_b64(data, args):
93
+ data = data.encode("utf-8")
94
+ from_base64 = base64.b64decode(data).decode("utf-8")
95
+ return from_base64
96
+
97
+ @register("en_b32")
98
+ def en_b32(data, args):
99
+ if isinstance(data, str):
100
+ data = data.encode("utf-8")
101
+ return base64.b32encode(data).decode("utf-8")
102
+
103
+ @register("dec_b32")
104
+ def dec_b32(data,args):
105
+ if isinstance(data,str):
106
+ data = data.encode("utf-8")
107
+ return base64.b32decode(data).decode("utf-8")
108
+
109
+ @register("en_rot13")
110
+ def en_rot13(data, args):
111
+ if isinstance(data, bytes):
112
+ data = data.decode("utf-8")
113
+ return codecs.encode(data, encoding="rot13", errors="strict")
114
+
115
+ @register("dec_rot13")
116
+ def dec_rot13(data, args):
117
+ if isinstance(data, bytes):
118
+ data = data.decode("utf-8")
119
+ return codecs.decode(data, encoding="rot13", errors="strict")
120
+
121
+ @register("en_hex")
122
+ def en_hex(data, args):
123
+ data = data.encode("utf-8")
124
+ to_hex = codecs.encode(data, encoding="hex", errors="strict").decode("utf-8")
125
+ return to_hex
126
+
127
+ @register("dec_hex")
128
+ def dec_hex(data, args):
129
+ data = data.encode("utf-8")
130
+ from_hex = codecs.decode(data, encoding="hex", errors="strict").decode("utf-8")
131
+ return from_hex
132
+
133
+ @register("en_url")
134
+ def en_url(data, args):
135
+ to_url = quote_plus(data)
136
+ return to_url
137
+
138
+ @register("dec_url")
139
+ def dec_url(data, args):
140
+ from_url = unquote_plus(data)
141
+ return from_url
142
+
143
+ @register("en_xor")
144
+ def en_xor(data, args):
145
+ if not args.key:
146
+ return Fore.YELLOW + "No key provided :d XOR requires a KEY (-k)"
147
+
148
+ if isinstance(data,str):
149
+ data = data.encode("utf-8")
150
+
151
+ if isinstance(args.key, str):
152
+ args.key = args.key.encode("utf-8")
153
+ xored = bytes(no1 ^ no2 for no1,no2 in zip(data, cycle(args.key)))
154
+ return base64.b64encode(xored).decode("utf-8")
155
+
156
+ @register("dec_xor")
157
+ def dec_xor(data, args):
158
+ if not args.key:
159
+ return Fore.YELLOW + "No key provided :d XOR requires a KEY (-k)"
160
+
161
+ raw_data = base64.b64decode(data)
162
+ if isinstance(args.key, str):
163
+ args.key = args.key.encode("utf-8")
164
+ decrypted_xor = bytes(no1 ^ no2 for no1, no2 in zip(raw_data,cycle(args.key)))
165
+ return decrypted_xor.decode("utf-8", errors="ignore")
166
+
167
+ @register("alperen")
168
+ def alperen(data,args):
169
+ return Style.DIM + Back.GREEN + Fore.RED + "Alp Eren YILMAZ sen mal mısın knk" + Style.RESET_ALL
170
+
171
+ def main():
172
+ parser = argparse.ArgumentParser(prog='TChef',description='Encoding-decoding-encrypting-decrypting service for terminal interface.',epilog='')
173
+ parser.add_argument("--operation", "-o", help="Operation you would like to work with.")
174
+ parser.add_argument("--data","-d",help="Poor thing that is going to be operated :( Btw data can be piped")
175
+ parser.add_argument("--key","-k",help="Required for some operations such as XOR.")
176
+ parser.add_argument("--help2", action="store_true",help="Prints all operations.")
177
+ parser.add_argument("--input-file", "-i", help="Reads data from a specified file.")
178
+ parser.add_argument("--output-file", "-f", help="Write the output to a specified file.")
179
+
180
+ args = parser.parse_args()
181
+
182
+ if args.help2:
183
+ print(Fore.CYAN + Style.BRIGHT + ("\nTCHEF: TERMINAL INTERFACE OF ENCODING-DECODING PROCESSES").center(30) + ("\n" * 3) + Style.RESET_ALL)
184
+ print("-" * 50)
185
+ print(Style.BRIGHT + "magic - MAGIC\nen_utf8 - ENcode String to UTF-8\ndec_utf8 - DEcode from UTF-8 Bytes\nen_b64 - ENcode Bytes to Base64\ndec_b64 - DEcode Bytes from Base64")
186
+ print("en_b32 - ENcode Bytes to Base32\ndec_b32 - DEcode from Base32\nen_rot13 - ENcode to ROT13\ndec_rot13 - DEcode from ROT13")
187
+ print("en_hex - ENcode Bytes to Hex\ndec_hex - DEcode from Hex\nen_url - ENcode to URL\ndec_url - DEcode from URL,\nen_xor - XOR ENcryption\ndec_xor - XOR DEcryption\n")
188
+ print("-" * 50)
189
+ print(Style.NORMAL +"HASHES"+ Style.BRIGHT + "\n\nhash_md5 - HASH to MD5\nhash_sha1 - HASH to SHA1\nhash_sha2 - HASH to SHA256\nhash_sha512 - HASH to SHA512")
190
+ print("\nXOR encyrption and decyrption works with base64.\n"+ Style.RESET_ALL + Fore.GREEN + "\n[+] Tip: You can chain operations:>! example: -o 'en_b64,en_hex'")
191
+ sys.exit(0)
192
+
193
+ if args.input_file:
194
+ try:
195
+ with open(args.input_file, "r", encoding="utf-8") as file:
196
+ args.data = file.read()
197
+ except Exception as e:
198
+ print(Fore.RED + f"Error reading the file :d : {e}")
199
+ sys.exit(1)
200
+
201
+ if not args.data and not sys.stdin.isatty():
202
+ args.data = sys.stdin.read().strip()
203
+
204
+
205
+ if args.operation:
206
+ ops = args.operation.split(",")
207
+ if not args.data and "alperen" not in args.operation:
208
+ print(Fore.RED + "Error!!! No valid data provided! (-d)")
209
+ sys.exit(1)
210
+ elif not args.help2:
211
+ print(Fore.RED + "Error! Operation is not specified! :d (-o)")
212
+ sys.exit(1)
213
+
214
+ current_data = args.data
215
+
216
+ try:
217
+ for op in ops:
218
+ op = op.strip()
219
+ if op in OPERATIONS:
220
+ current_data = OPERATIONS[op](current_data, args)
221
+ else:
222
+ print(Fore.RED + f"Error! Unknown operation! You can list all operations via --help2!")
223
+ sys.exit(1)
224
+ if args.output_file:
225
+ try:
226
+ with open(args.output_file, "w", encoding="utf-8") as file:
227
+ file.write(current_data)
228
+ print(Style.BRIGHT + f"Output has been written as {args.output_file}!")
229
+ except Exception as e:
230
+ print(Fore.RED + f"Error writing the data :d : {e}")
231
+ sys.exit(1)
232
+ else:
233
+ print(current_data)
234
+ except Exception as e:
235
+ print(Fore.RED + f"Operation failed :( : {e}\nTry adding valid operations and data!")
236
+
237
+ if __name__ == "__main__":
238
+ main()
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: tchef-cli
3
+ Version: 1.0.0
4
+ Summary: A lightweight terminal-based alternative to CyberChef for encoding, decoding, and XOR operations.
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: colorama
8
+
9
+ **TChef** is a powerful, terminal based data manipulation and encoding/decoding tool designed for penetration testers. It can be considered as a lightweight, CLI alternative to CyberChef.
10
+
11
+ TChef allows you to analyze obfuscated data without ever needing Internet and leaving your terminal.
12
+
13
+ ## 👾Features
14
+
15
+ - **⛓Operation Chaining**: Chain multiple operations in a single command (e.g., "-o en_b64, en_rot13)
16
+ - **🔮The MAGIC Module**: Recursively tries every operation in the script to decode the obfuscated data.
17
+ - **🗂Pipe & File I/O Support**: Read, write and pipe data without having any problems!
18
+
19
+
20
+ ## 🔣Supported Operations (for now!)
21
+
22
+ - **🔍Encoding & Decoding**: Base64, Base32, Hex, URL, UTF-8
23
+ - **🔐Cryptography**: XOR, ROT13
24
+ - **🔒Hashing**: MD5, SHA-1, SHA-256, SHA-512
25
+ - and **🔮MAGIC** operator
26
+
27
+ ## 📦Installation
28
+
29
+ Clone the repository and you are ready to go.
30
+
31
+ `git clone https://github.com/kotiaeion2512/Tchef.git`
32
+ `cd Tchef`
33
+ `pip install colorama`
34
+ `chmod +x tchef.py`
35
+
36
+ ## 💡Usage Examples
37
+
38
+ **1. Basic Encoding/Decoding**
39
+
40
+
41
+ ```
42
+ python tchef.py -o en_b64 -d "TopSecret"
43
+ # Output: VG9wU2VjcmV0
44
+ ```
45
+
46
+ **2. Operation Chaining (Recipe)** Decode a Base64 string, then decode the resulting Hex string:
47
+
48
+
49
+ ```
50
+ python tchef.py -o dec_b64,dec_hex -d "NDQ2NTc2Njk2NDZmNzU2Njc1NzI2NTY0M2QzZA=="
51
+ ```
52
+
53
+ **3. XOR Encryption with a Key**
54
+
55
+
56
+ ```
57
+ python tchef.py -o en_xor -k "supersecret" -d "hiddenpayload"
58
+ ```
59
+
60
+ **4. Using the MAGIC Module** Let TChef figure out the nested encoding automatically:
61
+
62
+
63
+ ```
64
+ python tchef.py -o magic -d "NDQ2NTc2Njk2NDZmNzU2Njc1NzI2NTY0M2QzZA=="
65
+ ```
66
+
67
+ **5. File I/O and Pipelining** Read a file, hash it, and save the result:
68
+
69
+
70
+ ```
71
+ python tchef.py -i payload.bin -o hash_sha256 -f checksum.txt
72
+ ```
73
+
74
+ Or use Linux pipes:
75
+
76
+
77
+ ```
78
+ echo "admin" | python tchef.py -o hash_md5
79
+ ```
@@ -0,0 +1,6 @@
1
+ tchef.py,sha256=KnNoBz1JZj5wXInJQT8xb5MZnQYizIaCDHzXUWUl5js,7699
2
+ tchef_cli-1.0.0.dist-info/METADATA,sha256=DCyK6XTbTNLXC1Wd43SkIsPvPkxZH2IWlUpOLGJ2Mqo,2065
3
+ tchef_cli-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
4
+ tchef_cli-1.0.0.dist-info/entry_points.txt,sha256=avg042a59ySeOxGyemQ_lw1je6MwYcxsTSiy94Kh5xU,37
5
+ tchef_cli-1.0.0.dist-info/top_level.txt,sha256=OMTKq1ksXYz2agBGm5CbzYpHOv4bXuAq_IRHvNO-JiY,6
6
+ tchef_cli-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ tchef = tchef:main
@@ -0,0 +1 @@
1
+ tchef