If you’re a developer helping users secure their phones or hardening your own device against attacks, this technical guide provides deeper insights into detecting and removing malware, analyzing suspicious activity, and implementing stronger protections.
1. Detecting a Compromised Device
Signs of Hacking (Technical Indicators)
- Unusual network traffic (check via
netstat, Wireshark, or mobile firewall logs) - Unauthorized background processes (use
adb shell psortopon rooted devices) - Suspicious app permissions (check
adb shell dumpsys package) - Modified system files (compare checksums or use
Tripwire-like tools) - Unexpected battery/CPU usage (analyze via
Battery Historianoradb shell dumpsys batterystats)
Tools for Detection
- MobSF (Mobile Security Framework) – Static & dynamic analysis of APKs
- Frida – Dynamic instrumentation to detect malicious behavior
- Burp Suite / Charles Proxy – Monitor HTTP/HTTPS traffic for exfiltration
- Logcat (Android) / Console (iOS) – Check for unusual logs (
adb logcat)
2. Removing the Hacker (Technical Steps)
A. Immediate Containment
- Disconnect from the network – Enable Airplane Mode or:
Bash
adb shell svc wifi disable
adb shell svc data disable - Revoke suspicious permissions (Android):
Bash
adb shell pm revoke <package_name> android.permission.<PERMISSION> - Kill suspicious processes (requires root):
Bash
adb shell su -c "kill -9 " B. Forensic Analysis (Before Factory Reset)
- Extract APKs of suspicious apps:
Bash
adb shell pm path <package_name>
adb pull /path/to/base.apk - Check installed packages (look for unknown apps):
Bash
adb shell pm list packages - Inspect network connections:
Bash
adb shell netstat -tuln - Check for persistence mechanisms (cron jobs, init scripts, etc.)
C. Full Removal (Nuclear Option)
- Boot into Safe Mode (disables third-party apps temporarily)
- Factory Reset via Recovery Mode (not just from Settings—some malware survives)
- Re-flash Stock Firmware (for advanced threats like rootkits)
3. Securing the Device Post-Cleanup
A. Hardening Android/iOS
- Enable Verified Boot (Android) – Ensures system integrity
- Disable USB Debugging & ADB (unless needed)
- Use SELinux/AppArmor (enforce strict policies)
- Implement Certificate Pinning (prevent MITM attacks)
B. Advanced Monitoring
- Deploy a Mobile EDR (e.g., CrowdStrike Falcon, SentinelOne)
- Use a Firewall (AFWall+ for Android, Lockdown for iOS)
- Log DNS requests (block malicious domains via
dnsmasqor Pi-hole)
C. Developer-Specific Protections
- Obfuscate code (ProGuard, R8, or DexGuard)
- Implement Runtime Application Self-Protection (RASP)
- Use Hardware-backed Keystores (Android KeyStore, iOS Secure Enclave)
4. Preventing Future Attacks
- Regularly audit APKs (check with
apktool,jadx, orGhidra) - Monitor Google Play Protect / Apple App Store alerts
- Educate users on phishing & sideloading risks
Final Notes
- For iOS: Jailbreak detection bypass is common—consider using
ObjectionoriMazingfor forensic analysis. - For Android: Custom ROMs (e.g., GrapheneOS) provide stronger security than stock firmware.