⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 share_pass.cpp

📁 VC++编写的类似Sniffer的网络数据包监听程序
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "share_pass.h"
#include "main.h"
#include "dict.h"
#include "report.h"
#include "function_1.h"
#pragma package(smart_init)
#include "syncobjs.hpp"
extern int share_thread_no;//用于share检测线程数量
extern int cur_ip;//检测ip列表的位置指示
//extern int scan_port_ip;//密码列表的位置指示
//extern int share_ip_no;//用户列表的位置指示
extern TCriticalSection *ping_CriticalSection;//全局临界变量
extern boolean thread_run;//
extern TStringList *main_list;//在本单元用于保存要检测的IP列表
extern TStringList *port_lists;//在本单元用于保存要检测的密码列表
extern boolean const_pass;//是否使用内定密码
//---------------------------------------------------------------------------
void __fastcall tshare_pass::ThreadDone_share(TObject * Sender)
{
  FNetConnection->Free();flist->Free();
  share_thread_no--; //线程总数减一
  report_f->Edit14->Text=IntToStr(share_thread_no);

  if (share_thread_no==0)
   {
//    main_f->Edit8->Text="查找共享完成";
//    main_f->BitBtn4->Enabled=!main_f->share_check->Checked;
//    main_f->BitBtn5->Enabled=!main_f->share_check->Checked;
    main_f->Bar->Position=0;
   }

}

__fastcall tshare_pass::tshare_pass(bool CreateSuspended)
        : TThread(CreateSuspended)
{
   FNetConnection=new TNetConnection(main_f);
   flist=new TStringList();
   //   FNetConnection->OnEchoClose=NetCon_EchoClose;
   FNetConnection->OnEchoOpen=NetCon_Echoopen;
   FNetConnection->GetInfo=false;//找系统信息
   FNetConnection->AutoDo=false;//不是自动查找
   OnTerminate =ThreadDone_share;
   FreeOnTerminate = True;
   share_thread_no++;//线程加1
   report_f->Edit14->Text=IntToStr(share_thread_no);
}

//---------------------------------------------------------------------------
void __fastcall tshare_pass::Execute()
{
   int ip_no;//主机的位置
   int temp=0;
   AnsiString temp_str="";
  while (thread_run)
   {
     pass_no=0;//用于指示密码位置
     user_no=0;
    ping_CriticalSection->Enter();//进入临界状态
     ip_no=cur_ip;
     cur_ip++;
    ping_CriticalSection->Leave();//析放临界状态
     if (ip_no>=main_list->Count) return;

    FNetConnection->Address=main_list->Strings[ip_no];
    FNetConnection->get_user(1,flist);//找用户
    if (flist->Count==0)//若没有用户则取默认的用户
      flist->AddStrings(dict_f->user_list->Lines);
      else temp=0;
    while (thread_run)
    {
      if (pass_no>=port_lists->Count)
       {
        pass_no=0;
        temp=0;
        user_no++;//用户列表位置加一
       if (user_no>=flist->Count)
          {
           user_no=0;
           break;
          }
        }
       FNetConnection->UserName=flist->Strings[user_no];
       if (const_pass)//使用内定密码
         temp_str=NameToPass(FNetConnection->UserName,temp);

       if (temp_str!="")
          FNetConnection->PassWord=temp_str;
         else
         {
           FNetConnection->PassWord=port_lists->Strings[pass_no];
           pass_no++;
         }

      FNetConnection->open();
      FNetConnection->close();
    }
 }
}
//---------------------------------------------------------------------------
void __fastcall tshare_pass::NetCon_Echoopen(TObject *Sender,
      TObject *IConnection, int Error)
{
  state=Error;
  Synchronize(set_list);//写全部信息
  if ((Error==51)||(Error==53)||(Error==64)||(Error==1792))//远程计算机不可用/网络路径不存在/不可再用/登录服务不运行
   {
    user_no=flist->Count;
    pass_no=port_lists->Count;
   }
}

void __fastcall tshare_pass::set_list()
{
 if (state==0)
  {
//若成功则跳到下一个用户
   if (FNetConnection->UserName==flist->Strings[user_no])
      { pass_no=port_lists->Count;
      }
  Beep();
  report_f->Edit1->Text=IntToStr(StrToInt(report_f->Edit1->Text)+1);
  report_f->all_info->Lines->Add("检测:"+FNetConnection->Address+"->用户:"+
        FNetConnection->UserName+"->密码:"+FNetConnection->PassWord+"-------------[成功]");
  report_f->ok_info->Lines->Add("主机:["+FNetConnection->Address+"] 用户:["+
        FNetConnection->UserName+"] 密码:["+FNetConnection->PassWord+"]");
  } else
  {
  report_f->all_info->Lines->Add("检测:"+FNetConnection->Address+"->用户:"+
        FNetConnection->UserName+"->密码:"+FNetConnection->PassWord+"-------------[失败:"+IntToStr(state)+"]");
  if (report_f->all_info->Lines->Count>500)
    {
     report_f->all_info->Lines->Clear();
    }
  }
 report_f->Edit9->Text=IntToStr(StrToInt(report_f->Edit9->Text)+1);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -