获取Linux 2.6.x sys_call_table
来源:互联网 发布:美国进口数据查询 编辑:程序博客网 时间:2024/06/06 00:53
网上搜索了一下, 发现此代码主要原理是通过搜索 int 0x80的中断服务程序中的sys_call_table来实现.
在linux中所有的syscall都是调用int 0x80, int 0x80的中断服务程序为system_call(arch/x86/kernel/traps_32.c:set_system_gate(SYSCALL_VECTOR,&system_call). system_call (arch/x86/entry_32.S)最终call *sys_call_table(,%eax,4)来完成一个syscall调用.
即 int 0x80 -> system_call -> sys_call_table, 这样我们只要首先获取int 0x80的中断服务地址system_call地址, 然后在system_call代码中直接搜索call指令即可找到sys_call_table地址了!
另一种方法就是直接修改
通过cat /boot/System.map-`uname -r` |grep sys_call_table 查看当前sys_call_table地址,并与通过以上方法取得的地址做比较!
内核版本: ubuntu 2.6.24-19-server
/*
* Standard in kernel modules
*/
#include <linux/kernel.h> /* We're doing kernel work */
#include <linux/module.h> /* Specifically, a module, */
#include <linux/moduleparam.h> /* which will have params */
#include <linux/unistd.h> /* The list of system calls */
/*
* For the current (process) structure, we need
* this to know who the current user is.
*/
#include <linux/sched.h>
#include <asm/uaccess.h>
unsigned long *sys_call_table = 0;
//EXPORT_SYMBOL ( sys_call_table );
struct {
unsigned short limit;
unsigned int base;
} __attribute__ ( ( packed ) ) idtr;
struct {
unsigned short offset_low;
unsigned short segment_select;
unsigned char reserved, flags;
unsigned short offset_high;
} __attribute__ ( ( packed ) ) * idt;
unsigned long* find_sys_call_table(void)
{
unsigned long system_call = 0; // x80中断处理程序system_call 地址
char *call_hex = "/xff/x14/x85"; // call 指令
char *code_ptr = NULL;
char *p = NULL;
unsigned long sct = 0x0;
int i = 0;
// 获取中断描述符表寄存器的地址
__asm__ ( "sidt %0": "=m" ( idtr ) );
// 获取0x80中断处理程序的地址
idt = ( void * ) ( idtr.base + 8 * 0x80 );
system_call = ( idt->offset_high << 16 ) | idt->offset_low;
// 搜索system_call代码
code_ptr = (char *)system_call;
for(i = 0;i < ( 100 - 2 ); i++) {
//// 查找call指令
if(code_ptr[i] == call_hex[0]
&& code_ptr[i+1] == call_hex[1]
&& code_ptr[i+2] == call_hex[2] ) {
//
p = &code_ptr[i] + 3;
break;
}
}
if ( p ){
sct = *(unsigned long*)p;
}
return (unsigned long*)sct;
}
int init_module ( void ) {
if ( ( sys_call_table = find_sys_call_table() ) ) {
printk( "sys_call_table = %p/n", sys_call_table );
}
return 0;
}
void cleanup_module ( void ) {
}
Makefile文件:
obj-m = get_sct.o
KVERSION = $(shell uname -r)
all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
- 获取Linux 2.6.x sys_call_table
- Linux 2.6版内核中通过模块获取sys_call_table地址的方法
- Linux 2.6版内核中通过模块获取sys_call_table地址的方法
- Linux 2.6版内核中通过模块获取sys_call_table地址的方法
- 多种方法获取sys_call_table(linux系统调用表)的地址
- linux sys_call_table 初始化
- Linux 2.6 中导出sys_call_table表修改系统调用函数
- sys_call_table
- sys_call_table
- linux中导出sys_call_table解决方法
- 一些Android sys_call_table获取的方法
- 导出Linux系统调用表(sys_call_table)
- sys_call_table 的总结
- linux 2.6.x Makefile
- linux 2.6.x Makefile
- zz linux 2.6.x Makefile
- linux 2.6x内核升级
- 截获系统调用(sys_call_table/VFS)
- 和T的老外聊的高兴,A的电话技术面试真难
- 嵌入式Linux操作系统学习规划
- 关于log4j.properties详细配置
- 循环遍历文件夹
- Flex 开发入门
- 获取Linux 2.6.x sys_call_table
- SetTimer函数的用法——转载 发布时间: 2006-5-22 下午5:26
- 如果你想让你的IIS支持WAP
- 自定义排序函数实现时需要注意的问题
- 成员函数的重载、覆盖与隐藏
- GUID( create and string covert)
- rename.js
- 嵌入式系统调试仿真工具
- 配置IIS和Apache的HTTP压缩