MCPcopy
hub / github.com/Gallopsled/pwntools / dynamic_string

Method dynamic_string

pwnlib/elf/elf.py:1666–1687  ·  view source on GitHub ↗

dynamic_string(offset) -> bytes Fetches an enumerated string from the ``DT_STRTAB`` table. Arguments: offset(int): String index Returns: :class:`str`: String from the table as raw bytes.

(self, offset)

Source from the content-addressed store, hash-verified

1664 return tag.entry.d_val
1665
1666 def dynamic_string(self, offset):
1667 """dynamic_string(offset) -> bytes
1668
1669 Fetches an enumerated string from the ``DT_STRTAB`` table.
1670
1671 Arguments:
1672 offset(int): String index
1673
1674 Returns:
1675 :class:`str`: String from the table as raw bytes.
1676 """
1677 dt_strtab = self.dynamic_by_tag('DT_STRTAB')
1678
1679 if not dt_strtab:
1680 return None
1681
1682 address = dt_strtab.entry.d_ptr + offset
1683 string = b''
1684 while b'\x00' not in string:
1685 string += self.read(address, 1)
1686 address += 1
1687 return string.rstrip(b'\x00')
1688
1689
1690

Callers 2

rpathMethod · 0.95
runpathMethod · 0.95

Calls 2

dynamic_by_tagMethod · 0.95
readMethod · 0.95

Tested by

no test coverage detected