[20261008]gdb引入结构体是否可行.txt
$ cat sskgphpjw.c
struct sskgphpjw_input {
unsigned char data[0x100]; // 偏移 0x00,字符串/名字数据
uint64_t len; // 偏移 0x100,8 字节长度
};
struct sskgphpjw_input ss;
--//必须定义1个变量,开始遗漏了struct sskgphpjw_input ss;,不然报如下错误:
(gdb) print (struct sskgphpjw_input *) $buf
No struct type named sskgphpjw_input.
$ gcc sskgphpjw.c -g -c -o sskgphpjw.o
--//在gdb下加入:
(gdb) add-symbol-file sskgphpjw.o 0
add symbol table from file "sskgphpjw.o" at
.text_addr = 0x0
(y or n) y
Reading symbols from sskgphpjw.o...
(gdb) set $buf = (char *)malloc(0x108)
(gdb) call strcpy($buf, "book/u01/app/oracle/product/21.0.0/dbhome_1")
$1 = 0x1a5053b0 "book/u01/app/oracle/product/21.0.0/dbhome_1"
(gdb) set {unsigned long}($buf+0x100) = 43
(gdb) p /x (unsigned int)sskgphpjw($buf)
$4 = 0x5507207c
(gdb) print (struct sskgphpjw_input *) $buf
$6 = (struct sskgphpjw_input *) 0x1a5053b0
(gdb) p *$6
$9 = {data = "book/u01/app/oracle/product/21.0.0/dbhome_1", '\000' <repeats 212 times>, len = 43}
(gdb) ptype *$6
type = struct sskgphpjw_input {
unsigned char data[256];
uint64_t len;
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-3184560/ ,如需转载,请注明出处,否则将追究法律责任。