mirror of
https://github.com/qilingframework/qiling.git
synced 2026-10-12 02:21:40 +00:00
update gdbserver
This commit is contained in:
+10
-11
@@ -1,36 +1,35 @@
|
||||
# Qiling Gdbserver
|
||||
|
||||
Qiling has supported **Gdb remote debugging** now (x86, x86-64 for now) by Qiling Gdbserver.
|
||||
Qiling supports **Gdb remote debugging**, which listens at default port **9999** if enable.
|
||||
|
||||
## Usage
|
||||
|
||||
```python
|
||||
from qiling import *
|
||||
|
||||
|
||||
def test_gdb(path, rootfs):
|
||||
ql = Qiling(path, rootfs, output="off")
|
||||
# ql.gdb = True # enable gdbserver at default port
|
||||
# ql.gdb = ":9999" # Listening to 0.0.0.0:9999
|
||||
ql.gdb = "127.0.0.1:9999" # Listening to 127.0.0.1:9999
|
||||
ql.gdb = True # enable gdbserver at default port 9999
|
||||
# You can also customize address & port of GDB server
|
||||
# ql.gdb = ":9999" # GDB server listens to 0.0.0.0:9999
|
||||
# ql.gdb = "127.0.0.1:9999" # GDB server listens to 127.0.0.1:9999
|
||||
ql.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_gdb(["../examples/rootfs/x86_linux/bin/x86_hello"], "../examples/rootfs/x86_linux")
|
||||
test_gdb(["../examples/rootfs/x8664_linux/bin/x8664_hello_static"], "../examples/rootfs/x8664_linux")
|
||||
```
|
||||
|
||||
Run gdb and `set architecture i386:intel` for x86 or `set architecture i386:x86-64` for x86-64
|
||||
|
||||
Then `target remote ip:port` and run the python script.
|
||||
|
||||
Currently supported features include `si`,`ni`,`c` ,read register,read memory,add/remove breakpoint
|
||||
Currently supported features include `si`, `ni`, `c`, `k`, read register, read memory, add/remove breakpoints.
|
||||
|
||||
---
|
||||
|
||||
## Example
|
||||
|
||||
In x86-64, for example
|
||||
Below is an example on how we use gdb to debug an x86-64 binary in Qiling.
|
||||
|
||||
**set arch**
|
||||
```bash
|
||||
@@ -40,8 +39,8 @@ The target architecture is assumed to be i386:x86-64
|
||||
|
||||
**connect**
|
||||
```bash
|
||||
(gdb) target remote 192.168.0.105:9999
|
||||
Remote debugging using 192.168.0.105:9999
|
||||
(gdb) target remote localhost:9999
|
||||
Remote debugging using localhost:9999
|
||||
warning: No executable has been specified and target does not support
|
||||
determining executable automatically. Try using the "file" command.
|
||||
0x00000000004014e0 in ?? ()
|
||||
|
||||
@@ -7,24 +7,23 @@ Qiling已通过Qiling Gdbserver支持**Gdb远程调试**(目前支持x86, x86-
|
||||
```python
|
||||
from qiling import *
|
||||
|
||||
|
||||
def test_gdb(path, rootfs):
|
||||
ql = Qiling(path, rootfs, output="off")
|
||||
# ql.gdb = True # enable gdbserver at default port
|
||||
ql.gdb = True # enable gdbserver at default port 9999
|
||||
# You can also customize address & port of GDB server
|
||||
# ql.gdb = ":9999" # Listening to 0.0.0.0:9999
|
||||
ql.gdb = "127.0.0.1:9999" # Listening to 127.0.0.1:9999
|
||||
# ql.gdb = "127.0.0.1:9999" # Listening to 127.0.0.1:9999
|
||||
ql.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_gdb(["../examples/rootfs/x86_linux/bin/x86_hello"], "../examples/rootfs/x86_linux")
|
||||
test_gdb(["../examples/rootfs/x8664_linux/bin/x8664_hello_static"], "../examples/rootfs/x8664_linux")
|
||||
```
|
||||
|
||||
运行gdb并为所需架构进行设置,x86输入命令`set architecture i386:intel`,x86-64输入命令`set architecture i386:x86-64`
|
||||
|
||||
然后输入命令`target remote ip:port` 并执行python脚本
|
||||
|
||||
当前支持的命令有 `si`,`ni`,`c`,读寄存器,读内存,插入或删除断点
|
||||
当前支持的命令有 `si`, `ni`, `c`, `k`, 读寄存器, 读内存, 插入或删除断点
|
||||
|
||||
---
|
||||
|
||||
@@ -40,8 +39,8 @@ The target architecture is assumed to be i386:x86-64
|
||||
|
||||
**connect**
|
||||
```bash
|
||||
(gdb) target remote 192.168.0.105:9999
|
||||
Remote debugging using 192.168.0.105:9999
|
||||
(gdb) target remote localhost:9999
|
||||
Remote debugging using localhost:9999
|
||||
warning: No executable has been specified and target does not support
|
||||
determining executable automatically. Try using the "file" command.
|
||||
0x00000000004014e0 in ?? ()
|
||||
|
||||
+2
-1
@@ -218,6 +218,7 @@ class Qiling:
|
||||
self.gdbserver(ip, port)
|
||||
except:
|
||||
print("Error ip or port")
|
||||
self.gdbsession.close()
|
||||
exit(1)
|
||||
|
||||
self.__enable_bin_patch()
|
||||
@@ -707,7 +708,7 @@ class Qiling:
|
||||
exit(1)
|
||||
|
||||
if ip is None:
|
||||
ip = ''
|
||||
ip = 'localhost'
|
||||
if port is None:
|
||||
port = 9999
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
@@ -32,9 +32,7 @@ class Qldbg(object):
|
||||
Modified this function for qiling.gdbserver by kabeor from https://github.com/iGio90/uDdbg
|
||||
"""
|
||||
try:
|
||||
print(self.mapping)
|
||||
self.mapping.append([hex(address), size])
|
||||
|
||||
self.current_address = address
|
||||
|
||||
hit_soft_bp = False
|
||||
|
||||
Reference in New Issue
Block a user