首页
社区
课程
招聘
[求助]lkm hook
发表于: 2014-1-23 22:58 4533

[求助]lkm hook

2014-1-23 22:58
4533
int (*orig_mkdir)((const char *pathname, mode_t mode); /*the original systemcall*/

int hacked_mkdir((const char *pathname, mode_t mode) {

    //请问如何在此调用原来的mkdir函数呢??

    return 0; /*everything is ok, but he new systemcall does nothing*/

}

[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

收藏
免费 0
支持
分享
最新回复 (4)
雪    币: 1392
活跃值: (4867)
能力值: ( LV13,RANK:240 )
在线值:
发帖
回帖
粉丝
2
原来的函数在org,参数在hacked这边,函数知道了,参数知道了,不知道怎么调用????
2014-1-24 07:24
0
雪    币: 47
活跃值: (43)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
3
int hack_mkdir(const char *path, mode_t mode) //定义一个替换函数,它将用来替换某个系统调用
{
        printk("<0> mkdir 已经被我成功拦截!!\n");
              return (*orig_mkdir)(path,mode);
}

这样,貌似不可以。。。参数path,mode 怎么获得,传递的呢?

初学 lkm 编程,忘大神耐心讲解,感激不尽。。。
2014-1-24 09:19
0
雪    币: 185
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
orig_mkdir  是一个函数指针的原型。 应该是typedef 的。

然后使用一个变量来保存原始指针 。

mydir = (orig_mkdir)*********;

mydir(path, mode);//这样就可以了。
2014-1-24 12:42
0
雪    币: 47
活跃值: (43)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
5
我打印了一下path,发现是 null。。。所以第一步因该是获得用户态下的参数path。

orig_mkdir 获得如下:

int (*orig_mkdir)((const char *pathname, mode_t mode); /*the original systemcall*/

int hacked_mkdir((const char *pathname, mode_t mode) {

    //请问如何在此调用原来的mkdir函数呢??

    return 0; /*everything is ok, but he new systemcall does nothing*/

}

static int __init begin(void)
{
        orig_mkdir = sys_call_table[__NR_mkdir]; //保存mkdir原来的的地址,我确定现在已经获得正确的系统调用的地址

        sys_call_table[__NR_mkdir] =hack_mkdir; //挟持
   
        return 0;
}
2014-1-24 15:06
0
游客
登录 | 注册 方可回帖
返回
//