Giter VIP home page Giter VIP logo

venom's Introduction

Venom - A Multi-hop Proxy for Penetration Testers

简体中文 | English

Venom是一款为渗透测试人员设计的使用Go开发的多级代理工具。

Venom可将多个节点进行连接,然后以节点为跳板,构建多级代理。

渗透测试人员可以使用Venom轻松地将网络流量代理到多层内网,并轻松地管理代理节点。

此工具仅限于安全研究和教学,用户承担因使用此工具而导致的所有法律和相关责任! 作者不承担任何法律和相关责任!

特性

  • 可视化网络拓扑
  • 多级socks5代理
  • 多级端口转发
  • 端口复用 (apache/mysql/...)
  • ssh隧道
  • 交互式shell
  • 文件的上传和下载
  • 节点间通信加密
  • 支持多种平台(Linux/Windows/MacOS)和多种架构(x86/x64/arm/mips)

由于IoT设备(arm/mips/...架构)通常资源有限,为了减小二进制文件的大小,该项目针对IoT环境编译的二进制文件不支持端口复用和ssh隧道这两个功能,并且为了减小内存使用限制了网络并发数和缓冲区大小。

安装

您可以直接下载使用release中编译好的可执行文件

如果您想从源码编译该项目, 需要安装 go >= 1.11, 然后执行下面的命令

go get -u github.com/Dliv3/Venom/...

# $GOPATH是安装Go时配置的环境变量,可通过go env命令查看
cd $GOPATH/src/github.com/Dliv3/Venom

# 编译好的二进制文件存放在当前目录下的release文件夹中
./build.sh

使用

Youtube演示视频: https://www.youtube.com/playlist?list=PLtZO9vwOND91vZ7yCmlAvISmEl2iQKjdI

1. admin/agent命令行参数

  • admin节点和agent节点均可监听连接也可发起连接

    admin监听端口,agent发起连接:

    ./admin_macos_x64 -lport 9999
    
    ./agent_linux_x64 -rhost 192.168.0.103 -rport 9999
    

    agent监听端口,admin发起连接:

    ./agent_linux_x64 -lport 8888
    
    ./admin_macos_x64 -rhost 192.168.204.139 -rport 8888
    
  • agent节点支持端口复用

    agent提供了两种端口复用方法

    1. 通过SO_REUSEPORT和SO_REUSEADDR选项进行端口复用
    2. 通过iptables进行端口复用(仅支持Linux平台)

    通过venom提供的端口复用功能,在windows上可以复用apache、mysql等服务的端口,暂时无法复用RDP、IIS等服务端口,在linux上可以复用多数服务端口。被复用的端口仍可正常对外提供其原有服务。

    第一种端口复用方法

    # 以windows下apache为例
    # 复用apache 80端口,不影响apache提供正常的http服务
    # -lhost 的值为本机ip,不能写0.0.0.0,否则无法进行端口复用
    ./agent.exe -lhost 192.168.204.139 -reuse-port 80
    
    ./admin_macos_x64 -rhost 192.168.204.139 -rport 80
    

    第二种端口复用方法

    # 以linux下apache为例
    # 需要root权限
    sudo ./agent_linux_x64 -lport 8080 -reuse-port 80
    

    这种端口复用方法会在本机设置iptables规则,将reuse-port的流量转发到lport,再由agent分发流量

    需要注意一点,如果通过sigtermsigint信号结束程序(kill或ctrl-c),程序可以自动清理iptables规则。如果agent被kill -9杀掉则无法自动清理iptables规则,需要手动清理,因为agent程序无法处理sigkill信号。

    为了避免iptables规则不能自动被清理导致渗透测试者无法访问80端口服务,所以第二种端口复用方法采用了iptables -m recent通过特殊的tcp包控制iptables转发规则是否开启。

    这里的实现参考了 https://threathunter.org/topic/594545184ea5b2f5516e2033

    # 启动agent在linux主机上设置的iptables规则
    # 如果rhost在内网,可以使用socks5代理脚本流量,socks5代理的使用见下文
    python scripts/port_reuse.py --start --rhost 192.168.204.135 --rport 80
    
    # 连接agent节点
    ./admin_macos_x64 -rhost 192.168.204.135 -rport 80
    
    # 如果要关闭转发规则
    python scripts/port_reuse.py --stop --rhost 192.168.204.135 --rport 80
    
  • 节点间通信加密

    Venom提供节点间通信加密功能,用户可通过-passwd选项指定密码,该密码用于生成AES加密所需的密钥。

    # 通过-passwd指定密码为dlive@dubhe
    ./admin_macos_x64 -lport 8889 -passwd dlive@dubhe
    
    # agent指定相同的密码与admin节点连接
    ./agent_macos_x64 -rhost 192.168.0.103 -rport 8889 -passwd dlive@dubhe
    

