程序自我复制[C代码]

来自http://tunps.com/selfcopy-c-code

/*
code by tunpishuang
vc++ 2008编译通过
使用“使用多字节字符集”,而非Unicode
功能:
    将当前正在运行的进程exe镜像复制到%systemroot%目录下
*/
#include <windows.h>
#include <stdio.h>
int main()
{
    char filename[256];
    char sysdir[256];
    int ret;
    GetModuleFileName(0,filename,256);
    GetSystemDirectory(sysdir,256);
    ret=CopyFile(filename,strcat(sysdir,"\\hacker.exe"),FALSE);
    if(ret)
    {
        printf("%s copied to %s\n",filename,sysdir);
    }
    else
    {
        printf("copy failed!\n");
    }
    return 0;
}

About tunpishuang

just 4 fun·····
This entry was posted in 未分类 and tagged , . Bookmark the permalink.

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>