Translate Article / Choose Language:
sandeep tech

Sandeep Bhondwe Android 9 - 15 Termux (tsu) Magisk & KernelSU 4-Min Guide 100% Tested (2026)
Welcome to Sandeep Tech! Have you ever found yourself in a situation where your smartphone is connected to a high-speed WiFi network, but you cannot recall the exact password to connect your laptop, tablet, or a friend's device? If your phone is Rooted (via Magisk, KernelSU, APatch, or SuperSU), you do not need a computer, USB debugging, or cumbersome desktop utilities. By using Termux, Android's premier Linux terminal emulator, you can read the internal system configuration files and extract every saved WiFi name (SSID) and security key (PreSharedKey) in less than 10 seconds.
⚠️
Ethical & Legal Disclaimer: This guide is published strictly for Educational & Personal Recovery Purposes. The techniques detailed below are intended to assist users in retrieving credentials for networks they own or have legitimate authorization to use. Extracting or tampering with third-party credentials without explicit consent violates cybersecurity laws and IT compliance policies worldwide. Sandeep Tech strongly advocates for ethical computing and privacy protection.

🔥 1. Prerequisites & System Requirements

To successfully execute these terminal commands and inspect internal system configuration directories, verify that your setup fulfills the following technical prerequisites:

Root Access Granted

Your smartphone must be rooted with a modern superuser solution such as Magisk (v24+), KernelSU, or APatch. The superuser management app must be functioning properly to grant root permissions to Termux.

Official Termux Build

Ensure you have installed Termux from F-Droid or the official GitHub repository. Do not use the abandoned Google Play Store build, as its repositories are permanently deprecated.

Saved Network History

The network you are attempting to retrieve credentials for must have been connected to your device at least once previously. Android only stores credentials for authenticated profiles.

Initial Internet Connection

You need an active data or WiFi connection during the initial setup to download the tsu package and repository index files via Termux package manager (pkg).

🎥 2. Video Tutorial Walkthrough (YouTube Demo)

If you prefer a fast visual demonstration showing the exact terminal prompts, superuser popups, and instant command outputs, watch this short tutorial from Sandeep Tech:

[mobile-video]https://www.youtube.com/shorts/OrfPVEaUthE[/mobile-video]

🧠 3. How Android Stores WiFi Passwords: Security & Architecture

To understand why root privileges are mandatory for terminal extraction, we must inspect the inner security architecture of the Android OS. Android is built upon a hardened Linux kernel and implements an uncompromising Application Sandboxing Model combined with Security-Enhanced Linux (SELinux) mandatory access controls.

Here is what happens behind the scenes from a technical perspective:

  • Dedicated System UID Ownership: WiFi credentials and supplicant configurations are stored in the system partition path /data/misc/wifi/. This directory is strictly owned by system:wifi (User ID 1000). Regular third-party Android apps operate under isolated isolated UIDs (e.g., u0_a123) and are completely blocked by Linux filesystem permissions (drwxrwx---).
  • SELinux Enforcing Domain Restrictions: Even if file permissions were somehow bypassed, SELinux policies (specifically wpa_socket and wifi_data_file contexts) restrict reads to the core system WiFi daemon (wificond).
  • The Evolution from Text to XML:
    • Android 4.4 to Android 9.0: Credentials were saved in plain text within the standard Linux wpa_supplicant.conf configuration file.
    • Android 10 & 11: Google transitioned WiFi management to a centralized XML structure named WifiConfigStore.xml.
    • Android 12, 13, 14, and 15: Google restructured the wireless stack into an APEX Mainline Module (com.android.wifi). This decoupled WiFi drivers and security updates from OEM manufacturer updates, moving the credentials to /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml.

⚡ 4. Step-by-Step Guide: Termux Commands

Follow these numbered instructions in sequential order to set up your environment and read the saved credentials:

Step 1
Install the Maintained Termux Build (F-Droid)

The Google Play Store edition of Termux was discontinued in 2020 due to Android SDK target requirements and will throw broken repository errors. Download the latest official APK from F-Droid:

👉 Official F-Droid Link: Download Termux from F-Droid

Step 2
Grant Storage Access to Termux

Open the Termux terminal, type the storage setup command, hit Enter, and tap Allow on the Android permission popup:

bash - termux@android
termux-setup-storage

This command maps your device's internal storage to ~/storage/shared, allowing you to easily export files or save logs directly to your phone's Downloads directory.

Step 3
Update Repositories & Install the tsu Package

In Termux, running standard su switches to the bare Android toolbox shell, which drops Termux's PATH and installed command utilities. To maintain full terminal capabilities inside root mode, install tsu (the Termux su wrapper):

