In this blog, we will go through proxying an iOS application which uses native web sockets to interact with a web server. The blog will help penetration testers who are trying to intercept sensitive data that is being sent by an iOS application in a non-trivial manner over the network because some applications do not respect the iOS proxy settings.
During a recent iOS application penetration test, I encountered an iOS application that was sending data to port 20xx on a web server. This application traffic could not be proxied by changing the iOS manual proxy settings located at (Settings -> Wi-Fi -> HTTP Proxy -> Manual) and forwarding the iDevice traffic to the proxy. One of the reasons that the normal proxying method might be failing is because it might be using some native websockets to interact with the web server instead of the normal UIWebView class. For more technical details of how websockets in native iOS can be configured, check out this elabs blog post.
There is a workaround to fix this problem. We can perform DNS spoofing to forward all the HTTP traffic for all of the ports through a MitM proxy like Burp. The blog is divided into three main steps.
Sniff traffic using Wireshark to find out the port and IP of the webserver.
Spoof the DNS for the iDevice to send all data to laptop.
Start a proxy on the laptop to intercept traffic all traffic from iDevice after DNS spoofing.
Given below is a step by step approach to intercept Native Web Socket iOS application traffic.
Create a wireless hot spot with your machine and connect the iDevice to the hotspot. [Note the machine needs to be connected to Ethernet or some other route out to the internet as the Wi-Fi interface will be used for the hotspot. Refer here for information on how to create a hotspot on a windows machine]
Start a network sniffer (like Wireshark) and look for traffic going to any non-standard ports.
Filter the traffic to look at the traffic going to the destination server IP (ip.dst== ip.ip.ip.ip)
Note the port number where the traffic is being sent.
Fig 1: Finding the non-standard port number where application sends Traffic.
Start the Metasploit console to perform DNS spoofing and enter the following commands.
set SRVHOST = (IP address of laptop which is running the hotspot)
set SRVPORT = 53, set TARGETACTION = BYPASS, set TARGETDOMAIN = www.apple.com (Note: by setting TARGETDOMAIN= www.apple.com, all the traffic except the traffic coming from apple.com will be spoofed)
set targethost = (IP address of laptop which is running the hotspot)
Fig 2: Configuring DNS server on the laptop using fakedns module in Metasploit.
Configure Burp to listen on specific ports for the incoming traffic from iDevice and forward it to the appropriate port as follows:
Go to Proxy’Options’Add; set ‘bind port’ to the port where the traffic needs to be sent (note: this is the non-standard tcp port number recorded in Wireshark)
Listen on all interfaces
Click Request Handling’ Redirect to host: (Enter the domain name of the server)
Request Handling ‘ Redirect to port: (Enter the corresponding port number)
Click force use of SSL if the outgoing traffic is sent using https.
Click ok and repeat the above steps for all the ports that the iOS application is explicitly sending HTTP application traffic to. In other words, every port will require a separate Proxy listener to be configured in burp.
Fig 3: Configure incoming listener and redirect the iDevice traffic to appropriate IP and port to Server.
Configure Proxy settings in iDevice:
Click settings ‘ Wi-Fi ‘Click on hotspot ‘ DHCP and set DNS = (IP of Laptop)
Set HTTP Proxy to the IP address of the laptop and corresponding port in burp. (this is the normal setting to proxy standard HTTP traffic)
Fig 4: Configure IP and DNS forwarding settings in the IOS device.
Type “exploit” in the Metasploit console and you will see the application traffic been proxied for non-standard ports in burp.
This small tweak can be used to overcome the problem of proxying non-trivial iOS application traffic.
PTaaS is NetSPI’s delivery model for penetration testing. It enables customers to simplify the scoping of new engagements, view their testing results in real time, orchestrate faster remediation, perform always-on continuous testing, and more - all through the Resolve™ vulnerability management and orchestration platform.
We help organizations defend against adversaries by being the best at simulating real-world, sophisticated adversaries with the products, services, and training we provide. We know how attackers think and operate, allowing us to help our customers better defend against the threats they face daily.
At NetSPI, we believe that there is simply no replacement for human-led manual deep dive testing. Our Resolve platform delivers automation to ensure our people spend time looking for the critical vulnerabilities that tools miss. We provide automated and manual testing of all aspects of an organization’s entire attack surface, including external and internal network, application, cloud, and physical security.
Our proven methodology ensures that the client experience and our findings aren’t only as good as the latest tester assigned to your project. That consistency gives our customers assurance that if vulnerabilities exist, we will find them.