Alberto Ornaghi alorantifork org Marco Valleri nagaantifork org
Alberto Ornaghi <alor@antifork. org> Marco Valleri <naga@antifork. org> Man in the middle attacks Demos Blackhat Conference - USA 2003 1
The scenario Server Attacker Client Blackhat Conference - USA 2003 2
Once in the middle… n Injection n Key Manipulation n Downgrade attack n Filtering Blackhat Conference - USA 2003 3
Injecting n Possibility to add packets to an already established connection (only possible in full-duplex mitm) n The attacker can modify the sequence numbers and keep the connection synchronized while injecting packets. n If the mitm attack is a “proxy attack” it is even easier to inject (there are two distinct connections) Blackhat Conference - USA 2003 4
Injecting Command injection n Useful in scenarios where a one time authentication is used (e. g. RSA token). In such scenarios sniffing the password is useless, but hijacking an already authenticated session is critical n Injection of commands to the server n Emulation of fake replies to the client Blackhat Conference - USA 2003 5
Command Injection DEMO Blackhat Conference - USA 2003 6
Key Manipulation n SSH v 1 n IPSEC n HTTPS Blackhat Conference - USA 2003 7
Key Manipulation SSH v 1 n Modification of the public key exchanged by server and client. start Server KEY(rsa) S-KEY M MITM Ekey[S-Key] Eskey(M) S-KEY Client KEY(rsa) Ekey[S-Key] S-KEY D(E(M)) Blackhat Conference - USA 2003 8
SSH v 1 Attack DEMO Blackhat Conference - USA 2003 9
Key Manipulation IPSEC If two or more clients share the same “secret”, each of them can impersonate the server with another client. Diffie-Hellman exchange 1 – Authenticated by pre-shared secret Client Diffie-Hellman exchange 2 – Authenticated by pre-shared secret Mi. M De-Crypt Packet Server Re-Crypt Packet Blackhat Conference - USA 2003 10
Key Manipulation HTTPS We can create a fake certificate (eg: issued by Very. Sign) relying on browser misconfiguration or user dumbness. Client Fake cert. Mi. M Real Connection to the server Blackhat Conference - USA 2003 Server 11
HTTPS Attack DEMO Blackhat Conference - USA 2003 12
Filtering n The attacker can modify the payload of the packets by recalculating the checksum n He/she can create filters on the fly n The length of the payload can also be changed but only in full-duplex (in this case the seq has to be adjusted) Blackhat Conference - USA 2003 13
Filtering Code Filtering / Injection n Insertion of malicious code into web pages or mail (javascript, trojans, virus, ecc) n Modification on the fly of binary files during the download phase (virus, backdoor, ecc) Blackhat Conference - USA 2003 14
Binary Modification DEMO Blackhat Conference - USA 2003 15
Filtering HTTPS redirection Let’s see an example Change form destination to http: //attacker Http post (loginpassword) Client Http main page with https login form Mi. M Auto-submitting hidden form with right authentication data login password Server Real https authentication post Authenticated connection Blackhat Conference - USA 2003 16
HTTPS Redirection Attack DEMO Blackhat Conference - USA 2003 17
Downgrade Attacks n SSH v 2 n IPSEC n PPTP Blackhat Conference - USA 2003 18
Downgrade Attacks SSH v 2 v 1 n Parameters exchanged by server and client can be substituted in the beginning of a connection. (algorithms to be used later) n The attacker can force the client to initialize a SSH 1 connection instead of SSH 2. – The server replies in this way: n n SSH-1. 99 -- the server supports ssh 1 and ssh 2 SSH-1. 51 -- the server supports ONLY ssh 1 – The attacker makes a filter to replace “ 1. 99” with “ 1. 51” n Possibility to circumvent known_hosts Blackhat Conference - USA 2003 19
SSH v 2 Downgrade DEMO Blackhat Conference - USA 2003 20
Downgrade Attacks IPSEC Failure n Block the keymaterial exchanged on the port 500 UDP n End points think that the other cannot start an IPSEC connection n If the client is configured in rollback mode, there is a good chance that the user will notice that the connection is in clear text Blackhat Conference - USA 2003 21
Downgrade Attacks PPTP attack (1) n During negotiation phase – – – Force PAP authentication (almost fails) Force MS-CHAPv 1 from MS-CHAPv 2 (easier to crack) Force no encryption n Force re-negotiation (clear text terminate-ack) n Force “password change” to obtain password hashes – Retrieve passwords from existing tunnels – Perform previous attacks – Hashes can be used directly by a modified SMB or PPTP client – MS-CHAPv 2 hashes are not usefull (you can force v 1) Blackhat Conference - USA 2003 22
Downgrade Attacks PPTP attack (2) Force PAP from CHAP Server req | auth | chap start MITM Client req | auth | fake nak | auth | pap nak| auth | chap req | auth | pap ack | auth | pap We don’t have to mess with GRE sequences. . . Blackhat Conference - USA 2003 23
Downgrade Attacks L 2 TP rollback n L 2 TP can use IPSec ESP as transport layer (stronger than PPTP) n By default L 2 TP is tried before PPTP n Blocking ISAKMP packets results in an IPSec failure n Client starts a request for a PPTP tunnel (rollback) n Now you can perform PPTP previous attacks Blackhat Conference - USA 2003 24
PPTP Attack DEMO Blackhat Conference - USA 2003 25
MITM attacks Different attacks in different scenarios: LOCAL AREA NETWORK: - ARP poisoning - DNS spoofing - Port stealing - STP mangling FROM LOCAL TO REMOTE (through a gateway): - ARP poisoning - DNS spoofing - ICMP redirection - IRDP spoofing - DHCP spoofing - route mangling REMOTE: - DNS poisoning - route mangling - traffic tunneling WIRELESS: - Access Point Reassociation Blackhat Conference - USA 2003 26
MITM attacks ARP poisoning n ARP is stateless (we all knows how it works and what the problems are) n Some operating systems do not update an entry if it is not already in the cache, others accept only the first received reply (e. g solaris) n The attacker can forge a spoofed ICMP packets to force the host to make an ARP request. Immediately after the ICMP it sends the fake ARP replay n Usefull on switched lan (the switch will notice the attack) Blackhat Conference - USA 2003 27
MITM attacks ARP poisoning - countermeasures n n n n YES - passive monitoring (arpwatch) YES - active monitoring (ettercap) YES - IDS (detect but not avoid) YES - Static ARP entries (avoid it) YES - Secure-ARP (public key auth) NO - Port security on the switch NO - anticap, antidote, middleware approach Blackhat Conference - USA 2003 28
ARP Poisoning DEMO (all we have done until now…) Blackhat Conference - USA 2003 29
ARP Poisoning Antidote Kernel Patch n http: //www. securityfocus. com/archive/1/299929 n “Kernel will send ARP request to test if there is a host at old MAC address. If such response is received it lets us know than one IP pretends to have several MAC addresses at one moment, that probably caused by ARP spoof attack. ” n We can fake this protection if the ARP entry is not in the cache and the real mac address will be banned Blackhat Conference - USA 2003 30
Antidote Attack DEMO Blackhat Conference - USA 2003 31
MITM attack Port stealing n The attacker sends many layer 2 packets with: n The attacker now has “stolen” victim hosts’ ports n When the attacker receives a packet for one of the victims it generates a broadcast ARP request for the victim’s IP address. n When the attacker receives the ARP reply from the victim, the victim’s port has been restored to the original binding state n The attacker can now forward the packet and restart the stealing process n Possibility to circumvent static-mapped arp entries – Source address equal to victim hosts’ address – Destination address equal to its own mac address Blackhat Conference - USA 2003 32
MITM attack Port stealing - countermeasures n YES - port security on the switch n NO - static ARP Blackhat Conference - USA 2003 33
Port Stealing DEMO Blackhat Conference - USA 2003 34
Q&A Alberto Ornaghi <alor@antifork. org> Marco Valleri <naga@antifork. org> Blackhat Conference - USA 2003 35
- Slides: 35