elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  [Pascal] Gathor 0.1 (Recolector de informacion)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Pascal] Gathor 0.1 (Recolector de informacion)  (Leído 1,737 veces)
WarZ0n3

Desconectado Desconectado

Mensajes: 22


Ver Perfil
[Pascal] Gathor 0.1 (Recolector de informacion)
« en: 1 Agosto 2013, 08:51 am »

Saludos gente  ::)
Después de ausentarme un gran tiempo por trabajo y viajes, hoy que tuve un tiempo libre y como estaba aburrido, se me ocurrió hace una pequeña herramienta de gathering, debo decir que faltan agregarles muchas características y otras deben ser quitadas del código, estoy consiente que queda mucho por optimizar y bueno... al fin y al acabo nunca es suficiente.

También pensé que, en cuando tenga tiempo libre, programar un sniffer ¿Les gustaría?.

Y sin mas rodeos el código (Compilado en Delphi 7), también adjuntare unas imágenes con ciertos detalles de su interés:
Código
  1. program Gathor;
  2.  
  3. (*********************************************)
  4. (* Software : Gathor 0.1                     *)
  5. (* Autor    : WarZone                        *)
  6. (* Fecha    : 1/8/13                         *)
  7. (*********************************************)
  8. (* Explicacion:                              *)
  9. (* Un simple gathering de informacion web    *)
  10. (* el cual tiene algunas caracteristicas     *)
  11. (* como leer el source de la pagina(index),  *)
  12. (* ver el servidor en que se esta corriendo, *)
  13. (* fecha, version del protocolo, contenido,  *)
  14. (* opciones de metodos usados <posiblemente  *)
  15. (* permitiendo un Defacement>, etc..         *)
  16. (*********************************************)
  17. (* Parametros + Ejemplo :                    *)
  18. (* <sitio_web> <puerto> <opcion>             *)
  19. (* www.google.com 80 get_proto_0             *)
  20. (*********************************************)
  21. (*    -Opciones de uso / Caracteristicas-    *)
  22. (*                                           *)
  23. (* Los siguientes comandos permiten hacer    *)
  24. (* peticiones HTTP por distintas opciones,   *)
  25. (* GET, POST, HEAD, ETC... y version del     *)
  26. (* protocolo respectivamente 1.0 o 1.1       *)
  27. (*                                           *)
  28. (* get_proto_0 -> metodo GET por HTTP/1.0    *)
  29. (* get_proto_1 -> GET por HTTP/1.1           *)
  30. (* post_proto_0 -> POST por HTTP/1.0         *)
  31. (* post_proto_1 -> POST por HTTP/1.1         *)
  32. (* options_proto_0 -> OPTIONS por HTTP/1.0   *)
  33. (* options_proto_1 -> OPTIONS por HTTP/1.1   *)
  34. (* head_proto_0 -> HEAD por HTTP/1.0         *)
  35. (* head_proto_1 -> HEAD por HTTP/1.1         *)
  36. (*********************************************)
  37.  
  38. {$APPTYPE CONSOLE}
  39.  
  40. uses
  41.  SysUtils,
  42.  Windows,
  43.  WinSock;
  44.  
  45. const
  46.  { Config }
  47.  BL         = #13#10;
  48.  
  49.  { HTTP Methods }
  50.  POST        = 'POST';
  51.  GET         = 'GET';
  52.  OPTIONS     = 'OPTIONS';
  53.  HEAD        = 'HEAD';
  54.  
  55.  { Version }
  56.  HTTP0       = ' HTTP/1.0';
  57.  HTTP1       = ' HTTP/1.1';
  58.  STP         = ' /';
  59.  
  60.  { Octetos }
  61.  ZERO        = $00000000;
  62.  BSIZE       = $00001024;
  63.  BUFFSIZE    = $000000FF;
  64.  BUFFDATA    = $00001000;
  65.  INADDRSIZE  = $0000000A;
  66.  
  67. var
  68.  WSData      : WsaData;
  69.  TcpSocket   : tSocket;
  70.  sAddr       : sockaddr_in;
  71.  pIp         : string;
  72.  I           : Integer;
  73.  
  74.  BuffName    : array [0..BUFFSIZE] of AnsiChar;
  75.  sData       : array [0..BUFFDATA] of Char;
  76.  
  77. (* Reporte de desensamblado en GetIp
  78. 00408450  /$ 55             PUSH EBP            <-----| Callback IP |
  79. 00408451  |. 8BEC           MOV EBP,ESP
  80. 00408453  |. 6A 00          PUSH 0
  81. 00408455  |. 53             PUSH EBX
  82. 00408456  |. 33C0           XOR EAX,EAX
  83. 00408458  |. 55             PUSH EBP
  84. 00408459  |. 68 BA844000    PUSH Project2.004084BA
  85. 0040845E  |. 64:FF30        PUSH DWORD PTR FS:[EAX]
  86. 00408461  |. 64:8920        MOV DWORD PTR FS:[EAX],ESP
  87. 00408464  |. 68 9C374100    PUSH Project2.0041379C                   ; /pWSAData = Project2.0041379C
  88. 00408469  |. 6A 01          PUSH 1                                   ; |RequestedVersion = 1 (1.0.)
  89. 0040846B  |. E8 98FFFFFF    CALL <JMP.&wsock32.WSAStartup>           ; \WSAStartup
  90. 00408470  |. 90             NOP
  91. 00408471  |. 90             NOP
  92. 00408472  |. 90             NOP
  93. 00408473  |. 8D55 FC        LEA EDX,DWORD PTR SS:[EBP-4]
  94. 00408476  |. B8 01000000    MOV EAX,1
  95. 0040847B  |. E8 88A3FFFF    CALL Project2.00402808
  96. 00408480  |. 8B45 FC        MOV EAX,DWORD PTR SS:[EBP-4]
  97. 00408483  |. E8 A4BBFFFF    CALL Project2.0040402C
  98. 00408488  |. 50             PUSH EAX                                 ; /Name
  99. 00408489  |. E8 72FFFFFF    CALL <JMP.&wsock32.gethostbyname>        ; \gethostbyname
  100. 0040848E  |. 8B40 0C        MOV EAX,DWORD PTR DS:[EAX+C]
  101. 00408491  |. 33D2           XOR EDX,EDX
  102. 00408493  |. 8B0490         MOV EAX,DWORD PTR DS:[EAX+EDX*4]
  103. 00408496  |. FF30           PUSH DWORD PTR DS:[EAX]
  104. 00408498  |. E8 3BFFFFFF    CALL <JMP.&wsock32.inet_ntoa>
  105. 0040849D  |. 8BD8           MOV EBX,EAX
  106. 0040849F  |. E8 6CFFFFFF    CALL <JMP.&wsock32.WSACleanup>           ; [WSACleanup
  107. 004084A4  |. 33C0           XOR EAX,EAX
  108. 004084A6  |. 5A             POP EDX
  109. 004084A7  |. 59             POP ECX
  110. 004084A8  |. 59             POP ECX
  111. 004084A9  |. 64:8910        MOV DWORD PTR FS:[EAX],EDX
  112. 004084AC  |. 68 C1844000    PUSH Project2.004084C1
  113. 004084B1  |> 8D45 FC        LEA EAX,DWORD PTR SS:[EBP-4]
  114. 004084B4  |. E8 83B7FFFF    CALL Project2.00403C3C
  115. 004084B9  \. C3             RETN
  116.  
  117.  
  118.  
  119. *)
  120. function
  121.  GetIP(): PChar;
  122. type
  123.  aIn_addr      = array [0..INADDRSIZE] of pInAddr;
  124.  pIn_addr      = ^aIn_addr;
  125. var
  126.  Hostent     : PHostEnt;
  127.  HostAddr    : pIn_addr;
  128.  HostPData   : PChar;
  129.  Int         : Integer;
  130. begin
  131.  WSAStartup($1, WSData);
  132.  asm
  133.    NOP
  134.    NOP
  135.    NOP
  136.  end;
  137.  Hostent:= GetHostBYName( PChar(ParamStr(1)) );
  138.  HostAddr:= pIn_addr(Hostent^.h_addr_list);
  139.  Int:= 0;
  140.  Result:= inet_ntoa(HostAddr^[Int]^);
  141.  WSACleanUp;
  142. end;
  143.  
  144. function
  145.  CALLBACK__getIp: string;
  146. asm
  147.  @@StartUp:
  148.    XOR EAX,EAX
  149.    XOR ECX,ECX
  150.    XOR EDX,EDX
  151.    MOV DWORD PTR FS:[EAX],ESP
  152.    LEA EDX,DWORD PTR SS:[EBP-4]
  153.    MOV EAX,1
  154.    MOV EAX,DWORD PTR SS:[EBP-4]
  155.    MOV EAX,DWORD PTR DS:[EAX+$C]
  156.    XOR EDX,EDX
  157.    MOV EDX,EBX
  158.    XOR EAX,EAX
  159.    MOV DWORD PTR FS:[EAX],EDX
  160.    LEA EAX,DWORD PTR SS:[EBP-4]
  161.    NOP
  162.    NOP
  163.  
  164.    PUSH Pointer($00408450) //Pointer($00408450)
  165.    POP EDX
  166.    CALL EDX                 (* CALLBACK DE LA FUNCION *)
  167. end;
  168.  
  169. begin
  170.  if (ParamCount<=1) then
  171.    WriteLn('Parametros usados: <sitio_web> <puerto> <opcion>'+BL);
  172.  
  173.  WSAStartUp($1, WSData);
  174.  TcpSocket:= Socket (AF_INET, SOCK_STREAM, ZERO);
  175.  
  176.  sAddr.sin_family:= af_inet;
  177.  sAddr.sin_addr.s_addr:= inet_addr(GetIP()); //INET_ADDR('173.194.42.209');
  178.  sAddr.sin_port:= htons(StrToInt(ParamStr(2))); //htons(Integer(ParamStr(2)));
  179.  
  180.  (* Opcion por default *)
  181.  if (ParamStr(3)<' ') then
  182.    sData:= 'OPTIONS /index.html HTTP/1.0'+BL+BL;
  183.  
  184.  (* Gathering automatico *)
  185.  if (ParamStr(3)>' ') then
  186.  begin
  187.    if (ParamStr(3)='get_proto_0') then
  188.      sData:= GET+STP+HTTP0+BL+BL;
  189.    if (ParamStr(3)='get_proto_1') then
  190.      sData:= GET+STP+HTTP1+BL+BL;
  191.    if (ParamStr(3)='post_proto_0') then
  192.      sData:= POST+STP+HTTP0+BL+BL;
  193.    if (ParamStr(3)='post_proto_1') then
  194.      sData:= POST+STP+HTTP1+BL+BL;
  195.    if (ParamStr(3)='options_proto_0') then
  196.      sData:= OPTIONS+STP+HTTP0+BL+BL;
  197.    if (ParamStr(3)='options_proto_1') then
  198.      sData:= OPTIONS+STP+HTTP1+BL+BL;
  199.    if (ParamStr(3)='head_proto_0') then
  200.      sData:= HEAD+STP+HTTP0+BL+BL;
  201.    if (ParamStr(3)='head_proto_1') then
  202.      sData:= HEAD+STP+HTTP1+BL+BL;
  203.  end;
  204.  Try
  205.    if (CALLBACK__getIp<='') then
  206.    begin
  207.      WriteLn('Conectando al servidor: ', GetIP); end
  208.    else begin WriteLn('Conectando al servidor: ', CALLBACK__getIp); end;
  209.  
  210.    Winsock.Connect(TcpSocket, sAddr, sizeof(sAddr));
  211.    WriteLn('Parametro: ', sData);
  212.    Winsock.Send(TcpSocket, sData, StrLen(sData), MSG_DONTROUTE);
  213.    Winsock.Recv(TcpSocket, BuffName, BSIZE, SD_RECEIVE);
  214.    WriteLn(BuffName);
  215.  Finally
  216.    Shutdown(TcpSocket, SD_BOTH);
  217.    CloseSocket(TcpSocket);
  218.    WSACleanUp();
  219.  end;
  220. end.
  221.  

Gathor con metódo OPTIONS:


Gathor con metódo POST:


Gathor con metódo GET:


Gathor con metódo HEAD:



PD: Lo del stack y el heap lo agrego por que aun que a muchos no les interese que sea una aplicación grande o pequeña, es un detalle que siempre tengo presente.

Y como ven el tamaño del stack no fue tan drástico (como en otras comparaciones que hice) y me olvide de tomar fotos  >:D
Claro que es un aplicación pequeña...




Y el heap por lo menos no se disperso tanto como pensaba...


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Información sobre Registros Variantes en Turbo Pascal.
Ejercicios
luistorcol 0 3,448 Último mensaje 25 Noviembre 2009, 02:11 am
por luistorcol
Pascal o C ??
Programación General
LeoJ24 1 2,004 Último mensaje 28 Febrero 2013, 23:20 pm
por 0xDani
Pascal vs C++: Pascal mejor que c++?
Programación General
Bomb-P 4 10,092 Último mensaje 11 Mayo 2013, 20:42 pm
por BlackM4ster
Gathor 0.5
Programación General
WarZ0n3 0 1,637 Último mensaje 24 Agosto 2013, 02:09 am
por WarZ0n3
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines