🖥️
Offensive security concepts
  • Introduction
  • 💿Virtualbox network setup
    • What is VirtualBox?
    • NAT
    • NAT network
    • Bridged adapter
    • Internal network
    • pfSense
    • vboxmanage
    • Overview
  • 🕵️OSINT
    • What is OSINT?
    • Google dorks
    • Metadata
    • Social media
      • osintagram
  • Tools
    • waybackurls
    • recon-ng
    • sherlock
    • maltego
    • theHarvester
    • photon
  • 😨Social Engineering
    • What is social engineering?
    • 7 tricks of social engineering
    • Email phishing
    • Typosquatting
    • Compiled resources
  • 😈MitM attack
    • What is MitM attack?
    • ARP spoof/poison
    • DNS spoof/poison
    • HTTP MitM attack
    • ICMP redirect attack
    • DHCP spoofing
    • Evil twin attack
    • Experiment (guest network)
    • Compiled resources
  • 🔌UPnP exploitation
    • What is UPnP?
    • What is SSDP?
    • IGD functions
    • LAN devices
    • Compiled resources
  • Network Reconnaissance & Attacks
    • What is network recon & attacks?
  • 1️⃣Network live host discovery
    • What is network live host discovery?
    • nmap
    • arp-scan
    • masscan
  • 2️⃣Network port scan/services enumeration
    • What is network port scan/services enumeration?
    • nmap
    • netcat
  • 3️⃣Network services vulnerability scanning & exploitation
    • What is network vulnerability scanning/exploitation?
    • 20/21 ~ FTP
    • 22 ~ SSH
    • 25 ~ SMTP
    • 53 ~ DNS
    • 80/443 ~ HTTP/HTTPS
    • 110 ~ POP3
    • 111/2049 ~ RPC/NFS
    • 139/445 ~ SMB
    • 143 ~ IMAP
    • 3389 ~ RDP
  • Vulnerability & exploitation
    • Database
    • Metasploit
    • Msfvenom
  • Misconfigurations
    • .DS_Store
  • Web Application Penetration Testing
    • Introduction
    • Web Content Discovery
      • Directories/URLs gathering
      • Subdomain enumeration
    • File inclusion & Path traversal
    • Insecure Direct Object Reference (IDOR)
    • Upload vulnerabilities
      • File extension cheat-sheet
    • SSRF
    • CSRF
    • XSS
    • SSTI
    • SQL injection
      • Filter evasion techniques
      • Practical challenge examples
        • TryHackMe
          • TryHackMe Burp suite: Repeater room
          • TryHackMe Advanced SQL Injection
  • Authentication/session management
    • OWASP WSTG-SESS-10 ~ JSON Web Token (JWT)
    • OWASP WSTG-ATHZ-05 ~ OAuth weaknesses
  • Webshell
  • Web API pentesting
    • Resources
    • Methodology
    • jq
    • httpx
    • ParamSpider
  • Web app pentesting methodology
  • OWASP
    • OWASP top 10
    • OWASP API top 10
    • Web Security Testing Guide (WSTG)
      • WSTG-ATHZ
        • WSTG-ATHZ-05 ~ OAuth weaknesses
      • WSTG-SESS
        • WSTG-SESS-10 ~ JWT
  • General web knowledge
    • URI standard (RFC 3986)
    • HTTP headers
  • 🛣️Attacks on routing protocols
    • What are attacks on routing protocols?
    • BGP hijacking
  • 🏕️To explore
    • MQTT
    • Routersploit
    • DNS rebinding attack
    • LLMNR/mDNS poisoning
  • 👤Anonymity
    • VPN
    • Proxychains
    • TOR
    • Obfuscation
  • Credentials brute-force/cracking
    • Introduction
    • Windows SAM database
    • Dictionary attack
    • Rainbow attack
      • Hash database
    • Tools
      • Hydra
      • John the ripper
      • Hashcat
      • hash-identifier
  • Post-exploitation
    • Gaining shell
      • netcat
      • socat
      • powershell
      • bash
      • PHP
    • Repository
  • Privilege escalation
    • Linux
      • Repositories
      • Enumeration
      • Vulnerabilities exploit
        • General
        • Kernel exploit
        • Sudo
        • SUID
        • Capabilities
        • Cronjobs
        • $PATH
        • NFS (target-machine)
        • Filesystem sharing
          • NFS (attacker-machine)
    • Windows
      • Password harvesting
      • Vulnerabilities exploit
        • Scheduled tasks
        • AlwaysInstallElevated
        • Service misconfigurations
          • Insecure permissions on service executable
          • Unquoted service path
          • Insecure service permission
        • Abusing privileges
  • Ⓜ️MITRE ATT&CK
    • Introduction
  • 🧰Tools/services
    • Introduction
    • Web application pentesting
      • Web discovery/fuzzing
        • paramspider
        • arjun
        • katana
      • uro
      • Password brute-forcing
      • Burp Suite (Community)
      • scanners
        • ZAP (Zed Attack Proxy)
        • nikto
        • nuclei
    • Information gathering/reconnaissance
    • Network recon & attacks
      • nmap (general overview)
      • scapy
      • bettercap
    • General
      • impacket
    • Wordlists
      • cewl
  • Professional report writing
    • Report template
      • Web applicaton pentesting
        • OWASP report layout
  • Tasks on-the-go
    • Note taking on-the-go
    • Other tips
  • Practice
    • Web Application Pentesting
      • OWASP
        • OWASP Juice Shop
        • OWASP Mutillidae II
        • OWASP Hackademic
      • Vulnhub
        • ...
      • Damn Vulnerable Web Application (DVWA)
    • Metasploitable 2
  • Operational Security (OpSec)
    • Hardening
      • General
      • Oracle VirtualBox
      • Web Browser
      • VPN/Proxy
  • Safe document viewer
    • PDF
    • .docx
  • Write-ups
    • TryHackMe
      • Silver Platter
      • Light
      • Pickle Rick
      • Hammer
        • Enumeration (active recon)
          • /hmr
          • Further directory discovery
          • /phpmyadmin
          • burp suite sitemap
        • Brute forcing 4-digit code
        • Retrieving the flag
      • OWASP Top 10 - 2021 (task 22)
      • sqlmap
    • OverTheWire
      • Untitled
    • OWASP
      • OWASP Juice Shop
      • OWASP WebGoat
  • AI prompt
    • ChatGPT
