Skip to content

Commit 403ef4e

Browse files
committed
Slight modifications to the hexreplace module
- Changed output verbosity - fixed a bug in __init__ with the search variable - little cleanup
1 parent df3383c commit 403ef4e

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

proxymodules/hexreplace.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python3
22
import os
3-
import re
43

54

65
class Module:
@@ -9,12 +8,11 @@ def __init__(self, incoming=False, verbose=False, options=None):
98
self.name = os.path.splitext(os.path.basename(__file__))[0]
109
self.description = 'Replace hex data on the fly defining search and replace-pairs in a file or as module parameters'
1110
self.verbose = verbose
12-
self.search = None
13-
self.replace = None
1411
self.filename = None
1512
self.separator = ':'
1613
self.len = 16
1714

15+
search = None
1816
if options is not None:
1917
if 'search' in options.keys():
2018
search = bytes.fromhex(options['search'])
@@ -54,17 +52,18 @@ def hexdump(self, data):
5452
print("\n".join(result))
5553

5654
def execute(self, data):
57-
#self.hexdump(data)
58-
print(f"Incoming packet with size {len(data)}:")
55+
if self.verbose:
56+
print(f"Incoming packet with size {len(data)}:")
5957
for search, replace in self.pairs:
60-
#print(f"{search} -> {replace}")
6158
if search in data:
62-
print("########## data found ###########")
63-
print("[Before:]")
64-
self.hexdump(data)
59+
if self.verbose:
60+
print("########## data found ###########")
61+
print("[Before:]")
62+
self.hexdump(data)
6563
data = data.replace(search, replace)
66-
print("[After:]")
67-
self.hexdump(data)
64+
if self.verbose:
65+
print("[After:]")
66+
self.hexdump(data)
6867
return data
6968

7069
def help(self):

0 commit comments

Comments
 (0)