summaryrefslogtreecommitdiffstats
path: root/woferclock/find_replace_binary_string
diff options
context:
space:
mode:
Diffstat (limited to 'woferclock/find_replace_binary_string')
-rwxr-xr-xwoferclock/find_replace_binary_string27
1 files changed, 27 insertions, 0 deletions
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)
OpenPOWER on IntegriCloud