Powered by GitBook
On this page
  • Overview of attack
  • Parameters
  • Attacking commands
  • msftconnecttest.com
  • Factors that trigger the browser to open the msfconnecttest.com/redirect address (theory)
  • Practical experimentation based on point 2 (force the NCSI probes to fail)
  • Experiment results
  • Further experimentation: authentication and automatic sign-in page
  1. MitM attack

HTTP MitM attack

This section combines the techniques from the ARP & DNS spoofing, and demonstrates how an attacker would be able to leverage the MitM position to intercept and modify HTTP data/traffic.

PreviousDNS spoof/poisonNextICMP redirect attack

Last updated 28 days ago

In an effort to understand the dangers of a public network, and the risks of ARP spoofing attacks, I have came up with a simple simulation example.

Overview of attack

Attacker

  1. Run a HTTP proxy server to intercept and sniff or modify data

  2. Run a rogue DNS server on the attacker machine, to resolve queries for a few selected or all the host names, to the IP address of the attacker. Special hosts file rules can be added for fake subdomains that does not exist

  3. Run ARP spoof attack on the victim machine, sending ARP replies to the victim and router gateway:

    • ARP reply to the gateway: <victim_ip>is-at<attacker_mac_addr>

    • ARP reply to the victim machine: <gateway_ip>is-at<attacker_mac_addr>

  4. Sends a phishing email to the victim, claiming to be from a trusted website. The email contains a seemingly legitimate HTTP link of a fake subdomain of the trusted root domain

Victim

  1. Receive an email claiming to be from a trusted website

  2. Clicks on the link provided in the email

  3. Provides login credentials to "authenticate" with the website

  4. Performs a certain action

Attacker

At this point, the user have gained control of the user's connection to the seemingly trusted website, and have stolen the login credentials

The attacker can exploit the user's trust in the website, and trick the user in performing actions

Parameters

Victim

  • Windows

  • 10.0.2.4

Attacker

  • Kali Linux

  • 10.0.2.5

Gateway

  • 10.0.2.1

Attacking commands

Terminal 1

  • Enable IPv4 forwarding

$ sudo sysctl -w net.ipv4_ip_forward=1
  • Create a firewall rule to redirect traffic to TCP port 80 (HTTP) to port 8080

$ sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
  • Compile and run the HTTP proxy

$ gcc mitm_proxy_http-hijacK.c -o http-proxy && sudo ./http-proxy

Terminal 2

  • Drop all DNS query destined for the actual gateway

$ sudo iptables -A FORWARD -d 10.0.2.1 -p udp --dport 53 -j DROP
  • Load DNS hosts file

$ cat hosts.spoof
10.0.2.5 *
  • Run DNS server

