Skip to content

Commit

Permalink
Merge branch 'gdb_8_py36_code_refactor' of github.com:hugsy/gef into …
Browse files Browse the repository at this point in the history
…gdb_8_py36_code_refactor
  • Loading branch information
hugsy committed Jan 7, 2022
2 parents 4f6ab0c + 8a27a38 commit d2f5f27
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions gef.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
#
#
#######################################################################################
# GEF - Multi-Architecture GDB Enhanced Features for Exploiters & Reverse-Engineers
#
Expand Down Expand Up @@ -395,7 +392,7 @@ def inner_f(*args, **kwargs):
f(*args, **kwargs)
else:
reason = "GDB >= {} for this command".format(required_gdb_version)
raise EnvironmentError(reason)
raise OSError(reason)
return inner_f
return wrapper

Expand All @@ -411,7 +408,7 @@ def inner_f(*args, **kwargs):
f(*args, **kwargs)
else:
reason = "This command cannot work for the '{}' architecture".format(gef.arch.arch)
raise EnvironmentError(reason)
raise OSError(reason)
return inner_f
return wrapper

Expand Down Expand Up @@ -2152,7 +2149,7 @@ def endianness(self) -> Endianness:
elif "big endian" in output:
self.__endianness = Endianness.BIG_ENDIAN
else:
raise EnvironmentError(f"No valid endianess found in '{output}'")
raise OSError(f"No valid endianess found in '{output}'")
return self.__endianness

def get_ith_parameter(self, i, in_func=True):
Expand Down Expand Up @@ -3290,7 +3287,7 @@ def xor(data, key):
"""Return `data` xor-ed with `key`."""
key = key.lstrip("0x")
key = binascii.unhexlify(key)
return bytearray([x ^ y for x, y in zip(data, itertools.cycle(key))])
return bytearray(x ^ y for x, y in zip(data, itertools.cycle(key)))


def is_hex(pattern):
Expand Down Expand Up @@ -3690,7 +3687,7 @@ def get_memory_alignment(in_bits=False):
except:
pass

raise EnvironmentError("GEF is running under an unsupported mode")
raise OSError("GEF is running under an unsupported mode")


def clear_screen(tty=""):
Expand Down Expand Up @@ -3801,13 +3798,11 @@ def db(t, p):
yield alphabet[a[j]]
else:
a[t] = a[t - p]
for c in db(t + 1, p):
yield c
yield from db(t + 1, p)

for j in range(a[t - p] + 1, k):
a[t] = j
for c in db(t + 1, t):
yield c
yield from db(t + 1, t)

return db(1, 1)

Expand Down Expand Up @@ -5612,7 +5607,7 @@ def is_target_alive(self, host, port):
s.settimeout(1)
s.connect((host, port))
s.close()
except socket.error:
except OSError:
return False
return True

Expand Down Expand Up @@ -5705,7 +5700,7 @@ def parsed_arglist(arglist):
jump = getattr(self.sock, "jump")
jump(hex(gef.arch.pc-main_base_address),)

except socket.error:
except OSError:
self.disconnect()
return

Expand Down Expand Up @@ -9920,7 +9915,7 @@ def do_invoke(self, argv):

try:
readelf = gef.session.constants["readelf"]
except IOError:
except OSError:
err("Missing `readelf`")
return

Expand Down

0 comments on commit d2f5f27

Please sign in to comment.