Put a breakpoint in shared library with GEF GDB

266 views Asked by At

I want to put a breakpoint in a Linux share library in specific offset ( in libTest.so in function 0x1234 ) while I debugging with GEF GDB. But I want to put it with gdb script.

If I run vmmap libTest.so I got

[ Legend:  Code | Heap | Stack ]
Start  End    Offset Perm Path
0x00000012a1XXX 0x00000012a3XXX 0x00000000000000 r-x /lib/libTest.so
0x00000012a3XXX 0x00000012a5XXX 0x000000000XXXX --- /lib/libTest.so
0x00000012aXXXX 0x00000012aXXXX 0x000000000XXXX r-- /lib/libTest.so
0x00000012aXXXX 0x00000012aXXXX 0x000000000XXXX rw- /lib/libTest.so

So the first line is where the code located. So I want to put a breakpoint in 0x00000012a1XXX+0x1234 For now I put that code in GDB script

python 
str = gdb.execute('vmmap  libTest.so', False, True)
addr_base= (str.split('\n')[2].split(' ')[0])
gdb.execute('b '+addr_base+0x1234)
end

But that is bad code. Is there any simple way?

0

There are 0 answers