How to Proxy Xamarin Mobile Apps
This blog post assumes you’re working with physical rooted devices, digital devices may work but not tested.
If you’ve spent a bit of time testing mobile applications, chances are you’ve come across a mobile application that was built using Xamarin. Xamarin is a cross-platform application building tool for building iOS and Android mobile applications. This platform is becoming more and more common as an app building tool.
What’s the problem?
All apps built in Xamarin by default ignore proxy settings that are set on the mobile device. A critical part of performing any testing on mobile applications is viewing and modifying requests before they reach the server. In non-Xamarin mobile applications, this is completed by using the proxy settings on the device and capturing the packets with your favourite tool (eg Burp proxy).
Android Bypass
If you’re just testing the Android side of the application, there’s a very simple bypass that gets around these proxy settings with a few commands.
Note: Burp is set up on a VM with a bridged IP address (192.168.0.210 in this case) and configured to receive connections on this IP instead of 127.0.0.1.
Assuming you’ve got your burp certificate set up, you should now see the traffic in burpsuite.
iOS Proxy
Setting up a proxy for Xamarin apps on iOS is a bit more work unfortunately. There are many ways to do this, I’ve found this to be the easiest with the least amount of headaches. You need to set up a VPN server on a virtual machine (could be the same Kali box you’re using to run burp - in my case it isn’t due to my Kali box giving me errors at the time) and then connect the iOS device to that VPN. This forces all traffic to go through your VPN which you can then funnel into burp.
With the VPN set up on the host you should now have a .ovpn file you can use on your iOS device. I chose to transfer this with SCP as SSH was set up on my device already.
Install OpenVPN on the iOS device, I chose to copy over an .apk file over and install it using Filza instead of dealing with the App Store. Then, install the profile you received when you set up the OpenVPN server on your VM.
Now, we’ve got our iOS device sending traffic to our VM that is running OpenVPN. Great! Let’s get it to now go into burp.
To do this we need to run a few iptables commands on the linux box that is running the OpenVPN server to force the traffic from the OpenVPN box to Burpsuite.
Finally, you just need to enable invisible proxying in burp.
Within Burp go to Proxy > Options > Select Proxy Listener > Edit > Request Handling > Support Invisible Proxying Assuming you have the burp certificate installed and there’s no certificate pinning enabled on this application you should see the traffic flowing through burp.
This technique can also be used for Android in the same way, however I personally opt for the easier way.
Conclusion
Xamarin apps appear to be more and more common these days, however, once you set this up once you should be good to go for any future apps after that. I think these methods are a lot nicer than using mitmproxy and a Digital Ocean box.
Thanks for reading.
Peace.
Credit Salman Syed’s Medium post that helped me grasp the iOS side of things originally.