Skip to content

canary ¤

Functions:

  • canary_value

    Get the global canary value from AT_RANDOM with its last byte masked (as glibc does)

  • find_tls_canary_addr

    Find the address of the canary in the Thread Local Storage (TLS).

  • canary

    Display information about the stack canary, including its location in TLS and any copies found on the stack.

Attributes:

DEFAULT_NUM_CANARIES_TO_DISPLAY module-attribute ¤

DEFAULT_NUM_CANARIES_TO_DISPLAY = 1

TLS_CANARY_OFFSETS module-attribute ¤

TLS_CANARY_OFFSETS = {'x86-64': 40, 'i386': 20, 'aarch64': 40}

parser module-attribute ¤

parser = ArgumentParser(description='Print out the current stack canary.')

canary_value ¤

canary_value() -> tuple[int | None, int | None]

Get the global canary value from AT_RANDOM with its last byte masked (as glibc does)

Returns:

  • tuple ( tuple[int | None, int | None] ) –

    (canary_value, at_random_addr) or (None, None) if not found

find_tls_canary_addr ¤

find_tls_canary_addr() -> int | None

Find the address of the canary in the Thread Local Storage (TLS).

The canary is stored at a fixed offset from the TLS base, which varies by architecture. The TLS base can be accessed through architecture-specific registers: - x86_64: fs register - i386: gs register - aarch64: tpidr_el0 register

Returns:

  • int ( int | None ) –

    The virtual address of the canary in TLS, or None if not found/supported

canary ¤

canary(all) -> None

Display information about the stack canary, including its location in TLS and any copies found on the stack.