forked from SubGlitch1/OSRipper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobfuscator.py
87 lines (75 loc) · 2.48 KB
/
obfuscator.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
import os
import sys
import zlib
import time
import base64
import marshal
import py_compile
import random
import secrets
a=random.randint(50,70)
randint = UltimateRandomNumberlow2 = secrets.randbelow(2)
if sys.version_info[0]==2:
_input = "raw_input('%s')"
elif sys.version_info[0]==3:
_input = "input('%s')"
zlb = lambda in_ : zlib.compress(in_)
b16 = lambda in_ : base64.b16encode(in_)
b32 = lambda in_ : base64.b32encode(in_)
b64 = lambda in_ : base64.b64encode(in_)
mar = lambda in_ : marshal.dumps(compile(in_,'<x>','exec'))
class FileSize:
def datas(self,z):
for x in ['Byte','KB','MB','GB']:
if z < 1024.0:
return "%3.1f %s" % (z,x)
z /= 1024.0
def __init__(self,path):
if os.path.isfile(path):
dts = os.stat(path).st_size
print('\n')
print(" [-] Encoded File Size : %s\n" % self.datas(dts))
def Encode(data,output):
loop = int(eval(str(a)))
x1 = "b32(zlb(data.encode('utf8')))[::-1]"
heading1 = "_ = lambda __ : __import__('zlib').decompress(__import__('base64').b32decode(__[::-1]));"
x2 = "b64(zlb(data.encode('utf8')))[::-1]"
heading2 = "_ = lambda __ : __import__('zlib').decompress(__import__('base64').b64decode(__[::-1]));"
for x in range(loop):
try:
data = "exec((_)(%s))" % repr(eval(x1))
except TypeError as s:
sys.exit(" TypeError : " + str(s))
ab=(heading1 + data)
for x in range(loop):
try:
data = "exec((_)(%s))" % repr(eval(x2))
except TypeError as s:
sys.exit(" TypeError : " + str(s))
abc=(heading2 + ab)
with open(output, 'w') as f:
f.write(abc)
f.close()
def SEncode(data,output):
for x in range(5):
method = repr(b64(zlb(mar(data.encode('utf8'))))[::-1])
data = "exec(__import__('marshal').loads(__import__('zlib').decompress(__import__('base64').b64decode(%s[::-1]))))" % method
z = []
for i in data:
z.append(ord(i))
sata = "_ = %s\nexec(''.join(chr(__) for __ in _))" % z
with open(output, 'w') as f:
f.write("exec(str(chr(35)%s));" % '+chr(1)'*10000)
f.write(sata)
f.close()
py_compile.compile(output,output)
def MainMenu(file):
try:
data = open(file).read()
except IOError:
sys.exit("\n File Not Found!")
output = file.lower().replace('.py', '') + '_or.py'
Encode(data,output)
FileSize(output)
if __name__ == "__main__":
MainMenu()