Skip to content

List imports #85

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

withzombies
Copy link

Adds a paginated list_imports.

Returns data that looks like this:

{
  "data": [
    {
      "module": ".dynsym",
      "import": "sprintf@@GLIBC_2.0",
      "address": "0x804e580",
      "ordinal": "0x0"
    },
    {
      "module": ".dynsym",
      "import": "err@@GLIBC_2.0",
      "address": "0x804e584",
      "ordinal": "0x0"
    },
    {
      "module": ".dynsym",
      "import": "signal@@GLIBC_2.0",
      "address": "0x804e588",
      "ordinal": "0x0"
    },
    {
      "module": ".dynsym",
      "import": "recv@@GLIBC_2.0",
      "address": "0x804e58c",
      "ordinal": "0x0"
    },
    {
      "module": ".dynsym",
      "import": "calloc@@GLIBC_2.0",
      "address": "0x804e590",
      "ordinal": "0x0"
    },
    {
      "module": ".dynsym",
      "import": "listen@@GLIBC_2.0",
      "address": "0x804e594",
      "ordinal": "0x0"
    },
    {
      "module": ".dynsym",
      "import": "__libc_start_main@@GLIBC_2.0",
      "address": "0x804e598",
      "ordinal": "0x0"
    },
    {
      "module": ".dynsym",
      "import": "htons@@GLIBC_2.0",
      "address": "0x804e59c",
      "ordinal": "0x0"
    },
    {
      "module": ".dynsym",
      "import": "setegid@@GLIBC_2.0",
      "address": "0x804e5a0",
      "ordinal": "0x0"
    },
    {
      "module": ".dynsym",
      "import": "read@@GLIBC_2.0",
      "address": "0x804e5a4",
      "ordinal": "0x0"
    },
    {
      "module": ".dynsym",
      "import": "free@@GLIBC_2.0",
      "address": "0x804e5a8",
      "ordinal": "0x0"
    },
    {
      "module": ".dynsym",
      "import": "accept@@GLIBC_2.0",
      "address": "0x804e5ac",
      "ordinal": "0x0"
    },
    {
      "module": ".dynsym",
      "import": "socket@@GLIBC_2.0",
      "address": "0x804e5b0",
      "ordinal": "0x0"
    }
  ],
  "next_offset": null
}

Copy link
Owner

@mrexodia mrexodia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution, I added some review comments to be addressed.

@@ -658,6 +658,44 @@ def list_globals(
"""List all globals in the database (paginated)"""
return list_globals_filter(offset, count, "")

class Import(TypedDict):
address: str
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TypedDict does not match the returned data.

"module": module_name,
"import": symbol_name,
"address": f"{ea:#x}",
"ordinal": f"#{ordinal}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the ordinal provide any kind of value? As far as I know this is just what IDA uses as an index to identify that specific import.

acc += [{
"module": module_name,
"import": symbol_name,
"address": f"{ea:#x}",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use hex(ea) to match the rest of the codebase


def imp_cb(ea, symbol_name, ordinal, acc):
if not symbol_name:
symbol_name = "<unnamed>"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under what circumstances does this happen? Perhaps this is where we should return symbol_name = f"#{ordinal}" in this case?


acc += [{
"module": module_name,
"import": symbol_name,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer calling this name or function, or did you observe calling it import improve LLM performance in some way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants