Created
November 18, 2015 14:58
-
-
Save Holzhaus/2ceb137fe791b4856401 to your computer and use it in GitHub Desktop.
[OSSec-Uebung03] Patch für die PEDA pattern search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/utils.py b/lib/utils.py | |
index b8ee40f..5d4461c 100644 | |
--- a/lib/utils.py | |
+++ b/lib/utils.py | |
@@ -316,8 +316,8 @@ def normalize_argv(args, size=0, convert=True): | |
""" | |
Normalize argv to list with predefined length | |
""" | |
- args = list(args) | |
- for (idx, val) in enumerate(args[:size]): | |
+ args = list(args)[:size] | |
+ for (idx, val) in enumerate(args): | |
if convert: | |
as_int = to_int(val) | |
if as_int is not None: | |
@@ -716,6 +716,8 @@ def cyclic_pattern_offset(value): | |
else: | |
search = hex2str(to_int(value)) | |
+ if type(search) is bytes: | |
+ pattern = pattern.encode() | |
pos = pattern.find(search) | |
return pos if pos != -1 else None | |
@@ -730,9 +732,9 @@ def cyclic_pattern_search(buf): | |
- list of tuple (buffer_offset, pattern_len, pattern_offset) | |
""" | |
result = [] | |
- pattern = cyclic_pattern() | |
+ pattern = cyclic_pattern().encode() | |
- p = re.compile("[%s]{4,}" % re.escape(cyclic_pattern_charset())) | |
+ p = re.compile(("[%s]{4,}" % re.escape(cyclic_pattern_charset())).encode()) | |
found = p.finditer(buf) | |
found = list(found) | |
for m in found: | |
diff --git a/peda.py b/peda.py | |
index bf75d0c..888236b 100644 | |
--- a/peda.py | |
+++ b/peda.py | |
@@ -1853,7 +1853,7 @@ class PEDA(object): | |
if escape != 0: | |
search = re.escape(search) | |
- search = bytes(search) | |
+ #search = bytes(search) | |
try: | |
p = re.compile(search) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment