当前位置:   article > 正文

内网代理工具总结

代理工具

写在前面

本文主要总结常见的代理工具,端口转发工具和 DNS 隧道、ICMP 隧道工具放在另一篇。

内网代理技术简介

当你在内网渗透的时候,在已经拿下一台主机或多台主机的情况下,遇到不出网的主机,你想 move to it,但是你没有到不出网主机的路由,也不容易建立这样的路由,该怎么办?
PS:你用 CS、MSF 这样的综合工具当我放 peach。

这时候,代理技术就非常重要了。通过把已拿下的主机做成代理服务器(跳板机),让代理服务器帮助你转发你的流量到不出网主机,实现访问。

常见代理协议简介

应用层代理协议包括 HTTP、HTTPS、SOCK、SOCKS、DNS、SSH 等协议;
传输层代理协议有:TCP、UDP;
网络层代理协议有:ICMP。

以上只是一般场景经常使用的网络通信协议,对于特殊场景的网络通信协议暂未了解,还有,你也可以开发自己的代理工具和通信协议。

制作代理服务器方法简介

通常被制作成代理服务器的内网主机为出于内网边界可以连接外网的服务器。

代理功能如何实现?

  • 只需要让服务器监听一个端口接收数据,
  • 再用一个软件将这个数据转发出去。

所以我们需要使用一个软件,让软件运行在服务器上,它会在服务器开放并监听该个端口,接收并根据代理服务器自己的路由来转发数据。

内网常用代理工具:

  • EW(好用)
  • Venom:https://github.com/Dliv3/Venom
  • FRP
  • NPS:https://github.com/ehang-io/nps/releases
  • Neo-reGeorg:reGeorg 改进版 https://github.com/L-codes/Neo-reGeorg
  • Termite:Termite,EW 最新版
  • Stowaway:Venom 改进版 https://github.com/ph4ntonn/Stowaway
  • Ngrok:https://ngrok.com/download
  • stunnel
  • ptunnel
  • reGeorg:https://github.com/sensepost/reGeorg

利用代理进行转发流量的工具

有了代理服务器(跳板机),我们想要将访问请求转发到不出网主机,首先需要连接到代理服务器的监听端口,下面列出常用的代理连接工具。

Windows 下:

  • Proxifier

Linux 下:

  • Proxychains、Proxychains4

Proxifier 可以全局代理也可以仅代理指定软件的流量,功能齐全且强大。
Proxychains 操作简单,使用方便,暂不支持全局代理。

Proxifier 用法

这里不详述,下面是汉化后版本的界面,英文界面各个按钮位置相同。
image.png
点击配置文件->代理服务器,会弹出一个窗口,让你添加代理服务器,添加代理服务器需要配置代理服务器 IP 及其监听端口,代理通信协议,其他的按照你的需求来。然后检查(Check)一下,只要能连通代理服务器即可,不需要等它检查完。
image.png
该工具还可以配置代理链,但这里不详述。
然后设置代理规则,是全局代理还是仅代理部分软件,是使用哪个代理服务器,代理出口使用哪个网卡。
image.png
image.png

Proxychains4

Proxychains4 的使用相当简单,首先你需要配置 Proxychains4.conf:

vim /etc/proxychains4.conf

# 添加代理服务器
# 协议 ip port
socks5 192.168.111.80 45666
  • 1
  • 2
  • 3
  • 4
  • 5

然后你就可以使用 proxychains4 来将你指定程序的流量代理出去了:

# curl 命令
proxychains4 curl url

# impacket-psexec 横向
proxychains4 impacket-psexec de1ay/administrator:2wsx\!QAZ@10.10.10.10
  • 1
  • 2
  • 3
  • 4
  • 5

EW 使用方法

Earthworm,EW,支持 Socks 代理,有多个版本,非常方法,上传即用。
image.png
基础使用方法:

 ./xxx ([-options] [values])*
 options :
 Eg: ./xxx -s ssocksd -h
 -s state setup the function.You can pick one from the following options:
 ssocksd , rcsocks , rssocks , lcx_listen , lcx_tran , lcx_slave
 -l listenport open a port for the service startup.
 -d refhost set the reflection host address.
 -e refport set the reflection port.
 -f connhost set the connect host address.
 -g connport set the connect port.
 -h help show the help text, By adding the -s parameter, you can also see the more detailed help.
 -a about show the about pages
 -v version show the version.             
 -t usectime set the milliseconds for timeout. The default value is 1000
 ......

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