2. admin节点内置命令

  • help 打印帮助信息

    (admin node) >>> help
    
      help                                     Help information.
      exit                                     Exit.
      show                                     Display network topology.
      getdes                                   View description of the target node.
      setdes     [info]                        Add a description to the target node.
      goto       [id]                          Select id as the target node.
      listen     [lport]                       Listen on a port on the target node.
      connect    [rhost] [rport]               Connect to a new node through the target node.
      sshconnect [user@ip:port] [dport]        Connect to a new node through ssh tunnel.
      shell                                    Start an interactive shell on the target node.
      upload     [local_file]  [remote_file]   Upload files to the target node.
      download   [remote_file]  [local_file]   Download files from the target node.
      socks      [lport]                       Start a socks5 server.
      lforward   [lhost] [sport] [dport]       Forward a local sport to a remote dport.
      rforward   [rhost] [sport] [dport]       Forward a remote sport to a local dport.
      
    
  • show 显示网络拓扑

    A表示admin节点,数字表示agent节点

    下面的拓扑图表示,admin节点下连接了1节点,1节点下连接了2、4节点,2节点下连接了3节点

    (node 1) >>> show
    A
    + -- 1
         + -- 2
              + -- 3
         + -- 4
    

    注意要对新加入的节点进行操作,需要首先在admin节点运行show命令同步网络拓扑和节点编号

  • goto 操作某节点

    (admin node) >>> goto 1
    (node 1) >>> 
    

    在goto到某节点之后你就可以使用下面将要介绍的命令

  • getdes/setdes 获取/设置节点信息描述

    (node 1) >>> setdes linux x64 blahblahblah
    (node 1) >>> getdes
    linux x64 blahblahblah
    
  • connect/listen/sshconnect 节点间互连

    node 1节点连接192.168.0.103的9999端口

    (node 1) >>> connect 192.168.0.103 9999
    connect to 192.168.0.103 9999
    successfully connect to the remote port!
    (node 1) >>> show
    A
    + -- 1
         + -- 2
    

    在node1节点监听9997端口, 然后在另一台机器上运行./agent_linux_x64 -rhost 192.168.204.139 -rport 9997 连接node1

    (node 1) >>> listen 9997
    listen 9997
    the port 9997 is successfully listening on the remote node!
    (node 1) >>> show
    A
    + -- 1
         + -- 2
         + -- 3
    

    在192.168.0.104上执行./agent_linux_x64 -lport 9999, node3通过sshconnect建立ssh隧道连接192.168.0.104的9999端口。你可以使用密码或者是ssh私钥进行认证。

    (node 1) >>> goto 3
    (node 3) >>> sshconnect [email protected]:22 9999
    use password (1) / ssh key (2)? 2
    file path of ssh key: /Users/dlive/.ssh/id_rsa
    connect to target host's 9999 through ssh tunnel ([email protected]:22).
    ssh successfully connects to the remote node!
    (node 3) >>> show
    A
    + -- 1
         + -- 2
         + -- 3
              + -- 4
    
  • shell 获取节点的交互式shell

    (node 1) >>> shell
    You can execute commands in this shell :D, 'exit' to exit.
    bash: no job control in this shell
    bash-3.2$ whoami
    whoami
    dlive
    bash-3.2$ exit
    exit
    exit
    
  • upload/download 向节点上传/从节点下载文件

    将本地/tmp/test.pdf上传到node1的/tmp/test2.pdf

    (node 1) >>> upload /tmp/test.pdf /tmp/test2.pdf
    upload /tmp/test.pdf to node 1: /tmp/test2.pdf
    this file is too large(>100M), do you still want to upload it? (y/n)y
     154.23 MiB / 154.23 MiB [========================================] 100.00% 1s
    upload file successfully!
    

    将node1的文件/tmp/test2.pdf下载到本地的/tmp/test3.pdf

    (node 1) >>> download /tmp/test2.pdf /tmp/test3.pdf
    download /tmp/test2.pdf from node 1: /tmp/test3.pdf
    this file is too large(>100M), do you still want to download it? (y/n)y
     154.23 MiB / 154.23 MiB [========================================] 100.00% 1s
    download file successfully!
    
  • socks 建立到某节点的socks5代理

    (node 1) >>> socks 7777
    a socks5 proxy of the target node has started up on local port 7777
    

    执行成功socks命令之后,会在admin节点本地开启一个端口,如上述的7777,使用7777即可进行socks5代理

  • lforward/rforward 将本地端口转发到远程/将远程端口转发到本地

    lforward将admin节点本地的8888端口转发到node1的8888端口

    (node 1) >>> lforward 127.0.0.1 8888 8888
    forward local network 127.0.0.1 port 8888 to remote port 8888
    

    rforward 将node1网段的192.168.204.103端口8889转发到admin节点本地的8889端口

    (node 1) >>> rforward 192.168.204.103 8889 8889
    forward remote network 192.168.204.103 port 8889 to local port 8889
    

