mirror of
https://github.com/Chaelsoo/sliver-psh
synced 2026-08-09 12:03:21 +00:00
28 lines
758 B
Python
28 lines
758 B
Python
#!/usr/bin/env python3
|
|
# AES-256-CBC encrypt a payload for use with stager.ps1.
|
|
# Usage: python3 encrypt.py <payload.bin> <output_enc.bin>
|
|
# Copy the printed key and IV into stager.ps1.
|
|
import os, sys
|
|
from Crypto.Cipher import AES
|
|
from Crypto.Util.Padding import pad
|
|
|
|
if len(sys.argv) != 3:
|
|
print(f"usage: {sys.argv[0]} <payload.bin> <output_enc.bin>")
|
|
sys.exit(1)
|
|
|
|
key = os.urandom(32)
|
|
iv = os.urandom(16)
|
|
|
|
with open(sys.argv[1], 'rb') as f:
|
|
data = f.read()
|
|
|
|
cipher = AES.new(key, AES.MODE_CBC, iv)
|
|
encrypted = cipher.encrypt(pad(data, AES.block_size))
|
|
|
|
with open(sys.argv[2], 'wb') as f:
|
|
f.write(encrypted)
|
|
|
|
print(f"[+] {len(data)} bytes -> {len(encrypted)} bytes encrypted")
|
|
print(f"[+] key = {key.hex()}")
|
|
print(f"[+] iv = {iv.hex()}")
|