Cyber SecurityReverse Engineer

How I Reverse Engineered a Video Streaming App to Extract Hidden Video URLs

Ever wondered how mobile streaming apps protect their video content? Today I’m sharing my journey into reverse engineering an Android video streaming app to uncover how it encrypts video URLs and generates API signatures. This isn’t just theory – it’s a real hands-on breakdown of the entire process.

The Challenge: Locked Behind Encryption

I recently came across this video streaming app that caught my attention. Unlike YouTube or other platforms where you can easily inspect network requests, this app had everything locked down tight. The video URLs weren’t just sitting there in plain text – they were encrypted in something called a play_info field that looked like complete gibberish.

Here’s what a typical encrypted video URL looked like:

Not exactly readable, right? But hidden inside this encrypted mess were multiple high-quality video URLs for different resolutions and codecs. The question was: how do I crack it?

Tools of the Trade

Before diving into the technical details, let me share the tools that made this possible:

Frida – This is hands-down the best dynamic analysis tool for mobile apps. Think of it as a way to inject your own code into a running app and see what’s happening under the hood.

Ghidra – The NSA’s free reverse engineering tool. Yeah, you read that right. The same agency that deals with nation-state cyber threats released this powerful disassembler for public use.

Android Debug Bridge (ADB) – Essential for working with Android devices and extracting app files.

Node.js – For building the final decryption script once I figured out the algorithm.

Step 1: Finding the Decryption Logic

The first challenge was figuring out where in the app’s code the decryption was happening. Mobile apps aren’t like websites where you can just “view source” – they’re compiled binaries with thousands of functions.

I started by decompiling the APK file and searching for anything related to video playback. After digging through hundreds of Java classes, I found this interesting piece in the PlayerViewModel class:

Bingo! The play_info was being decrypted using SBUtil.decryptChapterContent() with something called PRIVATE_KEY_VERSION. This was my smoking gun.

Step 2: Hooking Into the Native Code

The SBUtil class was interesting because it was calling native functions (written in C/C++, not Java). This meant the actual encryption logic was hidden in a compiled library file called libstupid.so – and yes, that’s actually what they named it.

Using Frida, I was able to hook into the app while it was running and capture exactly what was happening during decryption:

This revealed something fascinating. The decryption process had multiple steps:

  1. Base64 decode the input
  2. AES-128-CBC decryption
  3. Another Base64 decode
  4. zlib decompression
  5. JSON parsing

Step 3: Extracting the AES Key

The real breakthrough came when I used Ghidra to analyze the native library. Deep in the assembly code, I found two functions that generated the encryption keys:

With these keys in hand, I could now decrypt the video URLs outside of the app.

Step 4: Building the Decryption Script

Armed with the AES key, IV, and understanding of the process, I built a Node.js script that could decrypt any play_info string:

The Payoff: Clean Video URLs

When I ran this script on the encrypted play_info, here’s what came out:

Perfect! Multiple video URLs with different codecs (H264 and H265) and quality options, all neatly organized in JSON format.

The API Signature Challenge

But wait, there was another layer of protection. To actually request video information from their API, I needed to generate proper authentication signatures. Every API request included a sign parameter that looked like this:

Using Frida again, I discovered this signature was generated by taking all the request parameters, sorting them alphabetically, and running them through HMAC-SHA256 with a secret key.

The pattern looked like this:

Lessons Learned

This reverse engineering journey taught me several important lessons:

Nothing is truly secure on the client side. No matter how much you obfuscate or encrypt, if the decryption happens on the user’s device, it can be reverse engineered with enough patience and the right tools.

Multiple layers of protection are common. Modern apps don’t rely on just one security mechanism. This app had encrypted URLs, API signatures, and obfuscated native code.

The right tools make all the difference. Without Frida’s dynamic analysis capabilities and Ghidra’s static analysis, this would have been nearly impossible.

Documentation is your friend. Understanding crypto algorithms, Android internals, and assembly language was crucial for success.

The Bigger Picture

Why does this matter beyond just satisfying technical curiosity? Understanding how content protection works helps developers build better security systems. It also highlights the ongoing cat-and-mouse game between content creators trying to protect their assets and researchers trying to understand how systems work.

For content creators, this demonstrates why server-side validation and DRM systems are so important. Client-side security can slow down attackers, but it can’t stop determined reverse engineers.

For developers, this shows the importance of defense in depth – using multiple security layers and not relying solely on obscurity.

Final Thoughts

Reverse engineering mobile apps is like solving a complex puzzle. Each piece you uncover leads to the next challenge, and the satisfaction of finally cracking the system is incredible.

The techniques I used here – dynamic analysis with Frida, static analysis with Ghidra, and pattern recognition through careful observation – apply to many different reverse engineering challenges.

Whether you’re a security researcher, developer, or just someone curious about how apps work under the hood, these tools and techniques can open up a whole new world of understanding about the software we use every day.

Remember though: always use these skills responsibly and in accordance with applicable laws and terms of service. The goal should be learning and improving security, not causing harm.

Have you tried reverse engineering mobile apps? What tools and techniques have worked best for you? Drop a comment below and share your experiences!


Tags:

fdciabdul

Nothing more important except trains youself become better

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button