forked from billythegoat356/Kramer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkramer.py
More file actions
196 lines (139 loc) · 6.57 KB
/
kramer.py
File metadata and controls
196 lines (139 loc) · 6.57 KB
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
# by Anferomol
# original: https://github.com/billythegoat356/Kramer
# This Update: https://github.com/Anferomol/KramerDropFiles
from random import choice, randint, shuffle
from pystyle import Add, Center, Anime, Colors, Colorate, Write, System
from os.path import isfile, isdir
from py_compile import compile
from os import listdir, mkdir, remove, rmdir, rename, chdir, name
from shutil import move, copy, rmtree
from time import sleep
from binascii import hexlify
import sys
strings = "abcdefghijklmnopqrstuvwxyz0123456789" # ne pas changer svp
class Kyrie():
def encrypt(e: str):
e = Kyrie._ekyrie(e)
return Kyrie._encrypt(e)
def decrypt(e: str):
text = Kyrie._decrypt(e)
return Kyrie._dkyrie(text)
def _ekyrie(text: str):
r = ""
for a in text:
if a in strings:
a = strings[strings.index(a)-1]
r += a
return r
def _dkyrie(text: str):
r = ""
for a in text:
if a in strings:
i = strings.index(a)+1
if i >= len(strings):
i = 0
a = strings[i]
r += a
return r
def _encrypt(text: str, key: str = None):
if type(key) == str:
key = sum(ord(i) for i in key)
t = [chr(ord(t)+key)if t != "\n" else "ζ" for t in text]
return "".join(t)
def _decrypt(text: str, key: str = None):
if type(key) == str:
key = sum(ord(i) for i in key)
return "".join(chr(ord(t)-key) if t != "ζ" else "\n" for t in text)
class Key:
def encrypt(e: str, key: str):
e1 = Kyrie._ekyrie(e)
return Kyrie._encrypt(e1, key=key)
def decrypt(e: str, key: str):
text = Kyrie._decrypt(e, key=key)
return Kyrie._dkyrie(text)
def ran_int(min: int = 3, max: int = 1000000):
return randint(min, max+1)
def kramer(content: str, key: int) -> str:
_content_ = Key.encrypt(content, key=key)
_lines_sep_ = '/'
content = _lines_sep_.join(hexlify(x.encode()).decode() for x in _content_)
_names_ = ["_eval", "_exec", "_byte", "_bytes", "_bit", "_bits", "_system", "_encode", "_decode", "_delete", "_exit", "_rasputin", "_kramer"]
_names_ = ["self." + name for name in _names_]
shuffle(_names_)
for k in range(12):
globals()[f'n_{str(k+1)}'] = _names_[k]
_types_ = ("str","float","bool","int")
def _find(chars: str): return "+".join(f"_n7_[{list('abcdefghijklmnopqrstuvwxyz0123456789').index(c)}]" for c in chars)
_1_ = fr"""_n5_""",fr"""lambda _n9_:"".join(__import__(_n7_[1]+_n7_[8]+_n7_[13]+_n7_[0]+_n7_[18]+_n7_[2]+_n7_[8]+_n7_[8]).unhexlify(str(_n10_)).decode()for _n10_ in str(_n9_).split('{_lines_sep_}'))"""
_2_ = fr"""_n6_""",r"""lambda _n1_:str(_n4_[_n2_](f"{_n7_[4]+_n7_[-13]+_n7_[4]+_n7_[2]}(''.join(%s),{_n7_[6]+_n7_[11]+_n7_[14]+_n7_[1]+_n7_[0]+_n7_[11]+_n7_[18]}())"%list(_n1_))).encode(_n7_[20]+_n7_[19]+_n7_[5]+_n7_[34])if _n4_[_n2_]==eval else exit()"""
_3_ = fr"""_n4_[_n2_]""",fr"""eval"""
_4_ = fr"""_n1_""",fr"""lambda _n1_:exit()if _n7_[15]+_n7_[17]+_n7_[8]+_n7_[13]+_n7_[19] in open(__file__, errors=_n7_[8]+_n7_[6]+_n7_[13]+_n7_[14]+_n7_[17]+_n7_[4]).read() or _n7_[8]+_n7_[13]+_n7_[15]+_n7_[20]+_n7_[19] in open(__file__, errors=_n7_[8]+_n7_[6]+_n7_[13]+_n7_[14]+_n7_[17]+_n7_[4]).read()else"".join(_n1_ if _n1_ not in _n7_ else _n7_[_n7_.index(_n1_)+1 if _n7_.index(_n1_)+1<len(_n7_)else 0]for _n1_ in "".join(chr(ord(t)-{key})if t!="ζ"else"\n"for t in _n5_(_n1_)))"""
_5_ = fr"""_n7_""",fr"""exit()if _n1_ else'abcdefghijklmnopqrstuvwxyz0123456789'"""
_6_ = fr"""_n8_""",fr"""lambda _n12_:_n6_(_n1_(_n12_))"""
_all_ = [_1_, _2_, _3_, _4_, _5_, _6_]
shuffle(_all_)
_vars_content_ = ",".join(s[0] for s in _all_)
_valors_content_ = ",".join(s[1] for s in _all_)
_vars_ = _vars_content_ + "=" + _valors_content_
_final_content_ = fr"""class Kramer():
def __decode__(self:object,_execute:str)->exec:return(None,_n8_(_execute))[0]
def __init__(self:object,_n1_:{choice(_types_)}=False,_n2_:{choice(_types_)}=0,*_n3_:{choice(_types_)},**_n4_:{choice(_types_)})->exec:
{_vars_}
return self.__decode__(_n4_[(_n7_[-1]+'_')[-1]+_n7_[18]+_n7_[15]+_n7_[0]+_n7_[17]+_n7_[10]+_n7_[11]+_n7_[4]])
Kramer(_n1_=False,_n2_=False,_sparkle='''{content}''')""".strip().replace("_n1_",n_1.removeprefix("self.")).replace("_n2_",n_2.removeprefix("self.")).replace("_n3_",n_3.removeprefix("self.")).replace("_n4_",n_4.removeprefix("self.")).replace("_n5_",n_5).replace("_n6_",n_6).replace("_n7_",n_7).replace("_n8_",n_8).replace("_n9_",n_9.removeprefix("self.")).replace("_n10_",n_10.removeprefix("self.")).replace("_n12_",n_12.removeprefix("self."))
return _final_content_
def main(arg):
_file = arg
if not _file.strip() or not isfile(_file):
Colorate.Error("This file does not exist!")
return input('Press Enter to continue...')
if '\\' in _file:
file = _file.split('\\')[-1]
elif '/' in _file:
file = _file.split('/')[-1]
else:
file = _file
with open(_file, 'r', encoding='utf-8', errors='ignore') as f:
content = f.read()
with open(file, 'w', encoding='utf-8', errors='ignore') as f:
f.write(content)
# key = Write.Input("Enter your encryption key (3 - 1000000) -> ", Colors.red_to_yellow, interval=0.005)
key = ran_int(max=1000000)
try:
key = int(key)
except ValueError:
Colorate.Error("Invalid key!")
return
if key < 3 or key > 1000000:
Colorate.Error("Invalid key!")
return
if 'pyw' in file:
file = file.removesuffix(".pyw") + "-obf.pyw"
else:
file = file.removesuffix(".py") + "-obf.py"
content = kramer(content=content, key=key)
with open(file, 'w', encoding='utf-8') as f:
f.write(content)
compile(file)
logsfolder = "logs"
if isdir(logsfolder):
rmtree(logsfolder)
mkdir(logsfolder)
copy(file, logsfolder)
for _file in listdir("__pycache__"):
move(f"__pycache__/{_file}", ".")
break
sleep(0.025)
rmdir("__pycache__")
if isfile(file):
remove(file)
copy(_file, logsfolder)
rename(logsfolder+ '/' + _file, logsfolder+ '/' + file + 'c')
rename(_file, file)
if __name__ == '__main__':
c = 0
for file in sys.argv:
if c == 0:
c += 1
continue
main(file)