feature: xor'd payload

This commit is contained in:
Dobin
2024-02-11 12:51:12 +00:00
parent 0753290fe6
commit 547cd94dd5
8 changed files with 52 additions and 34 deletions
+27
View File
@@ -1,8 +1,11 @@
import pefile
import pprint
from model import *
from helper import *
from config import config
from observer import observer
from project import project
def make_shc_from_asm(asm_file, exe_file, shc_file):
@@ -27,3 +30,27 @@ def make_shc_from_asm(asm_file, exe_file, shc_file):
return code
#print("---[ Shellcode from {} written to: {} (size: {}) ]".format(exe_file, shc_file, len(code)))
def merge_loader_payload(main_shc_file):
print("--[ Merge stager: {} + {} -> {} ] ".format(
main_shc_file, project.payload, main_shc_file))
with open(main_shc_file, 'rb') as input1:
data_stager = input1.read()
with open(project.payload, 'rb') as input2:
data_payload = input2.read()
if project.decoder_style == DecoderStyle.PLAIN_1:
pass
elif project.decoder_style == DecoderStyle.XOR_1:
xor_key = 0x42
print("---[ XOR payload with key 0x{:x}".format(xor_key))
data_payload = bytes([byte ^ xor_key for byte in data_payload])
print("---[ Size: Stager: {} and Payload: {} Sum: {} ]".format(
len(data_stager), len(data_payload), len(data_stager)+len(data_payload)))
with open(main_shc_file, 'wb') as output:
data = data_stager + data_payload
output.write(data)
observer.add_code("final_shellcode", data)