0

I extracted pe file from another pe file and I saved it.

I want it execute but when I saved file computer sees it like text file. Altough my actual file starting with "4d 5a" computer sees like text and converts it "34 64". How can I solve this problem?

enter image description here

2

You need to convert the text to bytes. You can use python 3 for that, in something like:

my_hexdata = "4d5a..."

bytes_ = bytes.fromhex(my_hexdata)

with open('output.exe', 'wb') as x:
    x.write(bytes_)
0

use python,powershell,xxd -r, javascript
anything that you can script read a group of 2 char and make it one byte;

demo using binascii in python

:\>type asc2hex.py
import sys
import binascii
if(len(sys.argv)==2):
    inf = open(sys.argv[1],"rb");
    ouf = open("hex"+sys.argv[1] , "wb")
    dat= inf.read()
    inf.close()
    ouf.write(binascii.unhexlify(dat))
    ouf.close()
:\>type foo.bin
4d5a
:\>asc2hex.py foo.bin

:\>type hexfoo.bin
MZ
:\>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.