forked from shmilylty/shellcode-convert
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshellcode_convert.py
49 lines (43 loc) · 1.07 KB
/
shellcode_convert.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
#!/usr/bin/env python
# coding=utf-8
# author:admin[@hackfun.org]
# license:GPL v3
# blog:hackfun.org
RED = "\033[31m"
RESET = "\033[0m"
def error():
print(RED)
print("[!] Input error.")
exit(1)
def encode():
data = raw_input("[<-] Input data to encode: ")
print("[->] Output shellcode: ")
shellcode = ""
for char in data:
shellcode += "\\x" + char.encode("hex")
print(RED)
print(shellcode)
exit(0)
def decode():
data = raw_input("Input data to decode: ")
if data.find("\\x") == -1:
error()
data = data.replace("\\x","")
try:
plain = data.decode("hex")
except TypeError as e:
error()
print(RED)
print(plain)
exit(0)
def main():
print("ShellCode encode decode")
mode = raw_input("[<-] Input %s1[encode]%s or %s2[decode]%s:" % (RED, RESET, RED, RESET))
if mode == "1" or mode == "encode":
encode()
elif mode == "2" or mode == "decode":
decode()
else:
error()
if __name__ == '__main__':
main()