Home > Net >  Can't search into heap using gdb
Can't search into heap using gdb

Time:01-07

I try to search ascii in heap memory , I check the heap address using

cat /proc/PID/maps | grep heap

Then wirh GDB I want to search ascii

find 0x1577000,0x2a01000,"/bin/sh"

But I got error:

gdbserver: Unable to access target memory at 0x1579e9b, halting search.

What can I do please?

CodePudding user response:

But I got error:

  1. You probably used grep and (gdb) find on different processes. Heap location is randomized by ASLR (though GDB disables ASLR)
  2. In GLIBC, malloc tends to use mmaped arenas, which are not marked as heap in /proc/$pid/maps, so there is a high chance you wouldn't find the string you are looking for anyway.

CodePudding user response:

find 0x1577000,0x2a01000,"/bin/sh"

GDB's find command will search, in the words of its documentation, an "inclusive range". But if 0x2a01000 is the upper bound of a memory region in /proc/pid/maps, it means the region goes up to but does not include that location. So subtract 1 from that, and give GDB the command

find 0x1577000,0x2a00fff,"/bin/sh"
  • Related