This guide provides a detailed setup process for students to monitor various activities within WhatsApp, including audio, video, contacts, cookies, and other data interactions. The setup involves using dynamic instrumentation tools like Frida, filesystem monitoring tools like inotifywait
, and network traffic monitoring tools like mitmproxy and Wireshark.
- A Linux host machine
- Android Studio or Genymotion for Android emulation
- Rooted Android emulator for advanced monitoring (optional)
- Basic knowledge of Android development and Linux command-line tools
- Frida: For dynamic instrumentation
- inotifywait: For filesystem monitoring
- mitmproxy: For intercepting and analyzing HTTPS traffic
- Wireshark: For capturing and analyzing network traffic
- adb: Android Debug Bridge for emulator configuration
-
Install Android Studio:
- Download and install Android Studio from the official website.
- Create a new Android Virtual Device (AVD) with the desired specifications.
-
Root the Emulator (Optional for Advanced Monitoring):
- Rooting the emulator can provide more control and access to system files.
- Follow a guide such as How to Root Android Emulator for detailed steps.
-
Install Frida on the Linux Host:
pip install frida-tools
-
Download the Frida Server:
- Download the appropriate Frida server binary from the Frida releases page.
-
Push the Frida Server to the Emulator:
adb push frida-server /data/local/tmp/ adb shell "chmod 755 /data/local/tmp/frida-server" adb shell "/data/local/tmp/frida-server &"
-
Write Frida Scripts to Monitor Audio, Video, and Contacts:
Java.perform(function() { // Hooking into audio methods var MediaRecorder = Java.use('android.media.MediaRecorder'); MediaRecorder.start.implementation = function() { console.log('MediaRecorder started'); this.start(); }; // Hooking into video methods var Camera = Java.use('android.hardware.Camera'); Camera.startPreview.implementation = function() { console.log('Camera preview started'); this.startPreview(); }; // Hooking into contacts access var ContentResolver = Java.use('android.content.ContentResolver'); ContentResolver.query.overload('android.net.Uri', '[Ljava.lang.String;', 'android.os.Bundle', 'android.os.CancellationSignal').implementation = function(uri, projection, queryArgs, cancellationSignal) { console.log('Contacts accessed:', uri); return this.query(uri, projection, queryArgs, cancellationSignal); }; });
-
Run the Frida Script:
frida -U -f com.whatsapp -l your_script.js --no-pause
-
Install
inotify-tools
on Linux:sudo apt-get install inotify-tools
-
Monitor WhatsApp's Data Directory:
inotifywait -m -r -e access,modify,create,delete /data/data/com.whatsapp/
-
Script for Real-Time Logging:
#!/bin/bash # Directory to monitor DIR="/data/data/com.whatsapp/" # Log file to store inotify events LOGFILE="/var/log/whatsapp_data_monitor.log" # Run inotifywait and log events inotifywait -m -r -e access,modify,create,delete $DIR --format '%w%f %e' | while read FILE EVENT; do echo "$(date) - $EVENT - $FILE" >> "$LOGFILE" done
-
Install mitmproxy on Linux:
sudo apt-get install mitmproxy
-
Start mitmproxy:
mitmproxy -p 8080
-
Configure the Emulator to Use mitmproxy:
adb shell settings put global http_proxy <host_ip>:8080
-
Install the mitmproxy Certificate on the Emulator:
- Transfer the certificate:
adb push ~/.mitmproxy/mitmproxy-ca-cert.pem /sdcard/Download/
- Install the certificate from the emulator's settings.
- Transfer the certificate:
-
Install Wireshark on Linux:
sudo apt-get install wireshark
-
Start Wireshark and Select the Network Interface:
- Capture traffic on the network interface used by the emulator (e.g.,
vboxnet0
for VirtualBox).
- Capture traffic on the network interface used by the emulator (e.g.,
-
Set Up Capture Filters:
tcp.port == 8080
-
Write Frida Scripts for Monitoring Cookies and Data Transfers:
Java.perform(function() { // Hooking into cookie methods var CookieManager = Java.use('android.webkit.CookieManager'); CookieManager.getInstance().setCookie.overload('java.lang.String', 'java.lang.String').implementation = function(url, value) { console.log('Cookie set - URL:', url, 'Value:', value); return this.setCookie(url, value); }; // Hooking into database access methods var SQLiteDatabase = Java.use('android.database.sqlite.SQLiteDatabase'); SQLiteDatabase.execSQL.overload('java.lang.String').implementation = function(sql) { console.log('SQL executed:', sql); return this.execSQL(sql); }; });
-
Run the Frida Script:
frida -U -f com.whatsapp -l your_script.js --no-pause
-
TrackerControl:
- Installation: Download TrackerControl from the GitHub page.
- Functionality: Monitor which tracking domains are contacted by WhatsApp and other apps.
-
Real-Time Alerts:
- Webhook Integration: Configure inotifywait or Frida scripts to trigger webhooks that notify a monitoring service when specific events are logged.
- Monitoring Dashboard: Use tools like Grafana to visualize and set alerts for monitored events.
- Frida Documentation
- inotify-tools Documentation
- TrackerControl on GitHub
- Mitmproxy Documentation
- Wireshark Documentation
By following this comprehensive guide, students can set up an environment to monitor various activities within WhatsApp, including audio, video, contacts, cookies, and other data interactions. This setup provides hands-on experience with advanced cybersecurity tools and techniques, enhancing their understanding of mobile app data flows and privacy concerns.