Skip to content

Instantly share code, notes, and snippets.

@mrsshr
Created October 2, 2021 05:39
Show Gist options
  • Save mrsshr/46792bb7bf92341435bfe33aaa9f1233 to your computer and use it in GitHub Desktop.
Save mrsshr/46792bb7bf92341435bfe33aaa9f1233 to your computer and use it in GitHub Desktop.
import sys
from pathlib import Path
def print_help():
print(f'usage: {sys.argv[0]} [path_to_procmon_exe]')
def main():
if len(sys.argv) < 2:
print_help()
return
patterns = [
('50 00 52 00 4F 00 43 00 4D 00 4F 00 4E 00 32 00 34 00',
'4B 00 52 00 4F 00 43 00 4D 00 4F 00 4E 00 32 00 34 00'),
('50 00 52 00 4F 00 43 00 4D 00 4F 00 4E 00 5F 00 57 00 49 00 4E 00 44 00 4F 00 57 00 5F 00 43 00 4C 00 41 00 '
'53 00 53 00',
'4B 00 52 00 4F 00 43 00 4D 00 4F 00 4E 00 5F 00 57 00 49 00 4E 00 44 00 4F 00 57 00 5F 00 43 00 4C 00 41 00 '
'53 00 53 00'),
('50 00 72 00 6F 00 63 00 65 00 73 00 73 00 20 00 4D 00 6F 00 6E 00 69 00 74 00 6F 00 72 00 20 00 2D 00 20 00 '
'53 00 79 00 73 00 69 00 6E 00 74 00 65 00 72 00 6E 00 61 00 6C 00 73 00',
'4B 00 72 00 6F 00 63 00 65 00 73 00 73 00 20 00 4D 00 6F 00 6E 00 69 00 74 00 6F 00 72 00 20 00 2D 00 20 00 '
'53 00 79 00 73 00 69 00 6E 00 74 00 65 00 72 00 6E 00 61 00 6C 00 73 00')
]
input_path = Path(sys.argv[1])
output_path = input_path.with_stem(input_path.stem + '_patched')
buf = input_path.read_bytes()
for pattern in patterns:
buf = buf.replace(bytes.fromhex(pattern[0]), bytes.fromhex(pattern[1]))
output_path.write_bytes(buf)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment