JonathanSalwan / ROPgadget

This tool lets you search your gadgets on your binaries to facilitate your ROP exploitation. ROPgadget supports ELF, PE and Mach-O format on x86, x64, ARM, ARM64, PowerPC, SPARC, MIPS, RISC-V 64, and RISC-V Compressed architectures.
Other
3.96k stars 557 forks source link

ROPgadget -c (update) fails #186

Closed MisterAero closed 2 years ago

MisterAero commented 2 years ago

ROPgadget -c Traceback (most recent call last): File "/home/aero/.local/bin/ROPgadget", line 12, in ropgadget.main() File "/home/aero/.local/lib/python3.8/site-packages/ropgadget/init.py", line 26, in main args = Args() File "/home/aero/.local/lib/python3.8/site-packages/ropgadget/args.py", line 26, in init self.parse(arguments, custom_arguments_provided) File "/home/aero/.local/lib/python3.8/site-packages/ropgadget/args.py", line 132, in parse UpdateAlert().checkUpdate() File "/home/aero/.local/lib/python3.8/site-packages/ropgadget/updateAlert.py", line 30, in checkUpdate majorVersion = re.search("MAJOR_VERSION.+=.+(?P[\d])", d).group("value") File "/usr/lib/python3.8/re.py", line 201, in search return _compile(pattern, flags).search(string) TypeError: cannot use a string pattern on a bytes-like object

Could it be because of not using the latest version of pip3?

nurmukhametov commented 2 years ago

I guess something like this should resolve this issue

diff --git a/ropgadget/updateAlert.py b/ropgadget/updateAlert.py
index 3a6ef85..85e5a2e 100644
--- a/ropgadget/updateAlert.py
+++ b/ropgadget/updateAlert.py
@@ -26,7 +26,7 @@ class UpdateAlert(object):
         except:
             print("Can't connect to raw.githubusercontent.com")
             return
-        d = conn.getresponse().read()
+        d = conn.getresponse().read().decode()
         majorVersion = re.search("MAJOR_VERSION.+=.+(?P<value>[\d])", d).group("value")
         minorVersion = re.search("MINOR_VERSION.+=.+(?P<value>[\d])", d).group("value")
         webVersion = int("%s%s" % (majorVersion, minorVersion))
SweetVishnya commented 2 years ago

@nurmukhametov, yeah, this fixes an issue. Would you like to propose a PR?