Cracking the Code: How I Decrypted a Mobile App’s ‘Secure’ Login Secrets
The mobile app encrypted login credentials with AES using a hardcoded key and IV derived from a string resource. An attacker with the APK could extract the key and decrypt captured credentials.
Published on medium.com
Hey there, fellow tech enthusiasts and aspiring hackers! Imagine this: You’re poking around a mobile app during a penetration test (pentest for short that’s when we ethically hack apps to find vulnerabilities), and you spot something fishy in the login traffic.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the app used symmetric encryption with a key and IV derived from a hardcoded string resource, making the key extractable from the APK.
Impact
An attacker who obtains the APK could decrypt captured login credentials, potentially leading to account compromise.
What the attacker needed
Access to the APK; ability to capture network traffic
The fix
The app should use proper key management instead of hardcoding secrets in the APK.
How it was found
- Capture login traffic with a proxy to see encrypted uName and uPassword fields.
- Decompile the APK with JADX and search for crypto-related terms and field names.
- Locate the encryption class and note how the key and IV are derived from a resource ID.
- Resolve the resource ID to the actual string in strings.xml.
- Derive the key and IV from that string.
- Normalize the captured string and decrypt it with AES.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
The app scrambled your username and password before sending them, but it used a secret key that was stored inside the app itself. Anyone who downloads the app can find that key and unscramble the data, so the protection is useless.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.