I'm working on a project to automatize a process. My task is to open an .exe file and edit the binary. I was researching for a possible solution to this task without any success. Does anyone know if there is a Python library or java class that can help? Or any other solution to edit an exe file.
If you just need to edit the binary data contained in the file, then it is just a matter of opening the file as binary and seeking/reading/writing as you would any other binary file.
See the Python docs about reading and writing files: Reading and Writing Files
You'll do something like:
f = open('filename.exe', 'r+b') //'r+b' means read and write binary
Then proceed to seek through the file, read and write where needed.
Depending on your needs, you could treat the .exe file as an "ordinary" binary file as suggested in an other answer.
In other hand, if you need to "decode" Windows portable executable files (accessing header, copying sections), there are some dedicated Python module specialized in that task. I don't know which work the best or has the most features, but you should take a look for example to:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With