提醒:点上方↑“黑客技术”即可免费订阅我。 0x01 简介Powershell Remoting建立在windows WinRM服务之上,可以一对一或一对多远程控制,也可以建立HTTP 或 HTTPS的“listeners”,使用WS-MAM协议接收远程传递的命令。 Windows 远程管理(WinRM)是 WS-Management 协议的 Microsoft 实现,该协议为使用 Web 服务的本地计算机和远程计算机之间的通信提供了一种安全的方式。 也就是说在WS-MAN协议基础上,客户端运行环境可以多样化。 比如openwsman。 图片来源:v3 Secrets of PowerShell Remoting 0x02 远程管理Powershell Remoting在windows server 2008以前默认是不开启的,需要通过administrator用户执行Enable-PSRemoting命令开启。 在windows server 2012中,Powershell Remoting默认开启。 在windows下,powershell默认使用winrm进行远程管理,winrm版本不同默认的监听端口也不同。如下:
可以在参考这里判断winrm版本。 通过 如果要跨域、或指定IP地址执行时我们可以在客户端这里执行下面的代码,需要将所有或单一远程主机添加在信任表中。 Set-Item WSMan:localhostClientTrustedHosts -Value * -Force 删除所有远程信任主机 Clear-Item WSMan:localhostClientTrustedHosts 如果要删除单一远程主机,则可以执行: $newvalue = ((Get-ChildItem WSMan:localhostClientTrustedHosts).Value).Replace('computer01,','')Set-Item WSMan:localhostClientTrustedHosts $newvalue 更改computer01。 列出所有远程信任主机 Get-Item WSMan:localhostClientTrustedHosts 在使用远程执行时如果只提供用户名,那么则会弹窗输入密码。此时我们可以建立PSCredential对象将用户名和密码保存在里面。然后再传递给 $UserName = 'admin3'$serverpass = 'admin123!@'$Password = ConvertTo-SecureString $serverpass -AsPlainText –Force$cred = New-Object System.Management.Automation.PSCredential($UserName,$Password)invoke-command -ComputerName localhost -Credential $cred -ScriptBlock { ipconfig } 使用 之后写个for循环就可以一对多的执行了。 如果输出内容过于冗杂,还可以使用 如果想一对一获取交互式powershell,可以像这样执行 Enter-PSSession -ComputerName 192.168.200.161 -Credential $cred 0x03 多任务分发在使用 Get-Job -Id 1 | select -ExpandProperty childjobs 得到 0x04 域内信息搜集基本的信息搜集(日志、进程、服务等)可以靠上面列出的命令来收集,但是远程执行 在windows中有个 那么在powershell就可以这样执行: ([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()).GetAllTrustRelationships() 获得域之前的信任关系。 如果需要自行开发脚本,也可以参考下面的文档。 除此之外,还记得之前metasploit笔记中那个 两种不同的脚本都通过调用OpenSCManagerA API连接远程主机测试是否成功。 Local_admin_search.rb Invoke-CheckLocalAdminAccess 附veil-powerview作者博客中的测试截图: 0x05 参考
0x06 powershell pentest project 学习推荐整理的过程发现了很多牛人的博客和项目,在这里分享一下。 Powershell HID attack toolkit :https://github.com/samratashok/Kautilya post exploitation :https://github.com/samratashok/nishang Remote DLL inject :https://github.com/clymb3r aspx的Powershell webshell :https://github.com/samratashok/nishang/tree/master/Antak- WebShell Veil Post exploitation :https://github.com/Veil-Framework/Veil-PowerView A PowerShell Post-Exploitation Framework :https://github.com/mattifestation/PowerSploit local privilege escalation : https://github.com/HarmJ0y/PowerUp —————————— 关注微信号:hackdig 学习最新黑客技术! |
|