Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting changes for the "got-audit" command. #1097

Merged
merged 2 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Therefore it requires the following binaries to be present:

* `file`
* `readelf`
* `nm`
* `ps`
* `python3`

Expand Down
12 changes: 8 additions & 4 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -9263,6 +9263,11 @@ def __init__(self):
"Line color of the got command output for unresolved function")
return

def build_line(self, name: str, color: str, address_val: int, got_address: int) -> str:
line = f"[{hex(address_val)}] "
line += Color.colorify(f"{name} {RIGHT_ARROW} {hex(got_address)}", color)
return line

@only_if_gdb_running
def do_invoke(self, argv: List[str]) -> None:
readelf = gef.session.constants["readelf"]
Expand All @@ -9289,7 +9294,7 @@ def do_invoke(self, argv: List[str]) -> None:
relro_status = "No RelRO"

# retrieve jump slots using readelf
lines = gef_execute_external([readelf, "--relocs", elf_file], as_list=True)
lines = gef_execute_external([readelf, "--wide", "--relocs", elf_file], as_list=True)
jmpslots = [line for line in lines if "JUMP" in line]

gef_print(f"\nGOT protection: {relro_status} | GOT functions: {len(jmpslots)}\n ")
Expand Down Expand Up @@ -9317,8 +9322,7 @@ def do_invoke(self, argv: List[str]) -> None:
else:
color = self["function_resolved"]

line = f"[{hex(address_val)}] "
line += Color.colorify(f"{name} {RIGHT_ARROW} {hex(got_address)}", color)
line = self.build_line(name, color, address_val, got_address)
gef_print(line)
return

Expand Down Expand Up @@ -11072,7 +11076,7 @@ def __init__(self) -> None:
self.aliases: List[GefAlias] = []
self.modules: List[FileFormat] = []
self.constants = {} # a dict for runtime constants (like 3rd party file paths)
for constant in ("python3", "readelf", "file", "ps"):
for constant in ("python3", "readelf", "nm", "file", "ps"):
self.constants[constant] = which(constant)
return

Expand Down
Loading