发新话题
打印

[原创]LINUX下的文件时间克隆程序

[原创]LINUX下的文件时间克隆程序

文章作者: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 编辑 ]
每个人都有属于自已的世界,人生因此而精彩,HACK就是我的世界!

TOP

顶~~ PT! 直接做一个修改时间的哇~ 别克聋 有点麻烦!还需要一个被克隆的对象
DNA编程--AI智能程式

TOP

touch -r 一下不就行了

touch -r 具有你希望改成的时间的文件 你要改变的文件

不会用自己man 去

TOP

发新话题