自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

linux內(nèi)核模塊調(diào)試

系統(tǒng) Linux
在Host機(jī)上運(yùn)行: socat tcp-listen:8888 /tmp/vbox2, 其中/tmp/vbox2為管道文件,它是目標(biāo)機(jī)串口的重定向目的文件,socat將這個(gè)管道文件又重定向到tcp socket的8888端口。

1. 開啟虛擬機(jī),虛擬機(jī)運(yùn)行到 kgdb: Waiting for connection from remote gdb

2. 在Host機(jī)上運(yùn)行: socat tcp-listen:8888 /tmp/vbox2, 其中/tmp/vbox2為管道文件,它是目標(biāo)機(jī)串口的重定向目的文件,socat將這個(gè)管道文件又重定向到tcp socket的8888端口。

3. 開啟一個(gè)新的虛擬終端,cd path/to/kernel/source/tree, 然后執(zhí)行g(shù)db ./vmlinux

輸出

GNU gdb 6.8-debian

Copyright (C) 2008 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.  Type "show copying"

and "show warranty" for details.

This GDB was configured as "i486-linux-gnu"...

(gdb) set-remote

set remote baud rate to 115200c/s

set remote target to local tcp socket

kgdb_breakpoint () at kernel/kgdb.c:1721

1721        wmb(); /* Sync point after breakpoint */

(gdb) c

Continuing.

目標(biāo)機(jī)會(huì)一直啟動(dòng),直到提示輸入用戶名密碼。

4. 進(jìn)入目標(biāo)機(jī),輸入用戶名密碼(推薦使用字符界面下的root用戶),輸入g命令,目標(biāo)機(jī)被斷下,控制移交到Host機(jī)中的gdb中。(目標(biāo)機(jī)root的用戶目錄中的.bashrc中添加一行alias g='echo g>/proc/sysrq-trigger')

5. 在Host機(jī)中的gdb中

(gdb) set-mod-break

set breakpoint in system module init function

Breakpoint 1 at 0xc014bac5: file kernel/module.c, line 2288.

(gdb) c

Continuing.

6. 在目標(biāo)機(jī)中

insmod klogger2.ko

目標(biāo)機(jī)再次斷下,控制權(quán)移交Host機(jī)中的gdb

7. 在Host機(jī)中的gdb中

[New Thread 4693]

[Switching to Thread 4693]

Breakpoint 1, sys_init_module (umod=0x0, len=0, uargs=0x0)

at kernel/module.c:2288

2288        if (mod->init != NULL)

(gdb) print-mod-segment

Name:.note.gnu.build-id Address:0xdf977058

Name:.text Address:0xdf975000

Name:.rodata Address:0xdf977080

Name:.rodata.str1.4 Address:0xdf9774b4

Name:.rodata.str1.1 Address:0xdf977522

Name:.parainstructions Address:0xdf977a00

Name:.data Address:0xdf978440

Name:.gnu.linkonce.this_module Address:0xdf978480

Name:.bss Address:0xdf978a00

Name:.symtab Address:0xdf977a08

Name:.strtab Address:0xdf978078

(gdb) add-symbol-file /home/done/programs/linux-kernel/vlogger/klogger2.ko 0xdf975000 -s .data 0xdf978440 -s .bss 0xdf978a00

add symbol table from file "/home/done/programs/linux-kernel/vlogger/klogger2.ko" at

.text_addr = 0xdf975000

.data_addr = 0xdf978440

.bss_addr = 0xdf978a00

(y or n) y

Reading symbols from /home/done/programs/linux-kernel/vlogger/klogger2.ko...done.

(gdb) b hook_init

Breakpoint 2 at 0xdf976d19: file /home/done/programs/linux-kernel/vlogger/hook.c, line 255.

(gdb)

你可以調(diào)試自己些的LKM模塊了

附gdb的初始化配置文件~/.gdbinit

define set-remote

echo set remote baud rate to 115200c/s\n

set remotebaud 115200

echo set remote target to local tcp socket\n

target remote tcp:localhost:8888

end

define set-mod-break

echo set breakpoint in system module init function\n

break kernel/module.c:2288

end

define print-mod-segment

set $sect_num=mod->sect_attrs->nsections

set $cur=0

while $cur < $sect_num

printf "Name:%-s Address:0x%x\n",mod->sect_attrs->attrs[$cur]->name,mod->sect_attrs->attrs[$cur]->address

set $cur=$cur+1

end

end

后記:gdb的調(diào)試腳本真難寫,簡(jiǎn)單的字符串變量連接和等價(jià)判斷都顯得十分困難,不知道是我水平太差還是gdb的腳本功能太弱,總之比起Windbg來說,內(nèi)核調(diào)試?yán)щy程度上了個(gè)等級(jí)。
 

【編輯推薦】

  1. linux 2.6內(nèi)核配置選項(xiàng)注解
  2. Linux下用gdb檢測(cè)內(nèi)核rootkit的方法
  3. Linux內(nèi)核中的DeviceMapper機(jī)制
責(zé)任編輯:趙寧寧 來源: chinaitlab
相關(guān)推薦

2018-06-19 09:07:57

Linux內(nèi)核模塊

2019-07-08 20:00:35

Linux內(nèi)核模塊

2023-05-08 08:05:42

內(nèi)核模塊Linux

2021-09-03 08:44:51

內(nèi)核模塊Linux社區(qū)

2022-05-14 17:01:21

開源LinuxNVIDIA

2009-12-17 15:28:32

內(nèi)核模塊編譯

2010-04-12 11:19:47

編譯內(nèi)核模塊

2021-07-06 14:36:05

RustLinux內(nèi)核模塊

2022-05-12 09:58:31

LinuxNVIDIA開源

2018-05-14 09:48:45

Linux內(nèi)核模塊Kgotobed

2014-07-24 14:35:26

Linux內(nèi)核模塊

2017-01-15 22:51:16

2014-08-28 15:08:35

Linux內(nèi)核

2011-08-29 15:12:24

UbuntuLinux模塊

2020-05-13 21:11:37

KVM架構(gòu)工具

2011-03-17 11:12:10

LinuxIptablestime模塊

2018-03-19 09:15:00

2017-01-12 19:15:03

Linux內(nèi)核調(diào)試自構(gòu)proc

2022-02-08 15:15:26

OpenHarmonlinux鴻蒙

2021-07-11 06:45:18

Linux內(nèi)核靜態(tài)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)