yeah, the title pretty much says it,
is it possible to convert and exe file to shellcode that can be run in memory/inserted into a metasploit executable template?
here's he python code i use to load and run the shellcode
WARNING! IT CAN CRASH YOUR SYSTEM ( 64-bit ) ONLY WORKS ON 32-bit:
from ctypes import * #load ctypes module
import sys,binascii # import binascii to decode shellcode
o=open(sys.argv[1],"r") # open file to read encoded shellcode from
shellcode=binascii.unhexlify(o.read()) # write decoded shellcode to variable
cast(create_string_buffer(shellcode, len(shellcode)), CFUNCTYPE(c_void_p))() # run it
now i want to use an exe file as payload to run it from RAM
here's the code of the encoder:
import sys,binascii
i=open(sys.argv[1],"rb")
o=open(sys.argv[1]+".hex","w")
o.write(binascii.hexlify(i.read()))
the problem is when i feed it an encoded exe file it won't work:
C:\Dokumente und Einstellungen\User\Desktop>test.py out.txt
Traceback (most recent call last):
File "C:\Dokumente und Einstellungen\User\Desktop\test.py", line 5, in <module>
cast(create_string_buffer(shellcode, len(shellcode)), CFUNCTYPE(c_void_p))()
WindowsError: exception: access violation writing 0x00001101
i also checked if it was possible to use metasploit to convert an exe to shellcode, but i didn't find anything :(
so i'd like to convert the exe to "real" shellcode that can be run from RAM
any ideas?