3. 注意事项

  • 现阶段仅支持单个admin节点对网络进行管理
  • 要对新加入的节点进行操作,需要首先在admin节点运行show命令同步网络拓扑和节点编号
  • 当使用第二种端口复用方法(基于iptables)时,你需要使用script/port_reuse.py去启用agent在目标主机上设置的端口复用规则。

TODO

  • 与regeorg联动
  • 多个admin节点同时对网络进行管理
  • 节点间通信流量加密
  • socks5对udp的支持
  • 与meterpreter联动 (待定)
  • RESTful API
  • 关闭代理与端口转发

致谢

venom's People

Contributors

dliv3 avatar ier005 avatar spikei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

venom's Issues

how to goto admin node ?

no help message for the admin node id ? and how can I goto admin node ? I tried goto 0 and goto admin node which failed.

SOCKS5 DNS 解析问题

很棒的项目,点赞!

另外有一个关于建立了 SOCKS5 连接后 DNS 无法解析的问题。在目标内网起了 agent,端口映射至 VPS,然后外网攻击机 admin 连接 VPS 的端口,建立好连接,起 SOCKS5 服务,在攻击机本地监听了 7777 端口,至此一切正常。

接着浏览器设置代理,代理本地 7777 端口,使攻击机可以访问目标内网的 web 服务,但是以域名访问时无法解析(例 wiki.xxx.com),以目标内网 IP 请求时可以访问,说明 DNS 请求没有通过 SOCKS5 隧道转发至 agent 去请求目标内网的 DNS 服务器。

奇怪了,SOCKS5 不是默认会连带 DNS 请求一起走隧道吗?测试了其他的突破内网访问限制的方式,比如 goagent,ssr 等,都出现了这种问题,求一波解答,感谢!

另外,在以域名访问时,agent 报错如下图:

venom

