PE Portable Executung or DLL Dynamic Linking Libraries can be edited to remove or add capabilities or own code.
Read and modify a PE file
The following Python3 script reads a file, prints out a header, modified it to remove ASLR and write a new file without this flag.
f = pefile.PE('filename.exe')
print(hex(f.OPTIONAL_HEADER.DllCharacteristics)) // print as hex to work with masks
f.OPTIONAL_HEADER.DllCharacteristics = f.OPTIONAL_HEADER.DllCharacteristics ^ 0x0040 // xor with 0x0040 which is the value for DYNAMIC_BASE (=> ASLR) to enable or disable it.
f.write('filename.exe.new') // write the modified file.
Leave a Reply
You must be logged in to post a comment.