-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathConvertToFormat.py
More file actions
69 lines (59 loc) · 1.75 KB
/
ConvertToFormat.py
File metadata and controls
69 lines (59 loc) · 1.75 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
#!/bin/python
# ./ConvertToFormat.py
# Made by WafflesExploits
from base64 import b64encode
from sys import argv
# These variables are not to be changed.
delimiter = ""
output_path = ""
arguments_count = len(argv)
if(arguments_count < 2):
print("./ConvertToFormat.py <file> [<delimiter> <output-path>]")
print("[i] File content example: ")
print("""unsigned char Encrypted_Shellcode[] = {0x99,0x12 };
unsigned char Encrypted_Key[] = {0xF6,0x6B};
unsigned char Protected_Key_for_bruteforce[] = {0x00,0xF0};
BYTE Hint_Byte = 0xCB;""")
exit()
elif(arguments_count < 3):
delimiter = "-"
elif(arguments_count < 4):
delimiter = argv[2]
else:
delimiter = argv[2]
output_path = argv[3]
file_path = argv[1]
f = open(file_path, "r")
variables = f.read()
# Remove strings
text = variables
text = text.replace("\n","");
text = text.replace("unsigned char ", "");
text = text.replace("BYTE ", "");
text = text.replace("[]", "");
text = text.replace(";","\n");
text = text.replace("{", "").replace("}", "");
text = text.replace(" = ",delimiter);
text = text.replace(" ","");
text = text[:-1] # Remove last \n character
#print(text)
# Example Text final format:
#Encrypted_hex_code-0x99,0x12
#Encrypted_Key-0xF6,0x6B
#Protected_Key_for_bruteforce-0x00,0xF0
#HintByte-0xCB
text_bytes = text.encode('utf-8')
# Now, base64 encode the bytes
encoded_text = b64encode(text_bytes).decode('utf-8')
if(output_path):
f = open(output_path, "w")
f.write(encoded_text)
f.close()
print(f"[i] Using delimiter \"{delimiter}\"")
print(f"[i] Saved file to \"{output_path}\"")
else:
print(encoded_text)
if(arguments_count < 3):
print("[i] Using default delimiter \"-\"")
else:
print(f"[i] Using delimiter \"{delimiter}\"")