看到这个项目有点开心,想写点东西供你参考。

  1. 节点可视化。你的操作逻辑基本在复用Termite,但show的时候展示的信息太少了。当连接的同级节点比较多之后,是很难把节点ID和对应的主机对应关系记住的,Termite中之所以会把ID及各种系统类型,自定义配置等内容统一展示出来,正是为了应对这种难于长期记忆的问题,提示信息越多,对使用者越友好。
  2. ID分配机制。时间有限,只是粗略的看了一下代码,没看到ID分配机制的部分。从文档中推测是在show的时候触发的ID分配过程。这就要考虑每两次ID刷新时,主机是不是还能够维持上一次的ID,如果ID会改变的话,使用的时候也会比较困惑。尤其是像当前这种只展示了拓扑关系和ID值的方式,在这样的场景下,会更难用。
  3. 把shell绑定到本地端口会更舒服。你现阶段shell指令是直接复用当前控制台的。然而shell控制台是个很基础的需求,它和文件同步类指令要交替使用,才能完成一个完整的控制效果。这样的话,经常来回切换shell模式会比较繁琐,不如绑到一个独立的端口,用起来顺手。而且,shell绑定到端口,也可以方便和其他小组成员分享主机权限,只要大家都在同一局域网,就可以直接nc访问了。
  4. 可执行文件大小问题。项目是用Go写的,后面在IOT环境的扩展问题会很多。其中最核心的问题,是ELF文件太大(IOT的编译大部分都要通过static编译,因为IoT设备环境太复杂了,各种基础库都会遇到,这样的话产品文件就会更大)。而 IoT 设备内存相对又比较小,老些的设备内存只有几十M,加上网络也不会太稳定,这样的前提下,传输的文件越大,成功率就越低。虽然项目中考虑了部分代码选择性编译控制文件大小,然而实际效果有限,毕竟产品中大部分内容都是Go的运行环境(其实说产品中有90%的代码是Go运行环境都不为过,找个IDA看一眼就行,挺明显的)。我当初也是纠结了很久才选择的 C。其实Go还会带来个潜在的问题,那就是 IoT设备的 CPU 资源也有限,如果某程序长时间占用CPU和 内存资源导致系统反应过慢,可能会被 watchdog 误认为设备假死,触发设备重启,那之前的工作很可能就白做了。

断线重连?

agent连admin,admin有节点了,很好。
但是我用完之后就退出admin,等两天我还想继续用,我又打开admin,但是agent不会自动练上来,那我岂不是又要跑到agent机器去重启程序?

cpu占用百分之百

环境:windows tomcat
webshell运行agent 端口复用模式 成功连接,停止tomcat后,agent CPU占用百分之百

长时间未与节点交互后自动断开

不知道是不是BUG,信息如下。希望有一个断线重连的机制。

node disconnect: read tcp 192.168.43.30:58929->118.195.145.245:9930: wsarecv: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

还有上一个兄弟反应的无法跳转回admin节点的情况,只能在子节点之间跳转

交互 shell 阻塞,未正常结束

image

在其中一个节点shell长时间交互后,此时exit退回admin管控,未能未退,阻塞在这里(不知道是否与交互式时启动代理, 例如后台运行开启socks5有关),Ctrl + C等也结束不了,能否向MSF一样, Ctrl + C 后Tem shell 回到 meterpreter。短时间交互 exit 回退是OK的。

CentOS CPU占用 100%

是 Bug 么?agent_linux_x64。
环境 CentOS 云服务器,运行命令 nohup ./agent_linux_x64 -lport 9898 -passwd xxx &

Screenshot 2021-01-21 上午10 14 58
Screenshot 2021-01-21 上午10 16 05

运行socks server时,admin节点panic崩溃

版本1.1.0,released on 10 Jun

在运行一段时间后,报错:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x53e5e6]

goroutine 13303 [running]:
github.com/Dliv3/Venom/admin/dispather.localSocks5Server(0x5d0200, 0xc00000e010, 0xc00005e2c0, 0x40, 0xc000110000, 0xc000044000, 0x1, 0x1)
        /Users/dlive/Code/Go/src/github.com/Dliv3/Venom/admin/dispather/sender.go:427 +0xb6