下面介绍常用的几种场景,环境如下:

  • 外网主机 K 【1.1.1.1】
  • 内网主机 A 【1.1.1.2】,【10.1.1.2】
  • 内网主机 B 【10.1.1.2】,【10.1.2.2】
  • 内网主机 C 【10.1.2.1】

正向代理 ssocksd

在外网主机 K 可以访问内网主机 A(一般是双网卡或做了端口映射,下同不再强调) 的情况下,利用正向连接搭建代理进入内网。

# 在内网主机A上搭建代理,监听12345端口
ew_for_Win.exe -s ssocksd -l 12345
  • 1
  • 2

=> 亲测有用

反向代理 rcsocks,rssocks

在外网主机 K 无法访问内网主机,但是内网主机可以访问到外网主机的情况下,利用反向连接搭建代理进入内网。

# 先在外网主机(1.1.1.1)上监听12345和8888端口
# 等待目标连接,将12345端口的流量转发到本地8888端口
ew_for_Win.exe -s rcsocks -l 12345 -e 8888

# 然后在内网主机和外网主机8888端口建立连接
ew_for_Win.exe -s rssocks -d 1.1.1.1 -e 8888
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

=> 暂未实验

二级代理:正向代理+端口转发:ssocksd+lcx_tran

内网主机 A 无法访问深层内网,内网主机 B 可以访问深层内网,A 只能通过 B 访问到内网,此时外网主机要访问内网就要通过 A 到 B 再到内网。这时可以在 A 上做正向代理和端口转发,将 B 的端口

# 内网主机B(10.1.1.2)监听8888端口
ew_for_Win.exe -s ssocksd -l 8888

# 内网主机A(10.1.1.1/1.1.1.2)将本地12345端口的流量转发到内网主机B的8888端口
ew_for_Win.exe -s lcx_tran -l 12345 -f 10.1.1.2 -g 8888
  • 1
  • 2
  • 3
  • 4
  • 5

=> 亲测有用

二级代理:反向代理+端口转发:ssocksd+lcx_listen+lcx_slave

外网主机 K 不可以访问内网主机A,此时可在内网主机A、B做反向代理+端口转发进入内网

# 内网主机B(10.1.1.2)监听8888端口
ew_for_Win.exe -s ssocksd -l 8888

# 外网主机(1.1.1.1)监听12345和9999端口
# 等待目标连接,将12345端口流量转发到本地9999端口
ew_for_Win.exe -s lcx_listen -l 12345 -e 9999

# 内网主机A(10.1.1.1)连接外网主机的9999端口和内网主机B(10.1.1.2)的8888端口
# 隧道连接后,相当于将内网主机B的8888端口映射到外网主机的12345端口
ew_for_Win.exe -s lcx_slave -d 1.1.1.1 -e 9999 -f 10.1.1.2 -g 8888
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

=> 暂未实验

使用 EW 二级代理遇到的问题

  1. 使用 impacket-psexec 成功获取 shell 后,一小会就:

[*] Opening SVCManager on 10.10.10.10…
[-] Error performing the uninstallation, cleaning up

NPS 使用方法

Nps是一款轻量级、高性能、功能强大的内网穿透代理服务器。目前支持tcp、udp流量转发,可支持任何tcp、udp上层协议(访问内网网站、本地支付接口调试、ssh访问、远程桌面,内网dns解析等等……),此外还支持内网http代理、内网socks5代理、p2p等,并带有功能强大的web管理端。

NPS 使用手册:https://ehang-io.github.io/nps/#/

NPS 分为服务端和客户端,在内网渗透的角度来看

  • 客户端运行在攻击者机器上
  • 服务端运行在处于跳板机上

实验环境:

  • 服务端:Windows 11
  • 客户端:Kali
  • 目标:Windows 10

服务端使用方法:

# 以管理员运行
npx.exe
# 成功运行命令行显示为:
2023/09/03 21:49:12.477 [I] [nps.go:202]  the version of server is 0.26.10 ,allow client core version to be 0.26.0
2023/09/03 21:49:12.709 [I] [connection.go:36]  server start, the bridge type is tcp, the bridge port is 8024
2023/09/03 21:49:12.711 [I] [server.go:200]  tunnel task  start mode:httpHostServer port 0
2023/09/03 21:49:12.711 [I] [connection.go:71]  web management start, access port is 8080
2023/09/03 21:49:12.711 [I] [connection.go:62]  start https listener, port is 443
2023/09/03 21:49:12.711 [I] [connection.go:53]  start http listener, port is 80
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

