Skip to content

Commit d1ba28e

Browse files
committed
Improved UI
1 parent e6a2a48 commit d1ba28e

File tree

4 files changed

+260
-292
lines changed

4 files changed

+260
-292
lines changed

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
### [+] Installation
99

10-
```apt install python3```
10+
```apt install python```
1111

1212
```git clone https://github.com/KasRoudra/k-fuscator```
1313

@@ -17,12 +17,12 @@
1717

1818
```bash requirements.sh```
1919

20-
```python3 ob.py```
20+
```python3 kf.py```
2121

2222

2323
### Or, Use Single Command
2424
```
25-
apt install python3 && git clone https://github.com/KasRoudra/k-fuscator && cd k-fuscator && bash requirements.sh && python3 ob.py
25+
apt install python && git clone https://github.com/KasRoudra/k-fuscator && cd k-fuscator && bash requirements.sh && python3 kf.py
2626
```
2727

2828
### Features:
@@ -36,7 +36,6 @@ apt install python3 && git clone https://github.com/KasRoudra/k-fuscator && cd k
3636

3737
<img src="https://github.com/KasRoudra/k-fuscator/raw/main/main.jpeg">
3838

39-
4039
#### Bash Source Code
4140

4241
<img src="https://github.com/KasRoudra/k-fuscator/raw/main/screenshots/source-bash.jpeg">
@@ -61,9 +60,6 @@ apt install python3 && git clone https://github.com/KasRoudra/k-fuscator && cd k
6160

6261
<img src="https://github.com/KasRoudra/k-fuscator/raw/main/screenshots/variable-encryption.jpeg">
6362

64-
### [+] Encrypted/Decrypted file will be found in current directory!
65-
66-
6763
## This repository is open source to help others. So if you wish to copy, consider giving credit!
6864

6965
### Credits: <a href="https://github.com/H3LLO-H4CK3R-2/Bash-Encrypt">H3LL0-H4CK3R</a> and <a href="https://github.com/wodxgod/Simple-obfuscator">WodxGod</a> and <a href="https://github.com/chris-rands/emojify">Chris-Rands</a>

