Man in The Middle Demystified<br />Keatron Evans<br />Senior Instructor<br />
Still one of the most dangerous attacks.<br />While most security professionals and administrators understand MiTM conceptually, few can actually execute it and prove to the laymen that it is a valid and real threat. In this presentation I’ll give a step by step complete with screenshots on exactly how it’s done.<br />
How does it happen?<br />Basically an attack on the arp protocol.<br /><ul><li>When computers communicate across a network the initiator sends an arp request that asks who has a particular ip address.
This request is broadcast to everyone on the LAN and depends on the only response coming from the true holder of said IP address.
The protocol has no built-in functionality to tell if the response comes from the true source.
Additionally, there’s no rule in the arp protocol that says one has to wait for a request to send a response!</li></li></ul><li>The Setup!<br /><ul><li>We’ll be using two servers.
One server will authenticate to another via ftp.
The arpspoof makes each victim 1 believe I’m victim 2 and make victim 2 believe I’m victim 1.
Once we’ve got this in place, I’ll turn on ip forwarding on Backtrack which allows me to route the packets on to the intended recipient, while still allowing me to “see” the packets.
We’ll have dsniff running as well to conveniently grab the credentials from the packets.</li></li></ul><li>Communications before attack<br />Normal traffic flow<br />Victim 2<br />IP address 192.168.2.138<br />Victim 1<br />IP address 192.168.2.128<br />Man in The Middle<br />IP address 192.168.2.135<br />
Communications after attack<br />Desired traffic flow<br />Victim 2<br />IP address 192.168.2.138<br />Victim 1<br />IP address 192.168.2.128<br />Man in The Middle<br />IP address 192.168.2.135<br />
Step 1<br />Let’s setup Backtrack properly first. There is chance that once you start it, you didn’t get an ip or your ethernet/or wireless interface wasn’t enabled. We’ll need to bring the interface up first. Then we’ll need to have it get an ip address via dhcp. So let’s do those things.<br />
Eth0 interface is down so let’s bring it up;<br />
After the up command we enter ifconfig again and see that eth0 is now up.<br />
Now we need to tell it to get an ip address via a dhcp request. The command is /etc/init.d/networking restart<br />
It gets an ip address from your dhcp server. Verify it with ifconfig again. We see we have an ip of 192.168.2.135.<br />
Now we go to our first victim and see that its’ ip is 192.168.2.128.<br />
Victim 2 has an ip address of 192.168.2.138.<br />
Here’s the Filezilla ftp server running on victim 1. <br />
Let’s verify that the two victims can communiate. I’m issuing a continuos ping from victim 2 (.138) to victim 1 (.128).<br />We’ll let this ping run continously because we’re going to interrupt it with our arpsoof and verify our spoof is working.<br />
Now we go back to our Backtrack and open three terminal shells (you’ll need all three). First arpspoof victim 2 to victim 1. In other words, make victim 1 think you’re victim 2. Now in the second terminal, do the exact opposite. See below.<br />
Once you hit enter on both terminal windows, you’ll see that it’s telling victim 1 that .138 is at the Backtrack mac address, while also telling victim 2 that .128 is at the Backtrack mac address.<br />
We verifty that the spoof is working by seeing if the pings we started earlier on victim 2 are now failing. See below.<br />
We have now successfully diverted both victims traffic to our Backtrack. Now we need to enable ip forwarding so we can now route this traffic to it’s intended destination.<br />
Once we’ve enabled ip forwarding, go back and check your pinging victim 2 and see that the pings are now successful again. Congrats! You’re now man in the middling. But we need to grab credentials. So we’ll need another tool for that.<br />
To grab authentication credentials, we’ll start up dsniff. See below.<br />
Now go to victim 2 and stop your pings. Then ftp to the ftp server running on victim 1. <br />
Next login with whatever credentials you’ve set up on it.<br />
Once you’ve successfully logged in you should see whatever files you have in your ftp store.<br />
Here’s the important part. Dsniff needs to see the entire session to get the credentials. Entire session includes the disconnection or logging off. So you have to end the session before the credentials are actually grabbed. Close your ftp session, then go back to your Backtrack terminal and see the login information. Feeling l33t yet?<br />
Closing<br />Lessons.<br />It is a classic mistake for the laymen and sometimes even security professionals to think that the answer is always the use of strong passwords. In the case of a man in the middles attack a strong 20 character complex password with numbers, letters, and special characters, is obtained just as easily and quickly as a 5 character letters only password.<br />Join us in one of our Ethical Hacking classes where I or another of our world class instructors will teach you how to perform man in the middle against encrypted protocols such as SSL.<br />Thanks for watching! <br />Keatron Evans<br />THIS PRESENTATION ALSO AVAILABLE ON Resources.InfosecInstitute.com<br />