然后可以就可以在你自己的主机上用浏览器访问服务端 IP+8080 端口进入 Web 控制台。默认密码 admin:123
进入 Web 控制台,点击新增客户端,填写信息创建一个客户端。
image.png点击客户端左侧的+号,展开详细信息,复制启动命令,在客户端启动时使用:
image.png

客户端使用方法:

# 将下面-server后面的IP地址换成服务端的IP即可。
./npc.exe -server=127.0.0.1:8024 -vkey=wgw4lp13bsv8d6mo -type=tcp
  • 1
  • 2

image.png
然后你就可以使用代理去执行程序了。当前要先配置你的代理,你要使用哪个协议就点开 Web 管理页面中对应的协议代理,如 Socks 代理:
image.png
然后配置完代理工具,就可以使用代理运行程序了

sudo proxychains4  nmap -sS 192.168.44.132
  • 1

image.png


其他使用方法,可以使用参数 -h 来查询。

Frp 使用方法

Go开发的高性能反向代理工具,简单配置后可轻松实现内网穿透,支持 TCP、UDP、HTTP、HTTPS等多协议类型,功能强大,免杀效果好,但是体积较大 (10MB)。

分为 frps(服务端)和 frpc(客户端),服务端配置文件 frps.ini,客户端配置文件 frpc.ini,外网主机运行服务端,内网主机运行客户端。

Frp 容易被态势感知查杀,所以要会修改流量特征哟。

FRP 使用客户端进行代理,服务器做管理用。

反向代理

可用于外网主机 A 能访问内网主机 B,不能访问内网主机 C,而 C 可以访问到 A 的情况。
服务端运行在 A 上,frps.ini 配置如下:

 [common]
bind_addr = 1.1.1.1       # 服务端绑定ip,为本机
bind_port = 11111         # 服务端绑定端口

# dashboard:可通过浏览器查看frp的状态和统计信息
dashboard_addr = 1.1.1.1  # dashboard管理地址,为本机
dashboard_port = 22222    # dashboard管理端口
dashboard_user = root     # dashboard用户名
dashboard_pwd  = 123456   # dashboard用户密码

token = passw@rd          # 客户端与服务端连接的密码

# frp服务端通过heartbeat检测客户端在线状态,客户端每隔一段时间会自动给服务端
# 发heartbeat数据包,如果超时时间过后服务端没有收到heartbeat,则默认客户端掉线
heartbeat_interval = 10   # 客户端与服务端之间心跳间隔时间,默认为10秒
heartbeat_timeout = 90    # 客户端与服务端之间心跳超时时间,默认为90秒

# 默认情况下,代理搭建后只有当用户请求建立连接时,frps才会与frpc建立连接
# 而启用连接池后,frps和frpc之间会预先创建指定数量的连接形成连接池,每次接收到
# 用户请求后,会从连接池中取出一个连接和用户连接相关联,减少了建立连接的响应时间
# frps.ini 配置连接池的最大值:max_pool_count 
# frpc.ini 配置预创建连接的数量:pool_count
# 该功能适合有大量促发短连接请求时使用 
max_pool_count = 5        # 代理可以创建的连接池最大值,客户端设置超过此配置后会被调整到当前值

allow_ports = 2000-3000,50000-60000 # 指定可以被使用的代理端口

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

内网主机 B 运行客户端,frpc.ini 配置如下:

[common]
server_addr = 1.1.1.1    # 服务端绑定ip
server_port = 11111       # 服务器绑定端口

tls_enable = true         # 服务端/客户端流量使用TLS加密,默认不开启
                          # 开启TLS加密后不需要再设置 use_encryption
token = passw@rd          # 客户端与服务端连接的密码
protocol = tcp            # 协议类型

pool_count = 1            # 启用连接池,指定预创建连接的数量 

[demo]                    # 自定义代理的名称
remote_port = 10000       # 代理的端口
plugin = socks5           # 使用的协议

use_encryption = true     # 代理使用加密算法 (snappy),默认不开启
use_compression = true    # 代理使用流量压缩,减少通信流量,默认不开启

plugin_user= admin        # 配置socks5服务用户名
plugin_passwd= admin      # 配置socks5服务密码

