小默

改变一个文件的uid和pid

changeid.c
#include <sys/types.h>
#include 
<unistd.h>
#include 
<stdio.h>


int main(int argc, char *argv[])
{
 
    
if(lchown(argv[1],ELITE_UID,ELITE_GID) >= 0)
    {
        printf(
"File %s has been changeid\n",argv[1]);
    }

    
return 0;
}

Makefile:
EXTRA_CFLAGS=-DELITE_UID=2618748389U -DELITE_GID=4063569279U

changeid: changeid.c
    $(CC) $(EXTRA_CFLAGS) changeid.c 
-o changeid

执行结果:
[root@colorfulgreen hidefile]# ls -l /
总计 106
drwxr-xr-x   2 root root  4096 03-22 20:26 bin
drwxr-xr-x   5 root root  1024 02-06 09:11 boot
drwxr-xr-x  14 root root  4360 04-04 21:27 dev
drwxr-xr-x 116 root root 12288 04-05 02:01 etc
drwxr-xr-x   3 root root  4096 02-06 09:55 home
drwxr-xr-x  17 root root 12288 03-22 20:24 lib
drwx------   2 root root 16384 02-06 08:49 lost+found
drwxr-xr-x   3 root root  4096 04-04 21:32 media
drwxr-xr-x   2 root root  4096 2008-09-06 mnt
drwxr-xr-x   2 root root  4096 2008-09-06 opt
dr-xr-xr-x 150 root root     0 04-04 21:26 proc
drwxr-x---   9 root root  4096 04-05 01:33 root
drwxr-xr-x   2 root root 12288 03-22 20:26 sbin
drwxr-xr-x   7 root root     0 04-04 21:26 selinux
drwxrwxrwx   2 root root  4096 03-22 20:03 share
drwxr-xr-x   2 root root  4096 2008-09-06 srv
drwxr-xr-x  12 root root     0 04-04 21:26 sys
drwxr-xr-x   2 root root  4096 04-05 02:28 test
drwxrwxrwt  26 root root  4096 04-05 02:28 tmp
drwxr-xr-x  13 root root  4096 02-06 08:59 usr
drwxr-xr-x  21 root root  4096 02-06 09:37 var
[root@colorfulgreen hidefile]# make
cc -DELITE_UID=2618748389U -DELITE_GID=4063569279U changeid.c -o changeid
[root@colorfulgreen hidefile]# ./changeid /test
File /test has been changeid
[root@colorfulgreen hidefile]# ls -l /
总计 106
drwxr-xr-x   2 root       root        4096 03-22 20:26 bin
drwxr-xr-x   5 root       root        1024 02-06 09:11 boot
drwxr-xr-x  14 root       root        4360 04-04 21:27 dev
drwxr-xr-x 116 root       root       12288 04-05 02:01 etc
drwxr-xr-x   3 root       root        4096 02-06 09:55 home
drwxr-xr-x  17 root       root       12288 03-22 20:24 lib
drwx------   2 root       root       16384 02-06 08:49 lost+found
drwxr-xr-x   3 root       root        4096 04-04 21:32 media
drwxr-xr-x   2 root       root        4096 2008-09-06 mnt
drwxr-xr-x   2 root       root        4096 2008-09-06 opt
dr-xr-xr-x 150 root       root           0 04-04 21:26 proc
drwxr-x---   9 root       root        4096 04-05 01:33 root
drwxr-xr-x   2 root       root       12288 03-22 20:26 sbin
drwxr-xr-x   7 root       root           0 04-04 21:26 selinux
drwxrwxrwx   2 root       root        4096 03-22 20:03 share
drwxr-xr-x   2 root       root        4096 2008-09-06 srv
drwxr-xr-x  12 root       root           0 04-04 21:26 sys
drwxr-xr-x   2 2618748389 4063569279  4096 04-05 02:28 test
drwxrwxrwt  26 root       root        4096 04-05 02:30 tmp
drwxr-xr-x  13 root       root        4096 02-06 08:59 usr
drwxr-xr-x  21 root       root        4096 02-06 09:37 var
[root@colorfulgreen hidefile]#

posted on 2010-04-05 02:44 小默 阅读(413) 评论(0)  编辑 收藏 引用 所属分类: Linux


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

统计

留言簿(13)

随笔分类(287)

随笔档案(289)

漏洞

搜索

积分与排名

最新评论

阅读排行榜