Man In The Middle Attack

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhShUSk2mYXSKlSiGHY0R2uxvMG7kRN1013WuKx1iPJ5Q_H-kS1B3piWGN1GDiRqdjU6EfzMIwdLAz2OhxRbS-G9aaKk159UzwcYwVi1rdmwJiobMprw-XUk3dZ1zM8cUA9khekBs0CuvU/s400/man-in-the-middle.jpg

Man in the middle attack is usually used to capture data packets which are containing sensitive data like username and password. Hackers who are using this technique, should be in the same network with the victims. Man in the middle attack is the further implementation of ARP Spoofing / Poisoning which is already explained in my post. ARP Spoofing / Poisoning will changes the ARP table and makes hackers device as a gateway. In other words, all data packets passing hacker's PC before going to "Real" destination.

This time, I'm explaining this technique for penetrating test only to find your web application vulnerabilities and test your network security. First, you need two applications :

  1. Ettercap (For windows, For Linux)
  2. Wireshark (link)
After both application installed in your PC, you should follow this steps :
1. Connect to your network and make sure that subnet of your IP address is same with target's IP address. NB: It won't works when connected to network which has 32 network prefix or with subnet 255.255.255.255.
2. Open your ettercap and perform unified sniffing for multiple targets, or bridged sniffing for 2 targets only. I suggest to use unified sniffing because it's more flexible for use to choose the targets. After that choose your network interface.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSRC8m57sbCabWMISpWgh7xjlw-KJPgrlRhsAbm0kSaWg0Q-d28czoRvg1x2fzUoqGXriCP62vEyrdT8N082XWFyyLutQ0JQEo5d70pyvdFtASmrzObXs6zcksEvNXnbfKI_Kv52LvfLo/s400/ettercap-step1.jpg
3. Go to Host and choose Scan for hosts. After that choose your targets or select all targets except gateway IP Address.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrEU1Bi3cvy4pKPqGX99sXrCNpakaWCoVIEEBSBaxI5NuL2foSzywe_79TCmheIk96ysXu6mSVirYpvc_jQV9Tvj4Zvb5ZS9Ykj_KPxnch-Q-KtYgumOioTR-CZJWLuUR9Q_2DqRqSgqQ/s400/ettercap-step2.jpg
4. Go to Mitm on menu bar, and choose ARP Poisoning. After that minimize your Ettercap.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4E1WNSjHmxbXqgGD1z7QKWpfL9ENcwqMQSXvP8ajk1_k1ux4fwVIeoBkBVAhcUbk25_3Ijk8NWAbI6-IU6g_GCQqtOAX_CtQePujNDfVp_-ORFTWA_wLW2i751Qhd5uDEZgBofYk_J7g/s400/ettercap-step3.png

5. Open Wireshark and choose your network interface, then click Start.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP_14TqG-XfFFP53kXCryEdGfugRsNvQ0sR6xmRQtrhu1org3FHld0fMjHSKlU1oknc-iJxChZv04vQwF-eMlcEIRxirVWN6HggB7Y2is4M3i1251XgThrTL9pwdDd1DC8YycsYGZPCjg/s400/wireshark-main.JPG
6. In this implementation, I'm trying to capture Username and Password which are sent by user from login page of  HTML / PHP Web Application through TCP/HTTP protocol.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjK9qxR2OqPyuKDi5fs5AlYtEz5ciKl257IcX7qaE6_c-WzUzsBM6FlaPb1ourNpP-rY7yuIzQ5cQYuFRWdWiVy0fxOu_E9Yvqf5rScP4Kh1LAygNQdhCGurV23IYB0EKae3T3M0Zn67rY/s400/login1.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTYtzkuOErgojquolgD61c4h1qPhAXbWvEg1qtBwxzR0mXxACRoYZZrwFEaBy5ww8_XqqpNjZRZaRr4oVdiawOJtHNSZ18l7TMGuKIS2TKJI1CEbj1HS0xqvfoXB8r5SGts1Np-_MWVtk/s400/login2.jpg

7. In this scenario, you will get a thousands of captured data packets. If you think the time is enough, you may click stop button with red color on the top. After that, type "http" on filter search to find all http data packets. Find the POST data info on the table and click on it. After that expand HTML Form URL Encoded and then you get the username and password.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiouUvrhCPiXNXBtt9_ieTiK5Mq24q9FeBxaKUWJUSGhndxAKj32K9K0jik2FAnGc4CFoBVmxh1FqdJTDAnrQpTMXmZbDTeEfxbgzzsERBYStoXeLJGB5ydtfMFp3FH0NqNCsoVsVcyg2Q/s400/wireshark.jpg


Conclusion

Man in the middle attack technique effectively attacks web application with HTTP protocol and weak network security. Because hackers easily read all non-encrypted data packets which are containing sensitive information like username and password. Also,the core of man in the middle attack is ARP Poisoning/Spoofing. With it, hacker acts as a "fake" network gateway and get all information in that network.

To prevent it, as a common user, we have to make sure that we access the right web application which use SLL/HTTPS encryption. As a programmer, we should implement SSL/HTTPS and also SHA1 encryption for user's password for completing our system security and giving a security warranty of user's personal data. As network administrator, you should read my last post.

Comments