# 代理健康检查,服务端与客户端之间发包检测,在反向代理出现故障时
# 自动将故障代理服务删除,加强服务的可用性,目前可选择的协议类型为tcp和http
health_check_type = tcp       # 启用健康检查功能,类型为tcp
health_check_interval_s = 100 # 设定每隔100秒进行一次健康检查
health_check_timeout_s = 3    # 健康检查建立连接超时时间设置为3秒
health_check_max_failed = 3   # 连续3次建立连接失败时,此代理服务会被移除
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

这样,在 A 上设置代理为 socks5 127.0.0.1 10000,即可。

端口转发

服务端,frps.ini

[common]    
bind_addr = 1.1.1.1      
bind_port = 11111         

dashboard_addr = 1.1.1.1
dashboard_port = 22222    
dashboard_user = root     
dashboard_pwd  = 123456   

token = password          

heartbeat_interval = 10  
heartbeat_timeout = 90    

max_pool_count = 5        
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

客户端,fprc.ini:

[common]
server_addr = 1.1.1.1 
server_port = 11111
token = password
 
[test]
type = tcp
local_ip = 127.0.0.1 # 本地内网主机ip
local_port = 3389    # 本地内网主机端口
remote_port = 12389  # 远程外网主机端口
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

Venom 使用方法

Venom是一款为渗透测试人员设计的使用Go开发的多级代理工具,可将多个节点进行连接,然后以节点为跳板,构建多级代理。
渗透测试人员可以使用Venom轻松地将网络流量代理到多层内网,并轻松地管理代理节点。

特性:

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

代理功能

Venom 分为 admin 和 agent,而这两者均可以发起连接和监听,可通过-passwd指定密码,该密码用于生成AES加密所需的密钥,对通信流量进行加密。

# admin监听端口,agent主动连接
admin -lport 12345 -passwd P@ssw0rd
agent -rport 12345 -rhost 10.1.1.1 -passwd P@ssw0rd

# agent监听端口,admin主动连接
# admin掉线后agent不会关闭监听端口,admin再次重连时agent仍然会上线
agent -lport 12345 -passwd P@ssw0rd
admin -rport 12345 -rhost 10.1.1.1 -passwd P@ssw0rd
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

admin 可以进行管理,所以将 admin 放在公网服务器。

端口复用

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

  • 通过SO_REUSEPORT和SO_REUSEADDR选项进行端口复用
  • 通过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
  • 1
  • 2
  • 3
  • 4
./admin_macos_x64 -rhost 192.168.204.139 -rport 80
  • 1

第二种端口复用方法

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

这种端口复用方法会在本机设置iptables规则,将reuse-port的流量转发到lport,再由agent分发流量。
需要注意一点,如果通过sigterm,sigint信号结束程序(kill或ctrl-c),程序可以自动清理iptables规则。如果agent被kill -9杀掉则无法自动清理iptables规则,需要手动清理,因为agent程序无法处理sigkill信号。
为了避免iptables规则不能自动被清理导致渗透测试者无法访问80端口服务,所以第二种端口复用方法采用了iptables -m recent通过特殊的tcp包控制iptables转发规则是否开启。

节点管理,搭建多级节点

