iOS Pentesting Behind VPN Pentest Environment Setup

Intro


I recently had a fair bit of difficulty arriving at a suitable network setup for pen testing an iOS app (Note this is a hybrid app - and heavily based on APIs), as I was testing an environment behind VPN (such as Cisco Anyconnect), I had go for dual vpn setup to access the APIs within the Corporate network.



So I wrote this article basically to make sure this will help someone and more importantly I don't forget. One of the primary goal with any pentesting is to MITM the traffic from the iDevice.
This can be achieved by using OpenVPN (on Ubuntu VM) and OpenConnect Client (on iDevice). Additionally, we need to ensure the Burp invisible proxy is enabled, literally we are treating the app as a proxy-unaware app.

Credits:
https://security.stackexchange.com/questions/190568/optimal-way-to-capture-https-traffic-on-proxy-unaware-ios-applications
https://portswigger.net/burp/documentation/desktop/tools/proxy/options/invisible

Pre-Reqs:
  • Jail-Broken iPhone(iDevice) (I was on 12.4 with checkra1n exploit installed, Cydia installed - key tools installed -- like openssh) 
  • Macbook (may be a QEMU based OSX would work; don't hold be responsible!!)
  • Ubuntu VM (Bridged and I prefer this way as it's easy to remove and backup test environments)
  • Burp / iDevice configured to proxy -- the normal way working HTTPS calls intercepted (i.e. all the SSL bit sorted. I got stuck for not enabling PortSwigger certificate on FULL trust; Settings > General > About > Certificate Trust Settings)

Step 1 : The main goal in this step is to create a OpenVPN server (UbuntuVM) and client environment (iDevice).

$ curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh

$ chmod +x openvpn-install.sh

$ sudo bash openvpn-install.sh

*Leave all the default settings here (we are setting a temp system we are throwing away after the test anyways.

At the end of the setup create a client profile, I just gave the name of my iPhone.

Confirm if the OpenVPN process has started:

$ sudo ss -tunlp | grep openvpn
$ ifconfig

A new 'tun0' interface should be created.

Copy the *.ovpn file to the device.

Install OpenVPN app on iOS, load the profile.

Step 2 : Configure IPTables on Ubuntu VM

I followed the StackOverflow article listed above and setup my new OpenVPN 'tun0' interface to forward traffic to port '8080' on localhost.

iptables -t nat -A PREROUTING -i tun0 -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A PREROUTING -i tun0 -p tcp --dport 443 -j REDIRECT --to-port 8080

Step 3 : Configure BurpSuite further

Goto Proxy > Options > Add > then select > All Interfeces > Add port : 8080; like this below:


And the support the invisible proxying. 


Enabling Invisible Proxy support ensures to treat the app as a proxy-unaware app and ensures all traffic goes through the listener. 

Step 4 : Connect to the VPN 

Now, on the UbuntuVM connect to the corporate VPN (in my case it was using Cisco Anyconnect).

That's it.

Now that's done -- Connection/setting environment is one thing, attacking a React Based iOS app is another... :-)

















Popular posts from this blog

The correct way to install Jython (for Burpsuite)

RFID cloning with Proxmark3 Easy

Extracting an IPA; App distributed through Testflight