forked from pwndbg/pwndbg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from __future__ import annotations | ||
|
||
import argparse | ||
|
||
import pwndbg.commands | ||
import pwndbg.gdblib.kernel.kallsyms | ||
from pwndbg.color import message | ||
from pwndbg.commands import CommandCategory | ||
|
||
parser = argparse.ArgumentParser(description="Lookup kernel symbols") | ||
|
||
parser.add_argument("symbol", type=str, help="Address or symbol name to lookup") | ||
|
||
|
||
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.KERNEL) | ||
@pwndbg.commands.OnlyWhenQemuKernel | ||
@pwndbg.commands.OnlyWhenPagingEnabled | ||
def klookup(symbol: str) -> None: | ||
ksyms = pwndbg.gdblib.kernel.kallsyms.get() | ||
try: | ||
symbol_addr = int(symbol) | ||
for k, v in ksyms.items(): | ||
if v[0] == symbol_addr: | ||
print(message.success(f"{k} = {symbol_addr:#x}")) | ||
return | ||
print(message.error(f"No symbol found at {symbol_addr:#x}")) | ||
except ValueError: | ||
if symbol in ksyms: | ||
addr = ksyms[symbol][0] | ||
print(message.success(f"{symbol} = {addr:#x}")) | ||
else: | ||
print(message.error(f"No symbol found for {symbol}")) |