-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCryptoRusse.py
576 lines (570 loc) · 22 KB
/
CryptoRusse.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
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
# coding: utf-8
import random, string, base64, binascii, codecs, time, sys, os, hashlib
from base64 import b64encode, b64decode, b32encode, b32decode, b16encode, b16decode
from Crypto.Cipher import AES
from termcolor import colored
def stop():
print(colored('[!] Stopping CryptoRusse...', 'red'))
time.sleep(0.5)
print('[!] Good bye !')
sys.exit()
def stop2():
print(colored('\n[!] Stopping CryptoRusse...', 'red'))
time.sleep(0.5)
print('[!] Good bye !')
sys.exit()
def hashes():
print('[1] MD5 Encrypt text')
print('[2] SHA-1 Encrypt text')
print('[3] SHA-224 Encrypt text')
print('[4] SHA-256 Encrypt text')
print('[5] SHA-384 Encrypt text')
print('[6] SHA-512 Encrypt text')
print('[7] SHA3-224 Encrypt text')
print('[8] SHA3-256 Encrypt text')
print('[9] SHA3-384 Encrypt text')
print('[10] SHA3-512 Encrypt text')
print('[11] SHAKE-128 Encrypt text')
print('[12] SHAKE-256 Encrypt text')
print('[13] BLAKE2b Encrypt text')
print('[14] BLAKE2s Encrypt text')
print('[15] Go to main menu')
while 1:
x = input('[*]>>')
if x == '1':
print('[?] Type the text you want to encrypt into MD5')
a = input('[*]>>')
print('[!] This is the encrypted text into MD5 :', hashlib.md5(a.encode('utf-8')).hexdigest())
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif x == '2':
print('[?] Type the text you want to encrypt into SHA-1')
a = input('[*]>>')
print('[!] This is the encrypted text into SHA-1 :', hashlib.sha1(a.encode('utf-8')).hexdigest())
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif x == '3':
print('[?] Type the text you want to encrypt in SHA-224')
a = input('[*]>>')
print('[!] This is the encrypted text into SHA-224 :', hashlib.sha224(a.encode('utf-8')).hexdigest())
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif x == '4':
print('[?] Type the text you want to encrypt in SHA-256')
a = input('[*]>>')
print('[!] This is the encrypted text into SHA-256 :', hashlib.sha256(a.encode('utf-8')).hexdigest())
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif x == '5':
print('[?] Type the text you want to encrypt into SHA-384')
a = input('[*]>>')
print('[!] This is the encrypted text into SHA-384 :', hashlib.sha384(a.encode('utf-8')).hexdigest())
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif x == '6':
print('[?] Type the text you want to encrypt into SHA-512')
a = input('[*]>>')
print('[!] This is the encrypted text into SHA-512 :', hashlib.sha512(a.encode('utf-8')).hexdigest())
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif x == '7':
print('[?] Type the text you want to encrypt into SHA3-224')
a = input('[*]>>')
print('[!] This is the encrypted text into SHA3-224 :', hashlib.sha3_224(a.encode('utf-8')).hexdigest())
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif x == '8':
print('[?] Type the text you want to encrypt into SHA3-256')
a = input('[*]>>')
print('[!] This is the encrypted text into SHA3-256 :', hashlib.sha3_256(a.encode('utf-8')).hexdigest())
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif x == '9':
print('[?] Type the text you want to encrypt into SHA3-384')
a = input('[*]>>')
print('[!] This is the encrypted text into SHA3-384 :', hashlib.sha3_384(a.encode('utf-8')).hexdigest())
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif x == '10':
print('[?] Type the text you want to encrypt into SHA3-512')
a = input('[*]>>')
print('[!] This is the encrypted text into SHA3-512 :', hashlib.sha3_512(a.encode('utf-8')).hexdigest())
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif x == '11':
print('[?] Type the text you want to encrypt into SHAKE-128 (256 lenght)')
a = input('[*]>>')
print('[?] Output bits (512 bits = 128 letters and numbers, 1024 bits = 256 letters and numbers, bits ÷ 4 = numbers and letters)')
n = input('[*]>>')
print('[!] This is the encrypted text into SHAKE-128 :', hashlib.shake_128(a.encode('utf-8')).hexdigest(int(int(n)/4/2)))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif x == '12':
print('[?] Type the text you want to encrypt into SHAKE-256')
a = input('[*]>>')
print('[?] Output bits (512 bits = 128 letters and numbers, 1024 bits = 256 letters and numbers, bits ÷ 4 = numbers and letters)')
n = input('[*]>>')
print('[!] This is the encrypted text into SHAKE-256 :', hashlib.shake_256(a.encode('utf-8')).hexdigest(int(int(n)/4/2)))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif x == '13':
print('[?] Type the text you want to encrypt into BALKE2b (256 lenght)')
a = input('[*]>>')
print('[!] This is the encrypted text into BLAKE2b :', hashlib.blake2b(a.encode('utf-8')).hexdigest())
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif x == '14':
print('[?] Type the text you want to encrypt into BALKE2s (256 lenght)')
a = input('[*]>>')
print('[!] This is the encrypted text into BLAKE2s :', hashlib.blake2s(a.encode('utf-8')).hexdigest())
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif x == '15':
mainmenu()
else:
print(colored('[!] You need to choose a number between 1 and 15', 'red'))
def aes():
#### ENCRYPT ####
print('[1] Encode a message with AES')
print('[2] Decode a message with AES')
print('[3] Go to main menu')
while 1:
choix = input('[*]>>')
if choix == '1':
print('[?] Type the message which will be encrypted')
msg = input('[*]>>')
print('[1] Custom key and IV')
print('[2] Random key and IV')
while 1:
choixx = input('[*]>>')
if choixx == '2':
key = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for x in range(32))
iv = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for x in range(16))
encodage = AES.new(key, AES.MODE_CFB, iv)
chiffre = encodage.encrypt(msg)
print('[1] Output in Base64')
print('[2] Output in Hex')
while 1:
g = input('[*]>>')
if g == '1':
print('[!] This is the key : ' + key)
print('[!] This is the IV : ' + iv)
print('[!] This is the encoded message :', base64.b64encode(chiffre).decode("utf-8"))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif g == '2':
print('[!] This is the key : ' + key)
print('[!] This is the IV : ' + iv)
print('[!] This is the encoded message :', binascii.hexlify(chiffre).decode("utf-8"))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif choixx == '1':
print('[?] Type the key which will be used in encryption (32 characters only)')
key = input('[*]>>')
print('[?] Type the IV that will be used in encryption (16 characters only)')
iv = input('[*]>>')
encodage = AES.new(key, AES.MODE_CFB, iv)
chiffre = encodage.encrypt(msg)
print('[?] Which output do you want')
print('[1] Output in Base64')
print('[2] Output in Hex')
while 1:
g = input('[*]>>')
if g == '1':
print('[!] This is the key : ' + key)
print('[!] This is the IV : ' + iv)
print('[!] This is the encoded message :', base64.b64encode(chiffre).decode("utf-8"))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif g == '2':
print('[!] This is the key : ' + key)
print('[!] This is the IV : ' + iv)
print('[!] This is the encoded message :', binascii.hexlify(chiffre).decode("utf-8"))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
#### DECRYPT ####
elif choix == '2':
print('[?] Type the message which will be decrypted')
msg = input('[*]>>')
print('[?] Type the key which will be used in decryption (32 characters only)')
key = input('[*]>>')
print('[?] Type the IV which will be used in decryption (16 characters only)')
iv = input('[*]>>')
print('[?] What is the input format')
print('[1] Base64 input')
print('[2] Hex input')
while 1:
inputn = input('[*]>>')
if inputn == '2':
decryption_options = AES.new(key, AES.MODE_CFB, iv)
decryption = decryption_options.decrypt(codecs.decode(msg, "hex"))
print('[!] This is the key : ' + key)
print('[!] This is the IV : ' + iv)
print('[!] This is the decrypted message :',decryption.decode("utf-8"))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif inputn == '1':
decryption_options = AES.new(key, AES.MODE_CFB, iv)
decryption = decryption_options.decrypt(base64.b64decode(msg))
print('[!] This is the key : ' + key)
print('[!] This is the IV : ' + iv)
print('[!] This is the decrypted message :',decryption.decode("utf-8"))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif choix == '3':
mainmenu()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
def base():
print('[1] Encrypt/Decrypt text in/from Base64')
print('[2] Encrypt/Decrypt text in/from Base32')
print('[3] Encrypt/Decrypt text in/from Base16')
print('[4] Encrypt/Decrypt text in/from Hex')
print('[5] Go to main menu')
while 1:
cchoice = input('[*]>>')
if cchoice == '1':
print('[1] Encrypt text in Base64')
print('[2] Decrypt text from Base64')
while 1:
basee = input('[*]>>')
if basee == '1':
print('[?] Type the text you want to encrypt in Base64')
textt = input('[*]>>')
print('[!] This is the text encoded in Base64 :', b64encode(textt.encode('utf-8')).decode('utf-8'))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif basee == '2':
print('[?] Type the text you want to decrypt from Base64')
textt = input('[*]>>')
print('[!] This is the text decoded from Base64 :', b64decode(textt.encode('utf-8')).decode('utf-8'))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif cchoice == '2':
print('[1] Encrypt text in Base32')
print('[2] Decrypt text from Base32')
while 1:
basee = input('[*]>>')
if basee == '1':
print('[?] Type the text you want to encrypt in Base32')
textt = input('[*]>>')
print('[!] This is the text encoded in Base32 :', b32encode(textt.encode('utf-8')).decode('utf-8'))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif basee == '2':
print('[?] Type the text you want to decrypt from Base32')
textt = input('[*]>>')
print('[!] This is the text decoded from Base32 :', b32decode(textt.encode('utf-8')).decode('utf-8'))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif cchoice == '3':
print('[1] Encrypt text in Base16')
print('[2] Decrypt text from Base16')
while 1:
basee = input('[*]>>')
if basee == '1':
print('[?] Type the text you want to encrypt in Base16')
textt = input('[*]>>')
print('[!] This is the text encoded in Base16 :', b16encode(textt.encode('utf-8')).decode('utf-8'))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif basee == '2':
print('[?] Type the text you want to decrypt from Base16')
textt = input('[*]>>')
print('[!] This is the text decoded from Base16 :', b16decode(textt.encode('utf-8')).decode('utf-8'))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif cchoice == '4':
print('[1] Encrypt text in Hex')
print('[2] Decrypt text from Hex')
while 1:
basee = input('[*]>>')
if basee == '1':
print('[?] Type the text you want to encrypt in Hex')
textt = input('[*]>>')
print('[!] This is the encoded text in Hex :', codecs.encode(textt.encode('utf-8'), 'hex').decode('utf-8'))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif basee == '2':
print('[?] Type the text you want to decrypt from Hex')
textt = input('[*]>>')
print('[!] This is the decoded text from Hex :', codecs.decode(textt.encode('utf-8'), 'hex').decode('utf-8'))
print('[1] Go to the main menu')
print('[2] Quit CryptoRusse')
while 1:
finalchoice = input('[*]>>')
if finalchoice == '1':
mainmenu()
elif finalchoice == '2':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
elif cchoice == '5':
mainmenu()
else:
print(colored('[!] You need to choose a number between 1 and 5', 'red'))
def mainmenu():
try:
if sys.platform == 'win32':
os.system("cls")
elif sys.platform == 'linux2':
os.system('clear')
print(' ██████╗██████╗ ██╗ ██╗██████╗ ████████╗ ██████╗ ██████╗ ██╗ ██╗███████╗███████╗███████╗')
print('██╔════╝██╔══██╗╚██╗ ██╔╝██╔══██╗╚══██╔══╝██╔═══██╗██╔══██╗██║ ██║██╔════╝██╔════╝██╔════╝')
print('██║ ██████╔╝ ╚████╔╝ ██████╔╝ ██║ ██║ ██║██████╔╝██║ ██║███████╗███████╗█████╗ ')
print('██║ ██╔══██╗ ╚██╔╝ ██╔═══╝ ██║ ██║ ██║██╔══██╗██║ ██║╚════██║╚════██║██╔══╝ ')
print('╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝██║ ██║╚██████╔╝███████║███████║███████╗')
print(' ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚══════╝╚══════╝')
print('[!] Script by', colored('JeSuisRusse', 'red'))
print('[!]',colored('CTRL+C', 'red'), 'to quit CryptoRusse')
print('[1] Encode/Decode a message with AES methode (256 bits, CFB methode)')
print('[2] Encrypt with Hashes (MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA3-224, SHA3-256, SHA3-384, SHA3-512, BLAKE2b, BLAKE2s, SHAKE-128, SHAKE-256)')
print('[3] Encrypt/Decrypt text in/from Base64, Base32, Base16, Hex')
print('[4] Exit CryptoRusse')
while 1:
choixxx = input("[*]>>")
if choixxx == '1':
aes()
elif choixxx == '2':
hashes()
elif choixxx == '3':
base()
elif choixxx == '4':
stop()
else:
print(colored('[!] You need to choose a number (1 or 2)', 'red'))
except KeyboardInterrupt:
stop2()
mainmenu()