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

📄 scandirfile.pas

📁 明小子旁注Domain3.0和Domain2.2两个版本源码
💻 PAS
字号:
{##########################################
         旁注入侵专用程序 3.0升级版
 ----------------------------------------
  模块:旁注检测 - 扫描整站目录
  描述:该单元为扫描整站目录的多线程单元
  作者:2005.3.22日晚  明小子
##########################################}

unit ScanDirFile;

interface

uses
  Classes, Wininet, SysUtils, StdCtrls, Windows, ComCtrls;

type
  MyScanDirFile = class(TThread)
  private
    TmpNum: integer;
    ifor: integer;
    TmpEdit: TEdit;
    TmpLstBox: TListBox;
    TmpLstV: TListView;
    Url, ChkUrlStr: string;
    procedure ShowUpData;
    procedure ShowUpData2;
  protected
    procedure Execute; override;
  public
    constructor Create(Num: integer; ThEdit: TEdit; ThLstV: TListView);
  end;

implementation

uses ScanDir, MainUnit;

constructor MyScanDirFile.Create(Num: integer; ThEdit: TEdit; ThLstV: TListView);
begin
  TmpNum := Num;
  TmpEdit := ThEdit;
  TmpLstV := ThLstV;
  FreeOnTerminate := True;
  inherited Create(False);
end;

function CheckUrl(url: string; TimeOut: integer = 30000): boolean;
var
  hSession, hfile, hRequest: hInternet;
  dwindex, dwcodelen: dword;
  dwcode: array[1..20] of char;
  res: pchar;
  re: integer;
  Err1: integer;
  j: integer;
begin
  if pos('http://', lowercase(url)) = 0 then
    url := 'http://' + url;
  Result := false;
  hSession := InternetOpen('Mozilla/4.0', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
  InternetSetOption(hSession, Internet_OPTION_CONNECT_TIMEOUT, @TimeOut, 4);
  if assigned(hsession) then
  begin
    j := 1;
    while true do
    begin
      hfile := InternetOpenUrl(hsession, pchar(url), nil, 0, INTERNET_FLAG_RELOAD, 0);
      if hfile = nil then
      begin
        j := j + 1;
        Err1 := GetLastError;
        if j > 5 then break;
        if (Err1 <> 12002) or (Err1 <> 12152) then break;
        sleep(2000);
      end
      else begin
        break;
      end;
    end;
    dwIndex := 0;
    dwCodeLen := 10;
    HttpQueryInfo(hfile, HTTP_QUERY_STATUS_CODE, @dwcode, dwcodeLen, dwIndex);
    res := pchar(@dwcode);
    re := strtointdef(res, 404);
    case re of
      200..299: result := True;
      401..403: result := True;
    else result := False;
    end;
    if assigned(hfile) then
      InternetCloseHandle(hfile);
    InternetCloseHandle(hsession);
  end;
end;

procedure MyScanDirFile.ShowUpData2;
begin
  if Terminated then Exit;
  ChkUrlStr := URL + Trim(ScandirForm.EdAddress.Text) + ScandirForm.CheckListBox1.Items[ifor];
end;

procedure MyScanDirFile.ShowUpData;
begin
  if Terminated then Exit;
  with TmpLstV.Items.Add do
  begin
    caption := URL + Trim(ScandirForm.EdAddress.Text) + ScandirForm.CheckListBox1.Items[ifor];
    SubItems.Add('目录存在 - ' + inttostr(TmpLstV.Items.Count));
  end;
end;

procedure MyScanDirFile.Execute;
var
  i: integer;
  Res, AVG, Count, ThreadCount: integer;
begin
  try
    Count := ScandirForm.CheckListBox1.Items.Count;
    URL := '';
    URL := TmpEdit.Text;
    ThreadCount := 50;

    if (Count mod ThreadCount) = 0 then
      AVG := (Count div ThreadCount)
    else
      AVG := (Count div ThreadCount) + 1;

    for i := (TmpNum * AVG) - AVG to (TmpNum * AVG) - 1 do
    begin

      if Terminated then Exit;

      if i >= Count - 1 then
        exit;

      try
        ifor := i;
        Synchronize(ShowUpData2);
        if CheckUrl(ChkUrlStr) then
        begin
          Synchronize(ShowUpData);
        end;
        sleep(100);
      except
      end;

    end;

    sleep(50);
  except
  end;
end;

end.

⌨️ 快捷键说明

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