Sub topic 13
Hands-on diagnostic commands
This chapter assumes you know basic Android and Windows usage, can open an elevated Command Prompt, and know common malware types and networking terms such as IP address and DNS. The A+ exam rarely asks you to type these commands. It does expect you to know what each one shows and when you would choose it. Each command below supports a step of the troubleshooting method: gather information, form a theory, then test it.
Android checks with adb
The Android Debug Bridge (adb) is a command-line tool that talks to an Android device over USB. It works only after you enable USB debugging in Developer options and approve the computer on the device. Leave USB debugging off when you are not using it. It is a developer feature and widens the attack surface.
List third-party apps
adb shell pm list packages -3The -3 option limits the list to third-party apps, which are the ones the user or someone else installed. Look for names you do not recognize. An unfamiliar package, or one that matches a symptom such as heavy data use or constant ads, may be a sideloaded or spoofed app.
Check battery health
adb shell dumpsys batteryThe output shows battery level, temperature and charging status. A high temperature while the phone is idle points to a runaway app or a failing battery. Compare the reading with the symptom the user reported.
Read the system log
adb logcat -dThe -d option dumps the current log and exits. Without it, logcat keeps running. Look for the same app name appearing again and again with crash or exception messages. That pattern supports a theory that the app is failing to launch or close, and the next step could be a clear cache, update or reinstall.
Windows checks
Inspect the hosts file
type %SystemRoot%\System32\drivers\etc\hostsThe hosts file maps names to IP addresses and is checked before DNS. Malware often adds entries that send a bank or update site to an attacker's address. A normal file contains mostly comments, which begin with #. Any other line that you cannot explain is suspect.
Match connections to processes
netstat -anoThe -a option shows all connections and listening ports. The -n option shows numeric addresses. The -o option adds the process ID (PID) that owns each connection. Find an unfamiliar remote address, note its PID, then open Task Manager, go to the Details tab, and find that PID. This tells you which program is talking to the remote host.
Verify system files
sfc /scannowSystem File Checker (SFC) compares protected Windows files with known good copies and replaces any that were changed. Run it from an elevated prompt. In the malware removal process it belongs after the infection is cleaned, because it repairs damage and does not remove the cause.
Choosing the right command
| Symptom | Command | What you look for |
|---|---|---|
| Unknown app on a phone | `adb shell pm list packages -3` | Unfamiliar package names |
| Phone hot or draining fast | `adb shell dumpsys battery` | High temperature, abnormal status |
| App keeps crashing | `adb logcat -d` | Repeated errors from one app |
| Site opens the wrong page | `type ...\hosts` | Unexpected redirect entries |
| Suspected remote control | `netstat -ano` | Unknown remote address and its PID |
| Windows behaves oddly after cleanup | `sfc /scannow` | Repaired or corrupt files |
Where the commands fit
Exercise
A user says a browser keeps opening a fake bank page, even when they type the correct address. Which command shows whether a local file is redirecting the name, and what would a malicious result look like?
Show answer
Run type %SystemRoot%\System32\drivers\etc\hosts. A malicious result is an uncommented line that maps the bank's domain name to an unfamiliar IP address.
Exercise
You run netstat -ano and see an unknown remote address with PID 4120. What is your next step?
Show answer
Open Task Manager, go to the Details tab, and find PID 4120 to identify the owning process. Then research the process before ending or removing it.