bash - package manager
pkg update && pkg upgrade -y && pkg install tsu -y
Pro Tip: If the package manager hangs or returns connection timeouts, type termux-change-repo, choose Main repository, and select an alternative mirror like Albatross or Grimler.
Step 4
Acquire Elevated Superuser (Root) Shell

Now, invoke the root wrapper by typing:

bash - switch superuser
tsu

Immediately, your root management application (Magisk, KernelSU, or APatch) will present a Superuser Request dialog. Tap Grant or Remember & Grant. Notice how your command line prompt changes from the standard user symbol ($) to the root hash symbol (#).

Step 5
Extract WiFi Passwords on Legacy Android (Android 9 & Earlier)

If your device runs Android 9.0 Pie, Android 8 Oreo, Android 7 Nougat, or older versions, all credentials reside inside wpa_supplicant.conf:

root@android - legacy supplicant
cat /data/misc/wifi/wpa_supplicant.conf | grep -E "ssid|psk"

The terminal will instantly parse and print every saved network SSID alongside its corresponding plain-text PSK passphrase:

ssid="Office_HighSpeed_5G"
psk="CyberSecurity@2026#"
ssid="Home_Fiber_Broadband"
psk="MySuperStrongKey99!"

🚀 5. Modern Android Commands (Android 10, 11, 12, 13, 14 & 15)

On modern Android operating systems, executing the legacy command will yield cat: /data/misc/wifi/wpa_supplicant.conf: No such file or directory. Use the dedicated commands below tailored to your operating system:

Method A: For Android 10 (Q) & Android 11 (R)

In Android 10 and 11, the credentials are encapsulated inside the primary WiFi XML storage file:

root@android - Android 10/11
cat /data/misc/wifi/WifiConfigStore.xml | grep -E "SSID|PreSharedKey"

Method B: For Android 12 (S), Android 13 (T), Android 14 (U), & Android 15 (V)

On Android 12 through Android 15, WiFi connectivity is managed as a Project Mainline APEX package. The configuration file is situated in the apexdata tree:

root@android - Android 12 to 15 (APEX)
cat /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml | grep -E "SSID|PreSharedKey"

Method C: Clean One-Liner (Filter XML Tags for Clean Output)

Notice how raw XML outputs include cumbersome tags like <string name="SSID">&quot;MyNetwork&quot;</string>? Here is an advanced sed and awk one-liner crafted by Sandeep Tech that formats the output into clean, human-readable lines:

root@android - clean formatted output
su -c "cat /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml 2>/dev/null || cat /data/misc/wifi/WifiConfigStore.xml 2>/dev/null" | grep -E 'name="SSID"|name="PreSharedKey"' | sed -e 's/<[^>]*>//g' -e 's/&quot;//g' | awk '{print $0}'

Sample clean terminal output:

SSID: "Airtel_Extreme_Fiber"
PreSharedKey: "Airtel@5Ghz#2026"
SSID: "Starbucks_Guest_Network"
PreSharedKey: "FreeCoffeeWiFi!"

🤖 6. Sandeep Tech Automated 1-Click WiFi Extractor Script

Don't want to manually memorize different file paths for different Android versions? You can copy and run this universal bash script in Termux. It automatically detects your Android OS release version, locates the correct file path, strips raw XML formatting, and exports all networks into an organized table:

bash - Sandeep Tech Universal Extractor
tsu -c '
echo -e "\033[1;32m[+] Sandeep Tech - WiFi Password Extractor v2.0\033[0m"
OS_VER=$(getprop ro.build.version.release)
echo -e "\033[1;36m[*] Detected Android OS Version: $OS_VER\033[0m"

TARGET_FILE=""
if [ -f "/data/misc/apexdata/com.android.wifi/WifiConfigStore.xml" ]; then
    TARGET_FILE="/data/misc/apexdata/com.android.wifi/WifiConfigStore.xml"
elif [ -f "/data/misc/wifi/WifiConfigStore.xml" ]; then
    TARGET_FILE="/data/misc/wifi/WifiConfigStore.xml"
elif [ -f "/data/misc/wifi/wpa_supplicant.conf" ]; then
    TARGET_FILE="/data/misc/wifi/wpa_supplicant.conf"
fi

if [ -z "$TARGET_FILE" ]; then
    echo -e "\033[1;31m[-] Error: Could not locate WiFi configuration file.\033[0m"
    exit 1
fi

echo -e "\033[1;34m[*] Reading credentials from: $TARGET_FILE\033[0m\n"
grep -E "SSID|PreSharedKey|ssid|psk" "$TARGET_FILE" | sed -e "s/<[^>]*>//g" -e "s/&quot;//g" -e "s/^[ \t]*//"
echo -e "\n\033[1;32m[✓] Extraction Completed Successfully!\033[0m"
'

📊 7. Quick Command Reference & Path Cheat Sheet

Here is an at-a-glance architectural reference mapping each Android version to its storage format and terminal commands:

Android Version Configuration File Path File Format Termux Extraction Command
Android 4.4 – 9.0 /data/misc/wifi/wpa_supplicant.conf Plaintext Conf cat ... | grep -E "ssid|psk"
Android 10 – 11 /data/misc/wifi/WifiConfigStore.xml Structured XML cat ... | grep -E "SSID|PreSharedKey"
Android 12 – 13 /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml APEX XML cat ... | grep -E "SSID|PreSharedKey"
Android 14 – 15 /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml APEX Mainline cat ... | grep -E "SSID|PreSharedKey"
Export to File ~/storage/shared/Download/wifi.txt Plaintext Log ... > /sdcard/Download/wifi_passwords.txt

🛠️ 8. Troubleshooting 6 Common Termux & Root Errors

Encountering an error during extraction? Below are the root causes and instant solutions for the 6 most common obstacles experienced by Android users:

Error 1: tsu: command not found
Root Cause: The tsu package has not yet been installed, or the Termux package index is out of sync.
Solution: Run pkg update && pkg install tsu -y. If the update fails with 404 errors, run termux-change-repo and pick an alternative mirror server.
Error 2: cat: ... Permission denied (Even after tsu)
Root Cause: SELinux Enforcing Mode is blocking access to system contexts on custom ROMs or Samsung Knox devices.
Solution: In your root shell (#), temporarily set SELinux to Permissive mode:
setenforce 0
Run your WiFi extraction command, and then immediately re-enable SELinux protection:
setenforce 1
Error 3: No such file or directory
Root Cause: You ran the legacy Android 9 command on Android 11/12/13/14/15, or vice-versa.
Solution: Run this universal finder command to discover the exact path where your device stores credentials:
find /data/misc -name "*WifiConfigStore*" -o -name "*wpa_supplicant*" 2>/dev/null
Error 4: PreSharedKey displays <null> or is completely missing
Root Cause: The targeted network is either an Open Hotspot (unsecured without a password) or uses WPA-Enterprise (802.1X) with user-based digital certificates instead of a shared static passphrase.
Solution: Scroll to other network blocks in the XML file; password-protected home and commercial networks will always contain a populated PreSharedKey field.
Error 5: Termux freezes or hangs when executing tsu
Root Cause: Magisk or KernelSU failed to display the superuser prompt due to battery optimization or background overlay restrictions.
Solution: Open the Magisk App, navigate to the Superuser tab, locate Termux in the app list, and manually toggle the authorization switch to ON.
Error 6: Play Store Termux throws 'Repository is under maintenance'
Root Cause: You are using the deprecated Google Play Store build of Termux.
Solution: Completely uninstall the Play Store version, navigate to F-Droid, and install the latest official release.

📱 9. How Non-Rooted Users Can View Passwords (QR Code Method)

What if your smartphone is not rooted and you do not want to unlock your bootloader? Starting with Android 10, Google introduced a built-in feature to share connected WiFi networks via a QR code. This provides a legitimate, non-root mechanism to reveal your password:

  1. Open your smartphone's Settings app.
  2. Navigate to Network & Internet (or Connections > Wi-Fi on Samsung One UI).
  3. Tap the Gear Icon (Settings) next to your currently connected WiFi network.
  4. Tap the Share button (usually represented by a QR code icon). Authenticate using your fingerprint or lock screen PIN.
  5. A QR code will be generated on your display. On many devices (such as Google Pixel, Xiaomi MIUI/HyperOS, and OnePlus OxygenOS), the plain text password is printed directly underneath the QR code!
  6. If your phone hides the text beneath the QR code, take a screenshot of the QR code, open Google Lens or any online QR reader (like zxing.org), and scan the screenshot. The raw result will look like:
    WIFI:S:MyHomeWiFi;T:WPA;P:MySecretPassphrase123;;
    The string after P: is your WiFi password!

🔐 10. 7 Essential Rules to Secure Your Home WiFi Network

Now that you have seen how stored WiFi passwords can be read from device memory, it is equally important to audit and harden your own router against malicious third parties. Implement these 7 security standards:

  • 🔒 Migrate to WPA3-Personal (SAE): WPA3 replaces the vulnerable 4-way WPA2 handshake with Simultaneous Authentication of Equals (SAE). This completely prevents offline dictionary and brute-force attacks even if traffic is captured.
  • 🔑 Enforce Long, Complex Passphrases: Use passphrases with a minimum of 16 characters containing a mixture of uppercase letters, lowercase letters, numbers, and special symbols.
  • 🚫 Disable WPS (Wi-Fi Protected Setup) Immediately: WPS PIN authentication uses an 8-digit numeric pin with severe architectural flaws (Pixie Dust attack), allowing attackers to compromise your router within minutes regardless of your password strength.
  • 🛡️ Disable Remote Management (WAN Access): Never allow administrative router login from the public internet; keep administrative access bound exclusively to internal LAN connections.
  • 📲 Segregate IoT & Smart Devices on a Guest Network: Smart home devices (security cameras, smart TVs, smart plugs) rarely receive timely firmware patches. Isolate them on a separate 2.4GHz Guest VLAN to protect your primary computers and phones.
  • 🔄 Automate or Audit Router Firmware Updates: Keep your router's firmware updated to shield against critical remote code execution (RCE) vulnerabilities.
  • 🔍 Change Default Admin Credentials: Never leave default factory credentials like admin/admin on your router management portal (192.168.1.1).
Sandeep Tech Recommended Privacy Tool: TempMail Pro

Safeguard your real identity and stop inbox spam when downloading cybersecurity utilities, registering on tech forums, or testing GitHub scripts. Create instant, encrypted disposable inboxes in 10 seconds without phone verification using TempMail Pro.

🚀 Generate Free Disposable Email at tempreply.com

❓ 11. Frequently Asked Questions (FAQ)

Q1: Can I view saved WiFi passwords in Termux without Root?
Answer: No. Android's strict Linux sandbox model stores WiFi credentials inside the protected /data/misc directory (owned by UID 1000 system). Without Superuser (Root) privileges, neither Termux nor any third-party app can read this directory. Non-rooted users must use the native QR code sharing feature available in Android 10 and newer.
Q2: Why is wpa_supplicant.conf missing on Android 11, 12, 13, 14, and 15?
Answer: Starting with Android 10, Google replaced wpa_supplicant.conf with WifiConfigStore.xml. Starting in Android 12, Google transformed WiFi into a modular APEX mainline package located at /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml.
Q3: Why does Termux from Google Play Store fail with 403 Forbidden or repository errors?
Answer: The Play Store version of Termux was officially deprecated in 2020 due to Google Play Target SDK restrictions. Always download the actively maintained version from F-Droid or GitHub.
Q4: Why does the PreSharedKey field show null or nothing for some WiFi networks?
Answer: An empty or null PreSharedKey indicates an Open network (unsecured public hotspot without a password) or an Enterprise 802.1X network that uses certificates / username-password combos instead of a pre-shared key.
Q5: How do I fix 'Permission denied' when running cat on WifiConfigStore.xml even with tsu?
Answer: This is caused by SELinux enforcing mode. Run su or tsu, then type setenforce 0 to temporarily switch SELinux to permissive mode, view your passwords, and revert back with setenforce 1.
Q6: Does this method hack or crack unknown WiFi networks?
Answer: No. This is strictly a local credential recovery technique for previously connected networks stored in your own device's internal memory. It cannot crack or access unauthorized networks.
Q7: What is the difference between Magisk su and Termux tsu?
Answer: Standard su switches to root user with a minimal Android shell environment, which lacks Termux PATH and utilities. tsu is a wrapper specifically designed for Termux that preserves the full Termux environment, PATH, and installed packages.
Q8: Can I export all saved WiFi passwords to a file in my phone's Downloads folder?
Answer: Yes! You can redirect the command output to your internal storage using: cat /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml | grep -E "SSID|PreSharedKey" > /sdcard/Download/wifi_passwords.txt.
Q9: Will viewing saved WiFi passwords void my warranty or trigger SafetyNet / Play Integrity?
Answer: Merely reading the configuration file does not affect SafetyNet or Play Integrity. However, having a rooted device itself can affect Play Integrity unless configured with appropriate Magisk modules (like Play Integrity Fix).
Q10: Why does Termux say 'tsu: command not found'?
Answer: You haven't installed the tsu package yet. Run pkg update && pkg install tsu -y. If it fails, run termux-change-repo to select an active mirror server.
Sandeep Bhondwe - Sandeep Tech

Author: Sandeep Bhondwe (Sandeep Tech)

Cybersecurity Researcher, Ethical Hacker & Linux Enthusiast. Specializing in Android internals, network penetration testing, and mobile privacy. Join our official community on Telegram: @sandeep_hacker

Post a Comment

Previous Post Next Post
Live