NPS作为一款轻量级、高性能、功能强大的内网穿透代理服务器。并且支持多种协议的转发从而被广泛使用,借助网络空间搜索引擎2020年11月26日的结果,全球范围内共5,582个主机为NPS代理服务器。

目录解析

以NPS 0.26.9版本为例,目录结构及含义如下

│   nps

├───conf //配置目录
│ clients.json //客户端数据文件
│ hosts.json //主机数据文件
│ nps.conf //配置文件
│ server.key //私钥
│ server.pem //证书
│ tasks.json //任务数据文件

└───web //网站目录
├───static //静态资源目录
│ ├───css
│ │ bootstrap-table.min.css
│ │ bootstrap.min.css
│ │ datatables.css
│ │ fontawesome.min.css
│ │ regular.min.css
│ │ solid.min.css
│ │ style.css
│ │
│ ├───img
│ │ └───flag
│ │ en-US.png
│ │ zh-CN.png
│ │
│ ├───js
│ │ bootstrap-table-locale-all.min.js
│ │ bootstrap-table.min.js
│ │ bootstrap.min.js
│ │ echarts.min.js
│ │ fontawesome.min.js
│ │ inspinia.js
│ │ jquery-3.4.1.min.js
│ │ language.js
│ │ popper.min.js
│ │
│ ├───page
│ │ error.html
│ │ languages.xml
│ │
│ └───webfonts
│ fa-solid-900.eot
│ fa-solid-900.svg
│ fa-solid-900.ttf
│ fa-solid-900.woff
│ fa-solid-900.woff2

└───views //视图模板
├───client //客户端模板
│ add.html
│ edit.html
│ list.html

├───index //主页模板
│ add.html
│ edit.html
│ hadd.html
│ hedit.html
│ help.html
│ hlist.html
│ index.html
│ list.html

├───login //登录页模板
│ index.html
│ register.html

└───public //通用模板
error.html
layout.html

配置文件

以下内容均为缺省值

appname = nps //默认应用名
#Boot mode(dev|pro)
runmode = dev //启动模式

#HTTP(S) proxy port, no startup if empty
http_proxy_ip=0.0.0.0
http_proxy_port=80
https_proxy_port=443
https_just_proxy=true
#default https certificate setting
https_default_cert_file=conf/server.pem
https_default_key_file=conf/server.key

##bridge
bridge_type=tcp
bridge_port=8024
bridge_ip=0.0.0.0

# Public password, which clients can use to connect to the server
# After the connection, the server will be able to open relevant ports and parse related domain names according to its own configuration file.
public_vkey=123

#Traffic data persistence interval(minute)
#Ignorance means no persistence
#flow_store_interval=1

# log level LevelEmergency->0 LevelAlert->1 LevelCritical->2 LevelError->3 LevelWarning->4 LevelNotice->5 LevelInformational->6 LevelDebug->7 //日志等级,默认不以文件形式留存
log_level=7
#log_path=nps.log

#Whether to restrict IP access, true or false or ignore
#ip_limit=true

#p2p //p2p配置
#p2p_ip=127.0.0.1
#p2p_port=6000

#web //web服务器配置
web_host=a.o.com
web_username=admin //默认用户
web_password=123 //默认密码
web_port = 8080
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
# if web under proxy use sub path. like http://host/nps need this.
#web_base_url=/nps

#Web API unauthenticated IP address(the len of auth_crypt_key must be 16)
#Remove comments if needed
#auth_key=test
auth_crypt_key =1234567812345678

#allow_ports=9001-9009,10001,11000-12000 //端口限制

#Web management multi-user login //web管理项
allow_user_login=false
allow_user_register=false
allow_user_change_username=false


#extension //拓展
allow_flow_limit=false
allow_rate_limit=false
allow_tunnel_num_limit=false
allow_local_proxy=false
allow_connection_num_limit=false
allow_multi_ip=false
system_info_display=false

#cache //缓存
http_cache=false
http_cache_length=100

#get origin ip //获取原始IP
http_add_origin_header=false

#pprof debug options
#pprof_ip=0.0.0.0
#pprof_port=9999

#client disconnect timeout
disconnect_timeout=60

缺省口令

nps的缺省口令为admin/123,这也造成了一些安全问题,我们通过一个脚本(Github链接)对通过公网指纹找到的nps服务器进行了扫描。

全网扫描结果

对6000+指纹识别到的目标进行扫描,存在缺省口令的目标共618个

分布图如下

image-20201204182851879

可以看出中国境内的NPS服务器还是相当多的,NPS在国内常用于办公环境、开发环境的测试和穿透,如果被拿下,可以对内网进行漫游、权限获取等操作。

其中不乏某些电商开发环境政府机要部门内也存在该问题。

缓解措施

以Linux系统为例

  1. 修改/etc/nps/web/nps.conf中的缺省密码
  2. 重启nps服务即可