created by github.com/Dliv3/Venom/netio.InitTCP.func1
        /Users/dlive/Code/Go/src/github.com/Dliv3/Venom/netio/init.go:56 +0x1e1

admin连agent如何管理?

我的需求是,一堆机器,先互相通过agent连接,然后admin可以随时连上某台agent对整个agent网络进行管理。
所以我做实验:A机器(win10) admin B机器(win7) agent
agent -lport 8888
admin -rhost 172.0.0.231 -rport 8888

admin连上之后show,就只有一个A,没有任何节点
难道A不能管理B吗?那A连上B之后有什么用?

我对venom的端口映射(内网穿透)存在疑惑

我的环境为 内网肉鸡 IP :192.168.79.130(安装agent端)
公网机器IP : 118.118.118.118(假设)(安装admin端)
本机IP : 192.168.1.1
肉鸡通过运行了venome的agent 连接到了 公网机器
公网机器 goto 1 进入内网肉鸡的管理页面,运行socks 7777 按理说已经设置了socks5的代理
但是我本机 无法通过设置socks5 118.118.118.118:7777 来连接肉鸡架设的web页面
同样的 无法通过在node1 运行 lforward 127.0.0.1 8888 3389 把肉鸡的3389映射到公网机器的8888端口
通过本机访问118.118.118.118:8888 来访问肉鸡的3389

通过查阅其他人的文章,他们都是直接在内网中实验,例如
内网肉鸡 IP :192.168.79.130
kali机器IP : 192.168.79.1(安装admin端)
然后直接在kali中访问映射的端口如127.0.0.1:8888 我也测试过确实可以访问。

是不是意味着映射的端口只可以在本地访问,其他机器无法访问到映射的端口,或者是不是映射的端口只是允许本地访问。
ps: 我的vps的防火墙,业务组全部都是关的,测试过frp 没有问题。我想进行的是内网穿透

希望各位老师傅解答一下我的疑惑

开启交互式shell时,victim节点异常退出会导致admin节点死锁

hey,感谢您的工具,很不错
我在使用时发现了一些小bug

ENV:
admin node: Windows
victim node: Windows

(admin node) >>>
[+]Remote connection:  127.0.0.1:6754
[+]A new node connect to admin node success
(admin node) >>> shell
you should select node first
(admin node) >>> goto 1
node 1
(node 1) >>> shell
You can execute commands in this shell :D, 'exit' to exit.
Microsoft Windows [Version 10.0.17134.765]
(c) 2018 Microsoft Corporation。保留所有权利。

E:\GoWorkplace\src\github.com\Dliv3\Venom\agent>ls
ls
agent.exe
agent.go
cli
dispather
init

E:\GoWorkplace\src\github.com\Dliv3\Venom\agent>node disconnect:  read tcp 127.0.0.1:4444->127.0.0.1:6754: wsarecv: An existing connection was forcibly closed by the remote host.
Ctrl-C
Ctrl-C
Ctrl-C
Ctrl-C

当victim关闭tcp连接后,admin节点卡死。研究后发现是因为通信的channel阻塞:

if shellPacketRet.Success == 1 {
		c := make(chan bool, 2)
		go CopyStdin2Node(os.Stdin, peerNode, c)
		go CopyNode2Stdout(peerNode, os.Stdout, c)
		<-c
		<-c
...



func CopyNode2Stdout(input *node.Node, output io.Writer, c chan bool) {
	for {
		var packetHeader protocol.PacketHeader
		var shellPacketRet protocol.ShellPacketRet
		err := node.CurrentNode.CommandBuffers[protocol.SHELL].ReadPacket(&packetHeader, &shellPacketRet)
...



func (buffer *Buffer) ReadLowLevelPacket() (protocol.Packet, error) {
	packet := <-buffer.Chan
        // blocking here

我试着修复了该bug,已提交pr #2


还添加了goto命令的节点0,与admin节点绑定。场景:当某个victim节点退出时命令行会继续显示(node 1),可以通过goto 0跳转回(node admin),不过建议未来能根据路由动态更新命令提示符

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.