Redirecting HTTP LAN Traffic to a Malicious Site
After breaching the perimeter, there are many techniques to choose from to expand influence within a LAN. In many cases, using Responder or other methods will yield satisfactory results very quickly. In other cases, you might have to get creative due to defensive mitigations or due to a small attack surface. One possible attack to chose, would be a PiTM (person-in-the-middle) attack which impersonates the gateway and sends unencrypted HTTP traffic to a malicious website. If an attacker has control of a Linux host on the LAN, this attack can be performed with arpspoof. The attack disrupts a victim's unencrypted HTTP traffic and would ideally only be run in a targeted manner.
Please keep in mind that this attack will ultimately result in a DoS on all traffic destined for port 80, including traffic not generated by the browser, like updates, etc.
Below are the details on the test environment LAN I'll use to demonstrate:
- Router
- 10.0.0.1
- Ubuntu host machine running VirtualBox (this attack is much more complicated in VMWare)
- Kali Linux 2022.1 VM
- 10.0.0.83
- dsniff 2.4 (includes arpspoof)
- Windows 10 VM
- 10.0.0.161
- IPv6 disabled
- DNS cache cleared
- Microsoft Edge version 101.0.1210.53 64-bit (history cleared)
- Firefox 101.0 64-bit
We also need to enable IPv4 forwarding so we can forward packets from the victim computer to the real router, otherwise the victim's internet connection will be completely down:
As a side note, the following command does the same thing as the previous command, so either is fine:
There are a variety of things that can be done with the intercepted traffic, but for this attack, we will forward all traffic destined for port 80 to 8080, where a malicious web server will be listening. Forwarding encrypted TLS traffic is more problematic due to HSTS, etc. and has more prerequisites, so we'll stick with unencrypted HTTP for this test. Here's the command we'll use to send HTTP to our malicious web server:
sudo iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 8080
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url='https://jamesonhacking.blogspot.com/'" />
</head>
<body>
</body>
</html>
- This particular methodology with this particular toolset is only designed for IPv4 traffic. For this test environment, I recommend disabling IPv6 in Windows and clearing the DNS cache in case any IPv6 addresses are cached.
- Chrome now defaults to https:// for typed navigations, unless the user manually enters http://. At the time of this post, Firefox and Edge do not.
- If performing this test with Firefox, do not use Private Browsing mode, because in this case Firefox does rewrite http:// as https://.
- HSTS can be a showstopper. If the target URL the victim types into the browser is on Firefox's HSTS preload list or in Edge's similar list, the browser will modify the scheme from http:// to https://. In the case of a target website which has previously responded to the browser with a Strict-Transport-Security header, it will *also* do this. For our test environment, it is advisable to clear the Firefox or Edge browser history before testing, so as to remove any site added to the HSTS list via responses containing the Strict-Transport-Security header. In the case of Firefox, it's also advisable to perform a refresh.
- Even if HSTS isn't a factor, the browser may autocomplete the URL with https:// based on the browser history. Again, for this test exercise, be sure to clear browser history.
- In some environments, there may be protections in place like DHCP snooping, port security, etc., which prevent ARP spoofing.
- We use the Kali box to poison the ARP cache on the Windows host so that the MAC address of Kali is associated with the IP address of the router
- The victim types in icanhazip.com and this generates a DNS request which is forwarded up the chain by the Kali box to a legitimate DNS server.
- The victim then sends a request to the IP address of icanhazip.com on port 80 and the request is intercepted by our Python3 web server listening on 8080. Because the request doesn't use TLS (with an https:// scheme), the victim doesn't perform any validation to confirm that the website is who it says it is.
- At this point, any malicious content within index.html can be sent back to the victim. It could be a phishing site asking for credentials or offering a malicious download, etc. In our case, index.html contains a redirect.
Comments
Post a Comment