forked from m1kemu/MiscellaneousCode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Composer.py
30 lines (22 loc) · 775 Bytes
/
Composer.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
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
from base64 import b64encode, b64decode
import urllib.request
key = b'eax94il288nyq0rv'
def aes_encrypt(plaintext, key):
iv = get_random_bytes(AES.block_size)
cipher = AES.new(key, AES.MODE_CFB, iv)
ciphertext = cipher.encrypt(plaintext)
return ciphertext, iv
def aes_decrypt(ciphertext, key, iv):
cipher = AES.new(key, AES.MODE_CFB, iv)
plaintext = cipher.decrypt(ciphertext)
return plaintext
with open('calc_x64.bin', 'rb') as f:
shellcode = f.read()
ciphertext, iv = aes_encrypt(shellcode, key)
ciphertext = b64encode(ciphertext).decode()
iv = b64encode(iv).decode()
message = f'{ciphertext}:{iv}'
with open('download_me.txt', 'w') as f:
f.write(message)