-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxtools.py
666 lines (633 loc) · 19.9 KB
/
xtools.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
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
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
# -*- coding=utf-8 -*-
from sys import stdout
import subprocess as sp
import os, sys, time, random, base64, marshal, getpass, re, zlib
m = '\x1b[1;91m'
u = '\x1b[1;95m'
h = '\x1b[1;92m'
p = '\x1b[1;37m'
k = '\x1b[1;33m'
b = '\x1b[1;34m'
bm = '\x1b[96m'
try:
from uncompyle6.main import decompile
except Exception as e:
sp.call('pip2 install uncompyle6', shell=True, stderr=sp.STDOUT)
red = '\x1b[31m'
green = '\x1b[32m'
yellow = '\x1b[33m'
blue = '\x1b[34m'
magenta = '\x1b[35m'
cyan = '\x1b[36m'
white = '\x1b[37m'
reset = '\x1b[39m'
brblack = '\x1b[90m'
R = '\x1b[91m'
brgreen = '\x1b[92m'
k = '\x1b[93m'
brblue = '\x1b[94m'
brmgnt = '\x1b[95m'
brcyan = '\x1b[96m'
G = '\x1b[97m'
def jalan(z, t):
for e in z:
sys.stdout.write(e)
sys.stdout.flush()
time.sleep(t)
def load(word):
lix = [
'/', '-', '╲', '|']
for i in range(5):
for x in range(len(lix)):
sys.stdout.write(('\r{}{}').format(str(word), lix[x]))
time.sleep(0.2)
sys.stdout.flush()
def banner_dec():
banner = '''{}'''.format(m)
print(banner)
os.system('figlet -f slant "DECRYPT"')
def banner_enc():
banner = '''{}'''.format(m)
print(banner)
os.system('figlet -f slant "ENCRYPT"')
def running(s):
try:
for c in s + '\n':
sys.stdout.write(c)
sys.stdout.flush()
time.sleep(0.001)
except (KeyboardInterrupt,EOFError):
run('Exit!')
def run(x):
pt = '\x1b[1;37m'
rd = '\x1b[1;37m\x1b[1;31m'
rg = '\x1b[6;32m'
try:
num = 0
while num < 1:
for i, char in enumerate(x):
if i == 0:
print '\r%s%s%s%s' % (rg, char.lower(), rd, x[1:]),
sys.stdout.flush()
else:
if i == 1:
okklah = x[0].lower()
print '\r%s%s%s%s%s%s' % (rd, okklah, pt, char.lower(), rg, x[2:]),
sys.stdout.flush()
elif i == i:
okklah = x[0:i].lower()
print '\r%s%s%s%s%s%s' % (rd, okklah, pt, char.lower(), rg, x[i + 1:]),
sys.stdout.flush()
time.sleep(0.07)
num += 1
except:
exit()
def clr():
os.system('clear')
def logo():
banner_enc()
def b_menu():
jalan("""
-----------. .-----------
------ \ __ / ------
----- \( )/ -----
--- ' \/ ` ---
--- : : ---
--` '--
`/`/..\`\`
====UU====UU====
'//||\\`
''``
Dec/Enc Python
""",0.001)
def menu():
clr()
b_menu()
running('\n{}[{}1{}]{} Encrypt\n{}[{}2{}]{} Decrypt\n'.format(m,p,m,p,m,p,m,p,m,p,m,p,m,p,m,p,m,p,m,p))
asww = raw_input('{}[{}?{}]{} Choose {}>> {}'.format(m,p,m,p,k,p))
if asww == '1' or asww == '01':
load('Running...')
menu_enc()
elif asww == '2' or asww == '02':
load('Running...')
menu_dec()
elif asww == '':
run('Huh?')
menu()
else:
run('Please check number options!')
menu()
def menu_enc():
clr()
banner_enc()
running('{}[{}01{}]{} Encrypt Base16'.format(m,p,m,k))
running('{}[{}02{}]{} Encrypt Base32'.format(m,p,m,k))
running('{}[{}03{}]{} Encrypt Base64'.format(m,p,m,k))
running('{}[{}04{}]{} Encrypt Hex'.format(m,p,m,k))
running('{}[{}05{}]{} Encrypt Marshal'.format(m,p,m,k))
running('{}[{}06{}]{} Compile py > pyc'.format(m,p,m,k))
running('{}[{}07{}]{} Encrypt Marshal Zlib Base64'.format(m,p,m,k))
running('{}[{}08{}]{} Encrypt Zlib '.format(m,p,m,k))
running('{}[{}00{}]{} Exit'.format(m,p,m,k))
running('')
try:
inp = raw_input('{}[{}??{}]{} Choose {}>>{} '.format(m,p,m,k,h,p))
except (KeyboardInterrupt,EOFError):
run ('Disable!!')
menu()
if inp == '1' or inp == '01':
clr()
Satu()
elif inp == '2' or inp == '02':
clr()
Dua()
elif inp == '3' or inp == '03':
clr()
Tiga()
elif inp == '4' or inp == '04':
clr()
Empat()
elif inp == '5' or inp == '05':
clr()
Lima()
elif inp == '6' or inp == '06':
clr()
pyc()
elif inp == '7' or inp == '07':
clr()
emzb()
elif inp == '8' or inp == '08':
clr()
ezl()
elif inp == '':
run ('Input your choice!')
time.sleep(2)
menu_enc()
elif inp == '0' or inp == '00':
exit()
else:
run ('Wrong!, Please input your choice')
time.sleep(2)
menu_enc()
def menu_dec():
clr()
banner_dec()
running('{}[{}01{}]{} Decrypt base16'.format(m,p,m,k))
running('{}[{}02{}]{} Decrypt base32'.format(m,p,m,k))
running('{}[{}03{}]{} Decrypt base64'.format(m,p,m,k))
running('{}[{}04{}]{} Decrypt Hex'.format(m,p,m,k))
running('{}[{}05{}]{} Decrypt Marshal'.format(m,p,m,k))
running('{}[{}06{}]{} Uncompyle6 pyc > py'.format(m,p,m,k))
running('{}[{}07{}]{} Decrypt Marshal,Zlib,Base64'.format(m,p,m,k))
running('{}[{}08{}]{} Decrypt Zlib'.format(m,p,m,k))
running('{}[{}00{}]{} Exit'.format(m,p,m,k))
running('')
try:
inp = raw_input('{}[{}??{}]{} Choose {}>>{} '.format(m,p,m,k,h,p))
except (KeyboardInterrupt,EOFError):
run ('Disable!!')
menu()
if inp == '1' or inp == '01':
clr()
Enam()
elif inp == '2' or inp == '02':
clr()
Tujuh()
elif inp == '3' or inp == '03':
clr()
Delapan()
elif inp == '4' or inp == '04':
clr()
Sembilan()
elif inp == '5' or inp == '05':
clr()
unmarsh()
elif inp == '6' or inp == '06':
clr()
unpyc()
elif inp == '7' or inp == '07':
clr()
mzb()
elif inp == '8' or inp == '08':
clr()
zl()
elif inp == '':
run ('Input number!')
time.sleep(2)
menu_dec()
elif inp == '0' or inp == '00':
exit()
else:
run ('Wrong, Input your choice!')
time.sleep(2)
menu_dec()
def Satu():
clr()
logo()
try:
f = raw_input('Filenames: ')
except:
exit()
try:
bk = open(f, 'r').read()
except:
run('file %s not found ' % f)
time.sleep(1.5)
Satu()
en = base64.b16encode(bk)
ff = f + 'c'
open(ff, 'w').write('import base64\nexec(base64.b16decode("%s"))' % en)
nm = ('').join(f.split('.')[:1]) + '-enc.py'
os.rename(ff, nm)
run('file successfully encrypted to %s ' % nm)
def Dua():
clr()
logo()
try:
f = raw_input('Filenames: ')
except:
exit()
try:
bk = open(f, 'r').read()
except:
run('file %s not found ' % f)
exit()
en = base64.b32encode(bk)
ff = f + 'c'
open(ff, 'w').write('import base64\nexec(base64.b32decode("' + en + '"))')
nm = ('').join(f.split('.')[:1]) + '-enc.py'
os.rename(ff, nm)
run('file successfully encrypted to %s ' % nm)
def Tiga():
clr()
logo()
try:
f = raw_input('Filenames: ')
except:
exit()
try:
bk = open(f, 'r').read()
except:
run('file %s not found ' % f)
exit()
en = base64.b64encode(bk)
ff = f + 'c'
open(ff, 'w').write('import base64\nexec(base64.b64decode("' + en + '"))')
nm = ('').join(f.split('.')[:1]) + '-enc.py'
os.rename(ff, nm)
run('file successfully encrypted to %s ' % nm)
def Empat():
clr()
logo()
try:
f = raw_input('Filenames: ')
except:
exit()
try:
bk = open(f, 'r').read()
except:
run('file %s not found ' % f)
exit()
en = bk.encode('hex')
ff = f + 'c'
open(ff, 'w').write('exec("' + en + '").decode("hex")')
nm = ('').join(f.split('.')[:1]) + '-enc.py'
os.rename(ff, nm)
run('file successfully encrypted to %s ' % nm)
def Lima():
clr()
logo()
try:
f = raw_input('Filenames: ')
except:
exit()
try:
bk = open(f, 'r').read()
except:
run('file %s not found ' % f)
exit()
c = compile(bk, '<okklah>', 'exec')
en = marshal.dumps(c)
ff = f + 'c'
open(ff, 'w').write('import marshal\nexec(marshal.loads(' + repr(en) + '))')
nm = ('').join(f.split('.')[:1]) + '-enc.py'
os.rename(ff, nm)
run('file successfully encrypted to %s ' % nm)
def emzb():
clr()
logo()
try:
file = raw_input('File: ')
fileopen = open(file).read()
no = compile(fileopen,'aso','exec')
b = marshal.dumps(no)
c = zlib.compress(b)
d = base64.b64encode(c)
e = ('import marshal,zlib,base64\nexec(marshal.loads(zlib.decompress(base64.b64decode("' + d + '"))))')
f = file.replace('.py', '-enc.py')
g = open(f, 'w')
g.write(e)
g.close()
run('file successfully encrypted to %s ' % f)
raw_input('Press Enter To Return To Menu ')
menu()
except IOError:
run('File not found ')
raw_input('Press Enter To Return To Menu ')
emzb()
def ezl():
print "Encrypt Zlib"
file = raw_input('File : ')
out = file.replace('.py', '-enc.py')
oa = open(file).read()
xs = zlib.compress(oa)
s = open(out, 'w')
s.write('import zlib\nexec(zlib.decompress(' +repr(xs)+ '))')
s.close()
print ('File saved as '+ out)
def Enam():
clr()
banner_dec()
try:
print 'Dec base64.b16decocde'
f = raw_input('Filenames: ')
except:
exit()
try:
bk = open(f, 'r').read()
except:
run('file %s not found ' % f)
exit()
bk = bk.replace('exec(base64.b16decode("', '')
bk = bk.replace('"))', '')
bk = bk.replace('import base64\n', '')
en = base64.b16decode(bk)
ff = f + 'c'
open(ff, 'w').write(en)
nm = ('').join(f.split('.')[:1]) + '-decrypt.py'
os.rename(ff, nm)
run('file successfully decrypted to %s' % nm)
def Tujuh():
clr()
banner_dec()()
try:
print 'Dec base64.b32decode'
f = raw_input('Filenames: ')
except:
exit()
try:
bk = open(f, 'r').read()
except:
run('file %s not found ' % f)
exit()
bk = bk.replace('exec(base64.b32decode("', '')
bk = bk.replace('"))', '')
bk = bk.replace('import base64\n', '')
en = base64.b32decode(bk)
ff = f + 'c'
open(ff, 'w').write(en)
nm = ('').join(f.split('.')[:1]) + '-decrypt.py'
os.rename(ff, nm)
run('file successfully decrypted to %s' % nm)
def Delapan():
clr()
banner_dec()
try:
print 'Dec base64.b64decode'
f = raw_input('Filenames: ')
except:
exit()
try:
bk = open(f, 'r').read()
except:
run('file %s not found ' % f)
exit()
bk = bk.replace(+'exec(base64.b64decode("', '')
bk = bk.replace('"))', '')
bk = bk.replace('import base64\n', '')
en = base64.b64decode(bk)
ff = f + 'c'
open(ff, 'w').write(en)
nm = ('').join(f.split('.')[:1]) + '-decrypt.py'
os.rename(ff, nm)
run('file successfully decrypted to %s' % nm)
def Sembilan():
clr()
banner_dec()
try:
print 'Dec hex'
f = raw_input('Filenames: ')
except:
exit()
try:
bk = open(f, 'r').read()
except:
run('file %s not found ' % f)
exit()
bk = bk.replace('exec("', '') or bk.replace("exec('", '')
bk = bk.replace('").decode("hex")', '') or bk.replace("').decode('hex')", '')
en = str(bk).decode('hex')
ff = f + 'c'
open(ff, 'w').write(en)
nm = ('').join(f.split('.')[:1]) + '-decrypt.py'
os.rename(ff, nm)
run('file successfully decrypted to %s' % nm)
def unmarsh():
jalan(p + 31 * '\xe2\x95\x90' + h + '[' + bm + 'UNMARSH' + h + ']' + p + '>', 0.008)
print h + '\nMenu ' + p + ':\n [' + h + '1' + p + ']. Automatic Detection Version Script\n [' + h + '2' + p + ']. Back To Menu'
try:
pil = raw_input(h + '[' + k + '?' + h + ']' + p + ' Choice--> ')
except IOError:
unmarsh()
else:
if pil == '1':
pass
elif pil == '2':
menu()
else:
print h + '[' + m + '!' + h + ']' + p + ' Choose the right one'
unmarsh()
cek = 1
try:
print h + '[' + k + '#' + h + ']' + p + ' For Example : /path/marsh.py'
file = raw_input(h + '[' + k + '?' + h + ']' + p + ' Input File : ')
f = open(file, 'r').readlines()
for i in range(len(f)):
if f[i][0:4] == 'exec':
if f[i][19] == 'b':
cek = 3
elif f[i][20] == 'c':
cek = 2
else:
cek = 1
except IndexError:
print h + '[' + m + '!' + h + ']' + p + ' Program Error!!!'
sys.exit()
except KeyboardInterrupt:
print h + '[' + k + '^' + h + ']' + p + ' ctrl+c \n'
print h + '[' + k + '#' + h + ']' + p + ' Exit!!!\n'
time.sleep(3)
sys.exit()
except EOFError:
print h + '[' + k + '^' + h + ']' + p + ' ctrl+d \n'
print h + '[' + k + '#' + h + ']' + p + ' Exit!!!\n'
time.sleep(3)
sys.exit()
else:
try:
string = open(file, 'r').read()
except IOError:
print '\n' + h + '[' + m + '!' + h + ']' + p + ' File Not Found'
raw_input(h + '[' + k + '^' + h + ']' + p + ' Press Enter to Return to the menu ')
os.system('clear')
menu()
if cek == 2:
py = 'python2'
dec = 'decompile(2.7, x, stdout)'
sys.stdout.write(h + '[' + k + '#' + h + ']')
jalan(p + ' check the script version', 0.1)
time.sleep(1.5)
print '\n' + h + '[' + m + '*' + h + ']' + p + ' python version 2 was detected'
time.sleep(1)
try:
x = re.search('((?<![\\\\])[\\\'"])((?:.(?!(?<![\\\\])\\1))*.?)\\1', string).group()
except Exception as e:
raise e
elif cek == 3:
py = 'python3'
dec = 'decompile(3.8, x, stdout)'
sys.stdout.write(h + '[' + k + '#' + h + ']')
jalan(p + ' check the script version', 0.1)
time.sleep(1.5)
print '\n' + h + '[' + m + '*' + h + ']' + p + ' python version 3 was detected'
time.sleep(1)
try:
x = 'b' + re.search('((?<![\\\\])[\\\'"])((?:.(?!(?<![\\\\])\\1))*.?)\\1', string).group()
except Exception as e:
raise e
else:
print h + '[' + m + '!' + h + ']' + p + ' File Not Suport'
raw_input(h + '[' + k + '^' + h + ']' + p + ' Press Enter to Return to the menu ')
menu()
fileout = open('un.py', 'w')
fileout.write('from sys import stdout\nfrom uncompyle6.main import decompile\nimport marshal\n\n')
fileout.write('x = marshal.loads(' + x + ')\n')
fileout.write(dec)
fileout.close()
load(h + '[' + k + '#' + h + ']' + p + ' Unmarshal process Wait a minute ...')
sp.call(py + ' un.py > unpyc/dec.py', shell=True, stderr=sp.STDOUT)
os.system('rm un.py')
os.system('clear')
time.sleep(1)
delay = open('unpyc/dec.py', 'r').readlines()
for x in range(len(delay)):
jalan(delay[x], 0.0001)
print '\n\n' + h + '[' + k + '#' + h + ']' + p + ' Successfully Decompiled'
print h + '[' + k + '#' + h + ']' + p + ' file saved : unpyc/dec.py'
ask = raw_input(h + '[' + k + '?' + h + ']' + p + ' Decompile Again? y/t ')
if ask == 'y' or ask == 'Y':
menu()
elif ask == 't' or ask == 'T':
sys.exit()
else:
print h + '[' + m + '!' + h + ']' + p + ' Choose the right one ' + m + '!!!'
raw_input(h + '[' + k + '^' + h + ']' + p + ' Press Enter to Return to the menu ')
os.system('clear')
def pyc():
print m + '[' + p + '#' + m + ']' + p + ' For Example : /path/marsh.py'
f = raw_input(m + '[' + p + '?' + m + ']' + p + ' Enter Your File : ')
from py_compile import compile
compile(f)
load(m + '[' + p + '#' + m + ']' + p + ' Compile process Wait a minute ...')
jalan('\n' + m + '[' + p + '#' + m + ']' + p + ' file successfully compiled', 0.01)
print '\n' + m + '[' + p + '#' + m + ']' + p + (' File Saved: {}c').format(f)
ask = raw_input(m + '[' + p + '?' + m + ']' + p + ' Compile Again? y/t >> ')
if ask == 'y' or ask == 'Y':
menu()
elif ask == 't' or ask == 'T':
sys.exit()
else:
print m + '[' + m + '!' + m + ']' + p + ' Choose the right one ' + m + '!!!'
raw_input(m + '[' + p + '^' + m + ']' + p + ' Press Enter to Return to the menu ')
os.system('clear')
menu()
def unpyc():
print m + '[' + p + '#' + m + ']' + p + ' For Example : /path/file.pyc'
f = raw_input(m + '[' + p + '?' + m + ']' + p + ' Enter Your File : ')
try:
open(f, 'r').read()
except IOError:
print m + '[' + m + '!' + m + ']' + p + ' File Not Found'
raw_input(m + '[' + p + '^' + m + ']' + p + ' Press Enter to Return to the menu ')
menu()
else:
load(m + '[' + p + '#' + m + ']' + p + ' Decompile process Wait a minute ...')
try:
os.system('uncompyle6 ' + f + '> unpyc/jadi.py')
except Exception as e:
print m + '[' + m + '!' + m + ']' + p + ' Failed to decompile because : ' + e
print '\n\n' + m + '[' + p + '#' + m + ']' + p + ' Successfully Decompiled'
print m + '[' + p + '#' + m + ']' + p + ' file saved : unpyc/jadi.py'
ask = raw_input(m + '[' + p + '?' + m + ']' + p + ' Decompile Again? y/t >> ')
if ask == 'y' or ask == 'Y':
menu()
elif ask == 't' or ask == 'T':
sys.exit()
else:
print m + '[' + m + '!' + m + ']' + p + ' Choose the right one ' + m + '!!!'
raw_input(m + '[' + p + '^' + m + ']' + p + ' Press Enter to Return to the menu ')
os.system('clear')
menu()
def mzb():
print 'Decompile Marshal,Zlib,Base64'
a = raw_input('File : ' )
b = open(a).read().replace('exec(', 'x = ').replace('))))',')))')
c = open('mi.py', 'w')
if 'marshal' in b:
c.write('from sys import stdout\nfrom uncompyle6.main import decompile\n' + b + '\ndecompile(2.7, x, stdout)')
c.close()
elif 'marshal' not in b:
c.write(b + '\nprint (x)')
c.close()
d = a.replace('.py', '-decrypt.py')
os.system('python2 mi.py > ' + d)
e = open(d).read()
f = open(d, 'w')
f.write(e + ' \n\n\n\t')
f.close()
os.system('rm -rf mi.py')
print('\x1b[31;1m[\x1b[0;37m+\x1b[31;1m]\x1b[0;37m File saved as\x1b[32;1m ' + d)
print('Want Decrypt Again (Y/N) ?')
cuk = raw_input('Choice : ')
if cuk == 'y':
mzb()
elif cuk == 'n':
exit()
def zl():
print 'Decompile Zlib'
a = raw_input('File : ')
b = open(a).read().replace('exec', 'print')
c = open('ma.py', 'w')
if 'zlib' in b:
c.write('\n' + b + '')
c.close()
elif 'zlib' not in b:
c.write(b + '\nprint (print)')
c.close()
d = a.replace('.py', '-decrypt.py')
os.system('python2 ma.py > '+ d)
f = open(d, 'w')
f.write('# Suksess Decompile ✓ \n'+ e)
f.close()
os.system('rm -rf ma.py')
print('File saved as '+ d)
sys.exit()
def exit():
run('thanks for using my tools dude :)')
sys.exit()
if __name__ == '__main__':
if os.path.exists('unpyc'):
menu()
else:
os.system('mkdir unpyc')
menu()