From 3e7dedf3f2ed30cdf38663d361bde2599102f149 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sat, 2 Jun 2018 14:44:30 -0500 Subject: Add WoFerClock utility --- woferclock/find_replace_binary_string | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 woferclock/find_replace_binary_string (limited to 'woferclock/find_replace_binary_string') diff --git a/woferclock/find_replace_binary_string b/woferclock/find_replace_binary_string new file mode 100755 index 0000000..bcea1d8 --- /dev/null +++ b/woferclock/find_replace_binary_string @@ -0,0 +1,27 @@ +#!/usr/bin/python +# +# Copyright (c) 2018 Raptor Engineering, LLC +# Released under the terms of the AGPL v3 + +import sys +import binascii + +filename = sys.argv[1] +searchfile = sys.argv[2] +replacefile = sys.argv[3] + +with open(filename, 'rb') as f: + indata = f.read() +with open(searchfile, 'rb') as f: + searchdata = f.read() +with open(replacefile, 'rb') as f: + replacedata = f.read() + +raw_data = binascii.hexlify(indata) +search = binascii.hexlify(searchdata) +replace = binascii.hexlify(replacedata) +raw_data = raw_data.replace(search, replace) +outdata = binascii.unhexlify(raw_data) + +with open(filename, 'wb') as f: + f.write(outdata) -- cgit v1.2.3