Course contentsShow
← Security
Lesson 2731 of 3,05251. Mobile SecurityFree lesson

Repackaging and Code Injection Attacks

Modifying, recompiling, and re-signing mobile apps to inject malicious code or alter functionality.

Repackaging and Code Injection Attacks

What You'll Learn

You'll discover how attackers modify legitimate mobile apps to inject malicious functionality, then redistribute them to unsuspecting users.

The Attack Process

Repackaging is the practice of taking an existing mobile app, decompiling it, modifying its code, then recompiling and re-signing it with a new certificate. It's like taking someone else's recipe, adding your own "secret ingredient" (malicious code), and serving it under the same name.

The typical workflow:

  1. Extract: Download a popular app's APK (Android) or IPA (iOS)
  2. Decompile: Use tools to convert the binary back into readable code
  3. Inject: Insert malicious payloads—keyloggers, ad fraud code, data exfiltration routines, or backdoors
  4. Recompile: Rebuild the app with your modifications
  5. Re-sign: Generate a new signature (since you don't have the original developer's private key)
  6. Distribute: Upload to third-party app stores, phishing sites, or directly via social engineering

Why It Works

Users often download apps from unofficial sources to get "premium" features for free. They may not notice that the app's signature has changed, especially on Android where sideloading is straightforward. The app functions normally—the legitimate code still runs—but now it also executes the attacker's payload in the background.

Common injection targets include adding code to steal credentials, bypass in-app purchases, inject advertisements, or create backdoors for remote access.

Defense Complexity

This attack leverages your earlier learning about anti-tampering mechanisms and code signing. Defenders must implement integrity checks, certificate pinning validation, and runtime verification to detect unauthorized modifications.

Key Takeaway: Repackaging attacks transform legitimate apps into trojan horses by modifying and re-signing them, making code integrity verification and trusted distribution channels critical defensive controls.