(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.
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

listen [port]和connect [rhost] [rport]命令用于节点间互连,有两种方式:

  1. 先在node1节点开启端口监听,然后node2节点用agent连接:
# 先在node1节点监听56789端口
(admin node) >>> show # 显示网络拓扑
A
+ -- 1
(admin node) >>> goto 1 # 转到节点1
(node 1) >>> listen 56789
listen 56789
the port 56789 is successfully listening on the remote node!

# 然后在node2运行agent,连接node1,因为此时node2还没上线,所以无法goto跳转
agent -rhost 10.1.1.2 -rport 56789 -passwd P@ssw0rd

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  1. 先在node2节点运行agent开启端口监听,然后node1节点connect命令连接:
# 先在node2节点运行agent开启端口监听
agent -lport 56789 -passwd P@ssw0rd

# 然后node1节点connect连接
(node 1) >>> connect 10.1.1.3 56789
connect to 10.1.1.2 56789
successfully connect to the remote port!
(node 1) >>> show
A
+ -- 1
     + -- 2
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

端口转发功能

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
  • 1
  • 2

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
  • 1
  • 2

Neo-reGeorg 使用方法

该工具通过 HTTP 协议传输 Socks5 协议数据,为 reGeorg 的改良版。

使用条件:类似于 webshell,要能够将生成隧道文件上传至 web 服务器,然后连接。

在外网主机上:

# generate 表示生成, -k 表示密钥
python3 neoreg.py generate -k P@ssw0rd
  • 1
  • 2

会生成多种隧道脚本:

  [+] Create neoreg server files:
     => neoreg_servers/tunnel.ashx
     => neoreg_servers/tunnel.aspx
     => neoreg_servers/tunnel.jsp
     => neoreg_servers/tunnel_compatibility.jsp
     => neoreg_servers/tunnel.jspx
     => neoreg_servers/tunnel_compatibility.jspx
     => neoreg_servers/tunnel.php
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

将脚本上传至内网边界服务器 1.1.1.2,连接它,连接成功后,它会自动监听本地端口 1080:

python3 neoreg.py -k P@ssw0rd -u http://1.1.1.2/tunnel.php
  • 1

最后将代理设置为 socks5 1.1.1.2 1080 即可使用代理。

以上只提供了最基本的操作方式,其他方式请使用 -h 查询。能学到这里想必工具也用了不少,相信你。

Stunnel 使用方法

stunnel 是一个用于加密和解密网络连接的工具,它可以将任何普通的 TCP 连接转换为加密的 SSL/TLS 连接。
stunnel 支持协议:TCP、UDP、SSL、TLS、HTTP、POP3/IMAP、SMTP、FTP、SOCKS、NNTP、LDAP等

以下服务器均指Stunnel代理服务器,内网穿透中,Stunnel代理服务器一般放置在跳板机上。

该工具可用于一些网络协议的端口转发,既可本地端口转发,也可远程端口转发。

基础使用步骤

  1. 服务器生成证书和私钥文件

使用 openssl 生成证书:

openssl req -new -x509 -days 365 -nodes -config /etc/ssl/openssl.cnf -out stunnel.pem -keyout stunnel.pem
  • 1
  1. 服务器配置文件配置参数

在跳板机上执行下列操作:

mkdir /etc/stunnel

vim /etc/sunnel/stunnel.conf
  • 1
  • 2
  • 3

添加以下内容:

chroot = /var/log/stunnel/	# 配置运行时缓存目录位置
compression=zlib			# 通信压缩方式
syslog=yes						# 是否开启系统记录
debug=7								# 
output=/var/log/stunnel.log	# 日志输出路径
setuid=root						# 运行用户权限
setgid=root						# 运行组权限
pid=/var/run/stunnel.pid	# 配置运行时进程ID依赖文件
cert=/etc/stunnel/stunnel.pem	# 配置证书文件
key=/etc/stunnel/stunnel.pem	# 配置密钥文件
client=no							# no表示服务端
taskbar=no 						# 是否在系统栏显示图标
verify = no						# 设置是否验证对端证书

[ssh] 								# ssh 部分
accept=2223						# 本机对外监听端口
connect=192.168.111.12:22	# 该服务的目的地址
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  1. 攻击机配置文件
chroot = /var/log/stunnel/
pid = /stunnel.pid
client = yes
taskbar = yes 						#是否在系统栏显示图标

[ssh] 								# ssh 部分
accept=8099						# 本机对外监听端口
connect=192.168.44.133:2223	# 该服务的目的地址,对于攻击者而言就是代理服务器地址(IP:Port)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  1. 服务器、客户端运行stuunel
sudo stunnel /etc/stunnel/stunnel.conf
  • 1

搭建TCP隧道

环境:
kali:192.168.44.128
跳板机Ubuntu:192.168.44.133,192.168.111.128
目标机器Ubuntu:192.168.111.12

生成代理服务器证书和私钥文件:

openssl req -new -x509 -days 365 -nodes -config /etc/ssl/openssl.cnf -out stunnel.pem -keyout stunnel.pem
  • 1

代理服务器配置:

chroot = /var/log/stunnel/	# 配置运行时缓存目录位置
compression=zlib			# 通信压缩方式
syslog=yes						# 是否开启系统记录
debug=7								# 
output=/var/log/stunnel.log	# 日志输出路径
setuid=root						# 运行用户权限
setgid=root						# 运行组权限
pid=/var/run/stunnel.pid	# 配置运行时进程ID依赖文件
cert=/etc/stunnel/stunnel.pem	# 配置证书文件
key=/etc/stunnel/stunnel.pem	# 配置密钥文件
client=no							# no表示服务端
taskbar=no 						# 是否在系统栏显示图标
verify = no						# 设置是否验证对端证书

[tcp]
accept = 8000
connect = 192.168.111.12:26665
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号