Pinned
Pinned
Description
This app has stored my credentials and I can only login automatically. I tried to intercept
the login request and restore my password, but this seems to be a secure connection.
Can you help bypass this security restriction and get back my password?
Objective
Perform SSL Pinning Bypass to intercept the login request and get the
flag.
Difficulty
Medium
Flag
HTB{trust_n0_1_n0t_3v3n_@_c3rt!}
Release:
/release/pinned.zip
( f75b6eb5295e50b994bd360d7fa9fbe9ab01c07a1d69de6b7832a6cf6013d2d8 )
Prerequisites
A virtual Android image like Android-x86 running on Virtual Box or VMware or another
Android emulator, running with the Developer mode on.
Alternatively, a real android device connected via USB, running with the Developer
mode on.
Challenge:
Unzipping the pinned.zip file reveals the file pinned.apk . In order to run the
pinned.apk file, we have to set up an Android emulator. To achieve this, we are going to
use Android Studio IDE.
wget https://redirector.gvt1.com/edgedl/android/studio/ide-
zips/4.2.1.0/android-studio-ide-202.7351085-linux.tar.gz
tar xvzf android-studio-ide-202.7351085-linux.tar.gz
sh android-studio/bin/studio.sh
On the setup wizard we click OK , then we click on Next , and finally click on Finish .
Next, we wait for the Android Studio to download the components.
On the AVD Manager menu, click on the green "play" button to start the emulator.
Once the device is started, It should be looking like this.
Then, we install adb so we can communicate with it.
In our Android device terminal we type ifconfig to get the device's IP. Once we get the IP,
we type the following to establish the connection.
Next, we can list the devices that are connected by typing the following command.
adb devices
The connected devices might be displayed either with the format of name-port or ip-
port . In this case the device is displayed as emulator-5554 . Now that we are connected
to the device, let's go on and install the pinned.apk file.
According to the challenge description, before we go on and run the application, we have to
add the following domain name into the /system/etc/hosts file.
adb root
adb shell
mount -o rw,remount /system
echo "10.10.10.112 pinned.com" >> /system/etc/hosts
mount -o ro,remount /system
cat /system/etc/hosts
reboot
We can now run the application on the Android device.
This is a login screen asking for username and password. The credentials are stored and as
the message indicates, we can successfully login. Let's try to intercept the request and see
if we can get the password in plaintext. In order to setup Burp, type the following on the
host machine to get the ip address.
ifconfig
On the Burp Suit Proxy tab, go on Options and press the Add button under the Proxy
Listeners section.
On the pop up window type the port 8090 and select the host's IP from the drop down
menu.
Click OK and make sure the new proxy listener is selected.
Back to the Android emulator, click the three dots from the vertical menu near the device.
On the Extended Controls pop up window, click on settings. Then, uncheck the Use
Android Studio HTTP proxy settings , and check the Manual proxy configuration .
On the Host name field, add the host IP address, and on the Port number add 8090 .
Finally click APPLY .
The Proxy status should say Success . Then, go back on the Intercept tab on Burp,
and make sure the Intercept is on button is toggled. Finally, on the Android device click
the LOGIN . The request should now be intercepted on Burp.
As we can see, it failed to intercept the request and the tab Dashboard is now toggled on.
Navigating to the Dashboard tab, we can see that the alert Received fatal alert:
certificate_uknown . has been raised.
This means that SSL Pinning might be used. In order to bypass SSL Pinning, we first need
to run frida-server on the Android emulator device. Once we download the file, we type the
following to upload it to the device.
adb root
adb push frida-server-14.2.18-android-x86_64 /data/local/tmp/frida-
server
In order to bypass SSL Pinning using frida , we also need to download the script frida-
android-repinning. Once we copy and paste the code into a file and name it frida-
android-repinning.js , we start the frida-server on the emulator by executing the
following command. First, make sure you are in root mode by executing the adb root
command.
adb root
adb shell chmod 755 /data/local/tmp/frida-server
adb shell /data/local/tmp/frida-server &
Then, locate the app Pinned in the emulator and tap on it to start. Once the app is started
type the following on the terminal to locate the full name of the application.