Skip to content

attaching libdebug to a 32 bit process sometimes thinks it's 64 bit #57

Description

@jtyliu

If you have a 32 bit binary, run it with pwntools' process with shell=True and set a breakpoint, sometimes libdebug will attempt to set a breakpoint at a 64 bit address.

Note I could not get this error to trigger if shell=False (which is the default behaviour of process)

test.c

#include <stdio.h>
int main(){
	getc(stdin);
	printf("REE\n");
}

test.py

from libdebug import debugger
from pwn import *

context.log_level = 'critical'

def guess():
    con = process('./test', shell=True)
    d = debugger()
    d.attach(con.pid)

    d.breakpoint(0x804a92a)
    d.kill()
    con.close()
    return


for _ in range(100):
    print("AH")
    guess()

error

Traceback (most recent call last):
  File "/home/joshual/test.py", line 26, in <module>
    guess("AAA", 'REEEEEEE')
  File "/home/joshual/test.py", line 18, in guess
    d.breakpoint(0x804a92a)
  File "/home/joshual/.local/lib/python3.12/site-packages/libdebug/libdebug.py", line 327, in breakpoint
    address = self.context.resolve_address(position)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joshual/.local/lib/python3.12/site-packages/libdebug/state/debugging_context.py", line 247, in resolve_address
    normalized_address = normalize_and_validate_address(address, maps)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joshual/.local/lib/python3.12/site-packages/libdebug/utils/debugging_utils.py", line 29, in normalize_and_validate_address
    raise ValueError(f"Address {hex(address)} does not belong to any memory map.")
ValueError: Address 0x55555d59e92a does not belong to any memory map.

Metadata

Metadata

Assignees

No one assigned

    Labels

    not a bugSomething that is not a bug of libdebug

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions