文章作者:pt007[at]vip.sina.com
信息来源:邪恶八进制信息安全团队(
www.eviloctal.com)
注:文章首发I.S.T.O信息安全团队,后由原创作者友情提交到邪恶八进制信息安全团队技术讨论组。I.S.T.O版权所有,转载需注明作者。
复制内容到剪贴板
代码:
/*
程序:LINUX下的文件时间克隆
作者:pt007@vip.sina.com,貌似需要文件所有者或者root权限才能运行
测试:
gcc -o touch touch.c
touch newfile oldfile
*/
#include "stdio.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <utime.h>
int main (int argc,char **argv)
{
int i;
struct stat statbuf;
struct utimbuf timebuf;
/* Determine the options. */
if (argc!=3) {
printf("Usage: touch newfile oldfile\n");
return 0;
}
if(stat(argv[2],&statbuf)<0) //fetch currnet times
{
printf("%s,stat error!\n",argv[2]);
return 0;
}
timebuf.actime=statbuf.st_atime;
timebuf.modtime=statbuf.st_mtime;
if(utime(argv[1],&timebuf)<0) //modify time
{
printf("%s:utime error!\n",argv[1]);
return 0;
}
printf("Setting file times sucess!\n");
return 0;
}[
本帖最后由 pt007 于 2008-3-26 12:43 编辑 ]