kf.py

Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
# K-fuscator
2+
3+
# Author : KasRoudra
4+
# Github : https://github.com/KasRoudra
5+
# Contact : https://m.me/KasRoudra
6+
7+
# Encrypt(obfuscate) or decrypt bash/shell script or compile python script
8+
9+
import os, base64, sys, time
10+
from pprint import pformat
11+
alphabet = [
12+
"\U0001f600",
13+
"\U0001f603",
14+
"\U0001f604",
15+
"\U0001f601",
16+
"\U0001f605",
17+
"\U0001f923",
18+
"\U0001f602",
19+
"\U0001f609",
20+
"\U0001f60A",
21+
"\U0001f61b",
22+
]
23+
MAX_STR_LEN = 70
24+
OFFSET = 10
25+
26+
black="\033[0;30m"
27+
red="\033[0;31m"
28+
green="\033[0;32m"
29+
yellow="\033[0;33m"
30+
blue="\033[0;34m"
31+
purple="\033[0;35m"
32+
cyan="\033[0;36m"
33+
white="\033[0;37m"
34+
35+
ask = green + '\n[' + white + '?' + green + '] '+ yellow
36+
success = green + '\n[' + white + '√' + green + '] '
37+
error = red + '\n[' + white + '!' + red + '] '
38+
info= yellow + '\n[' + white + '+' + yellow + '] '+ cyan
39+
40+
pwd=os.getcwd()
41+
42+
logo='''
43+
'''+green +''' _ __ _____ _
44+
'''+yellow+'''| |/ / | ___| _ ___ ___ __ _| |_ ___ _ __
45+
'''+red +'''| ' /_____| |_ | | | / __|/ __/ _` | __/ _ \| '__|
46+
'''+blue +'''| . \_____| _|| |_| \__ \ (_| (_| | || (_) | |
47+
'''+cyan +'''|_|\_\ |_| \__,_|___/\___\__,_|\__\___/|_|
48+
'''+purple+''' [By KasRoudra]
49+
50+
'''
51+
52+
def slowprint(n):
53+
for word in n + '\n':
54+
sys.stdout.write(word)
55+
sys.stdout.flush()
56+
time.sleep(0.01)
57+
def sprint(n):
58+
for word in n + '\n':
59+
sys.stdout.write(word)
60+
sys.stdout.flush()
61+
time.sleep(0.05)
62+
63+
def about():
64+
os.system("clear")
65+
slowprint(logo)
66+
print(cyan+'[ToolName] '+purple+' :[K-fuscator] ')
67+
print(cyan+'[Version] '+purple+' :[1.0]')
68+
print(cyan+'[Author] '+purple+' :[KasRoudra] ')
69+
print(cyan+'[Github] '+purple+' :[https://github.com/KasRoudra] ')
70+
print(cyan+'[Messenger] '+purple+' :[https://m.me/KasRoudra]')
71+
print(cyan+'[Email] '+purple+' :[[email protected]]\n')
72+
ret=input(ask+"1 for main menu, 0 for exit > "+green)
73+
if ret=="1":
74+
main()
75+
else:
76+
exit()
77+
def mover(out_file):
78+
move= input(ask+"Move to a custom path?(y/n) > "+green)
79+
if move=="y":
80+
mpath=input(ask+"Enter the path > "+ green)
81+
if os.path.exists(mpath):
82+
os.system("mv -f '"+out_file+"' '"+mpath+"'")
83+
sprint(success+out_file+" moved to "+mpath+"\n")
84+
exit()
85+
else:
86+
sprint(error+"Path do not exist!\n")
87+
exit()
88+
else:
89+
print("\n")
90+
exit()
91+
exit()
92+
def obfuscate(VARIABLE_NAME, file_content):
93+
b64_content = base64.b64encode(file_content.encode()).decode()
94+
index = 0
95+
code = f'{VARIABLE_NAME} = ""\n'
96+
for _ in range(int(len(b64_content) / OFFSET) + 1):
97+
_str = ''
98+
for char in b64_content[index:index + OFFSET]:
99+
byte = str(hex(ord(char)))[2:]
100+
if len(byte) < 2:
101+
byte = '0' + byte
102+
_str += '\\x' + str(byte)
103+
code += f'{VARIABLE_NAME} += "{_str}"\n'
104+
index += OFFSET
105+
code += f'exec(__import__("\\x62\\x61\\x73\\x65\\x36\\x34").b64decode({VARIABLE_NAME}.encode("\\x75\\x74\\x66\\x2d\\x38")).decode("\\x75\\x74\\x66\\x2d\\x38"))'
106+
return code
107+
108+
109+
def chunk_string(in_s, n):
110+
"""Chunk string to max length of n"""
111+
return "\n".join(
112+
"{}\\".format(in_s[i : i + n]) for i in range(0, len(in_s), n)
113+
).rstrip("\\")
114+
115+
116+
def encode_string(in_s, alphabet):
117+
d1 = dict(enumerate(alphabet))
118+
d2 = {v: k for k, v in d1.items()}
119+
return (
120+
'exec("".join(map(chr,[int("".join(str({}[i]) for i in x.split())) for x in\n'
121+
'"{}"\n.split(" ")])))\n'.format(
122+
pformat(d2),
123+
chunk_string(
124+
" ".join(" ".join(d1[int(i)] for i in str(ord(c))) for c in in_s),
125+
MAX_STR_LEN,
126+
),
127+
)
128+
)
129+
130+
131+
def encryptsh():
132+
in_file = input(ask + "Input Filename > "+cyan)
133+
if not os.path.exists(in_file):
134+
sprint(error+'File not found')
135+
os.system("sleep 2")
136+
encryptsh()
137+
os.system("bash-obfuscate " + in_file + " -o .temp")
138+
if not os.path.exists(".temp"):
139+
try:
140+
sprint(info+"Installing Bash-Obfuscate....\n")
141+
os.system("apt install nodejs -y && npm install -g bash-obfuscate")
142+
os.system("bash-obfuscate " + in_file + " -o .temp")
143+
except:
144+
sprint(error+" Bash-Obfuscate not installed! Install it by:\n"+green+"[+] \"apt install nodejs -y && npm install -g bash-obfuscate\"")
145+
exit(1)
146+
out_file= input(ask + "Output Filename > " + green)
147+
with open(".temp",'r') as temp_f, open(out_file,'w') as out_f:
148+
filedata = temp_f.read()
149+
out_f.write("# Encrypted by K-fuscator\n# Github- https://github.com/KasRoudra/k-fuscator\n\n"+filedata)
150+
os.remove(".temp")
151+
sprint(success + out_file + " saved in "+pwd)
152+
mover(out_file)
153+
154+
def decryptsh():
155+
in_file = input(ask + "Input File > "+cyan)
156+
if not os.path.exists(in_file):
157+
print(error+' File not found')
158+
os.system("sleep 2")
159+
decryptsh()
160+
with open(in_file,'r') as in_f, open(".temp1",'w') as temp_f:
161+
filedata = in_f.read()
162+
if not (filedata.find("eval") != -1):
163+
sprint(error+" Cannot be decrypted!")
164+
exit()
165+
newdata = filedata.replace("eval","echo")
166+
temp_f.write(newdata)
167+
out_file = input(ask + "Output File > " +green)
168+
os.system("bash .temp1 > .temp2")
169+
os.remove(".temp1")
170+
with open(".temp2",'r') as temp_f2, open(out_file,'w') as out_f:
171+
filedata = temp_f2.read()
172+
out_f.write("# Decrypted by K-fuscator\n# Github- https://github.com/KasRoudra/k-fuscator\n\n"+filedata)
173+
os.remove(".temp2")
174+
sprint(success + out_file + " saved in "+pwd)
175+
mover(out_file)
176+
177+
178+
def encryptvar():
179+
var= input(ask + "Variable to be used(Must Required) > " + green)
180+
if (var==""):
181+
sprint(error + " No variable")
182+
os.system("sleep 3")
183+
encryptvar()
184+
if (var.find(" ")!= -1):
185+
sprint(error+" Only one word!")
186+
os.system("sleep 3")
187+
encryptvar()
188+
VARIABLE_NAME = var * 100
189+
in_file = input(ask+ "Input file > "+cyan)
190+
if not os.path.isfile(in_file):
191+
print(error+' File not found')
192+
os.system("sleep 2")
193+
encryptvar()
194+
out_file = input(ask + "Output file > " + green)
195+
with open(in_file, 'r', encoding='utf-8', errors='ignore') as in_f,open(out_file, 'w') as out_f:
196+
file_content = in_f.read()
197+
obfuscated_content = obfuscate(VARIABLE_NAME, file_content)
198+
out_f.write("# Encrypted by K-fuscator\n# Github- https://github.com/KasRoudra/k-fuscator\n\n"+obfuscated_content)
199+
sprint(success + out_file + " saved in "+pwd)
200+
mover(out_file)
201+
202+
def encryptem():
203+
in_file= input(ask +"Input File > "+cyan )
204+
if not os.path.isfile(in_file):
205+
print(error+' File not found')
206+
os.system("sleep 2")
207+
encryptem()
208+
out_file= input(ask + "Output File > " + green)
209+
with open(in_file) as in_f, open(out_file, "w") as out_f:
210+
out_f.write("# Encrypted by K-fuscator\n# Github- https://github.com/KasRoudra/k-fuscator\n\n")
211+
out_f.write(encode_string(in_f.read(), alphabet))
212+
sprint(success+out_file+" saved in "+pwd)
213+
mover(out_file)
214+
215+
def main():
216+
os.system("clear")
217+
slowprint(logo)
218+
219+
print(green+'[1]'+yellow+' Encrypt'+cyan+' Bash/Shell')
220+
print(green+'[2]'+yellow+' Decrypt'+cyan+' Bash/Shell')
221+
print(green+'[3]'+yellow+' Encrypt'+cyan+' Python into Variable')
222+
print(green+'[4]'+yellow+' Encrypt'+cyan+' Python into emoji')
223+
print(green+'[5]'+yellow+' More Tools')
224+
print(green+'[6]'+yellow+' About')
225+
print(green+'[0]'+yellow+' Exit\n')
226+
choose = input(ask+blue+' Choose a option : '+ cyan)
227+
228+
while True:
229+
if choose == "1" or choose=="01":
230+
encryptsh()
231+
elif choose == "2" or choose=="02":
232+
decryptsh()
233+
elif choose == "3" or choose=="03":
234+
encryptvar()
235+
elif choose == "4" or choose=="04":
236+
encryptem()
237+
elif choose == "5" or choose=="05":
238+
if os.path.exists("/data/data/com.termux/files/home"):
239+
os.system('xdg-open --view https://github.com/KasRoudra?tab=repositories')
240+
else:
241+
os.system('xdg-open https://github.com/KasRoudra?tab=repositories')
242+
exit()
243+
elif choose == "6" or choose=="06":
244+
about()
245+
elif choose == "0":
246+
exit()
247+
else:
248+
sprint(error+'Wrong input!')
249+
os.system("sleep 2")
250+
main()
251+
try:
252+
main()
253+
except KeyboardInterrupt:
254+
sprint(info+"Have a good day!")
255+
exit()
256+
except Exception as e:
257+
sprint(error+str(e))

main.jpeg

-141 KB
Loading

0 commit comments

Comments
 (0)