改變一個文件的uid和pid
changeid.c
Makefile:
執行結果:
#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;
}
#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
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]#
總計 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 小默 閱讀(439) 評論(0) 編輯 收藏 引用 所屬分類: Linux

