Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15357742
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类:

2009-07-15 11:29:20

#include <stdio.h>
#include <fcntl.h>
int main(void)
{
    if (getuid() == 0 || geteuid() == 0) {
        int fd0 = open("/dev/null", O_RDWR);
        int fd1 = open("/dev/null", O_RDWR);
        int fd2 = open("/dev/null", O_RDWR);
        dup2(1, fd1);
        dup2(2, fd2);
        dup2(fd0, 1);
        dup2(fd0, 2);
        int ret = system("rmmod pl2303");
        dup2(fd1, 1);
        dup2(fd2, 2);
        close(fd0);
        close(fd1);
        close(fd2);
        printf("Good, root user\n");
    } else {
        printf("Please run luther.gliethttp in root user\n");
        return -1;
    }

    return 0;
}

luther@gliethttp:/vobs/tmp$ gcc getuid_geteuid.c
luther@gliethttp:/vobs/tmp$ ./a.out
Please run luther.gliethttp in root user
luther@gliethttp:/vobs/tmp$ sudo ./a.out
Good, root user
阅读(2826) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~