$ sudo dnsspoof -i eth0 -f hosts.spoof

Terminal 3

  • Run the ARP spoof attack

$ sudo arpspoof -i eth0 -t 10.0.2.4 10.0.2.1 -r

Craft and send a malicious phishing email

...

msftconnecttest.com

On a Windows machine, the address http://www.msftconnecttest.com/redirect is observed to be automatically opened on the default browser it is disconnected from a VPN, and subsequently reconnected. I have noticed that the website used in the Windows NCSI configurations are in HTTP, rather than HTTPS.

In an effort to understand why this happens, and how I can trigger this behavior, I have done some research. I hope to replicate this as an attacker while being on the same network as a target user, to trick their browser to open this address — which can be intercepted and modified.

Factors that trigger the browser to open the msfconnecttest.com/redirect address (theory)

  1. Proxy server connection is detected

    • Based on the TUN/TAP interface?

    • How to trick the user device to believe it is connected to a proxy server?

  2. NCSI probes failure

    • how to make it fail?

Refer to " Why default browser automatically opens" link below:

"In some cases, such as when you connect to a network that uses a proxy server to connect to the internet or when network restrictions prevent NCSI from completing its active probe process, Windows opens the MSN Portal page in the default browser."

Practical experimentation based on point 2 (force the NCSI probes to fail)

Assume the following:

  1. Both the user and attacker machine are in a virtualbox NAT network

  2. The default gateway and fake DNS address for the target user would be the attacker machine at a particular address

Attacker machine: Run usual ARP & DNS spoof techniques

  • IP forwarding, drop DNS packets, etc.

  • Resolve www.msftconnecttest.com to any address

Windows user machine: Simulate change in network settings

  • Trigger disconnect of network interface on Windows machine

$ ipconfig /flushdns
PS C:\Windows\System32> netsh interface set interface <iface_name> disable
PS C:\Windows\System32> netsh interface set interface <iface_name> enable

To flush the DNS cache, followed by disabling interface (disconnect from network), and wait a few seconds before connecting back again. The goal of these steps is to trick the use's Windows machine to trigger the process explained in the observation description above.

Connect to VPN (expected to fail) for a few seconds, before disconnecting again

This will trigger the NCSI probes process:

  1. DNS query for www.msftconnecttest.com

  2. If step 1 succeeds, HTTP request to http://www.msftconnecttest.com/connecttest.txt

  3. If step 2 fails to connect or doesn't return a valid content of "Microsoft Connect Test", the default browser with address http://www.msftconnecttest.com/redirect would be automatically opened

Attacker machine: Run a HTTP proxy to intercept traffic

Upon receiving HTTP request for http://www.msftconnecttest.com/connecttest.txt, either ignore the request, or reply with an invalid content (anything besides "Microsoft Connect Test") as mentioned above.

Subsequently, the default browser would be opened with HTTP GET request to http://www.msftconnecttest.com/redirect , where the content would be controlled by the attacker machine's HTTP proxy

NOTE:

  • ARP spoof: To redirect DNS & HTTP traffic during the NCSI probe process to the attacker machine

  • DNS spoof: To resolve www.msftconnecttest.com

  • HTTP proxy: To process requests for http://www.msftconnecttest.com/connecttest.txt and http://www.msftconnecttest.com/redirect

Experiment results

The attack does not work., which leads me to wonder how does the presence of a proxy server such as a VPN trigger the mentioned behavior?

The following is my theory on why the attack does not work:

The NCSI probes are sent immediately after the device reconnects, this means that the ARP poisoned entry is not in use yet, and the initial DNS query for www.msftconnecttest.com would be resolved by the actual gateway instead, followed by the HTTP request. This would allow the NCSI probe process to succeed. Hence, the http://www.msftconnecttest.com/redirect address would not be triggered on the default browser.

Further experimentation: authentication and automatic sign-in page

How to make the device believe that the network requires authentication, to trigger the sign-in page to be opened on the browser?

pending research...

😈
https://gohxiangzheng.com/projects/http-mitm-attack/gohxiangzheng.com
c-sockets/mitm_proxy_http_hijack.c at main · Jarrettgohh/c-socketsGitHub
Network Connectivity Status Indicator FAQ for WindowsMicrosoftLearn
Logo
An Internet Explorer or Edge window opens when your computer connects to a corporate network or a public network - Windows ClientMicrosoftLearn
Why default browser automatically opens
Logo
How to Fix Msftconnecttest Redirect Error in 5 Steps - Updated %%currentyear%%Comparitech
Logo
Logo