跳板攻击之:NPS代理转发

1 NPS介绍

官方介绍太官方了,看了还需要时间慢慢理解,因此写此文章,以具体案例方便理解

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

文档 (ehang-io.github.io)

2 NPS特点

  • 协议支持全面,兼容几乎所有常用协议,例如tcp、udp、http(s)、socks5、p2p、http代理...

  • 全平台兼容(linux、windows、macos、群辉等),支持一键安装为系统服务

  • 控制全面,同时支持服务端和客户端控制

  • https集成,支持将后端代理和web服务转成https,同时支持多证书

  • 操作简单,只需简单的配置即可在web ui上完成其余操作

  • 展示信息全面,流量、系统信息、即时带宽、客户端版本等

  • 扩展功能强大,该有的都有了(缓存、压缩、加密、流量限制、带宽限制、端口复用等等)

  • 域名解析具备自定义header、404页面配置、host修改、站点保护、URL路由、泛解析等功能

  • 服务端支持多用户和用户注册功能

3 实验环境

3.1 实验准备

  1. 添加 A 记录 <your_vps_ domain> 指向 VPS IP
  2. Metasploitable主机开放了22,23与80端口与服务

3.2 实验拓扑

3.3 NPS配置

3.3.1 conf/nps.conf

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,默认是8084,此处修改为8081
bridge_type=tcp
bridge_port=8081
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=Admin@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_ip=127.0.0.1
#p2p_port=6000 #web
web_host=a.o.com
web_username=fcarey
web_password=Aadmin@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
auth_crypt_key =admin123admin123 #allow_ports=9001-9009,10001,11000-12000 #Web management multi-user login
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
http_add_origin_header=false #pprof debug options
#pprof_ip=0.0.0.0
#pprof_port=9999 #client disconnect timeout
disconnect_timeout=60

3.3.2 NPS配置客户端

类型 内容
备注 Client1
Basic 认证用户名仅限Socks5、Web、HTTP转发代理 Client1
Basic 认证密码仅限Socks5、Web、HTTP转发代理 Aadmin@123
唯一验证密钥唯一值,不填将自动生成 Aadmin@123
允许客户端通过配置文件连接
压缩
加密

3.4 NPC 无配置文件连接 NPS

./npc -server=192.168.50.49:8081 -vkey=Aadmin@123 -type=tcp

3.4.1 若遇到错误提示:找不到配置文件

0.26.7 客户端无法无配置文件启动 · Issue #556 · ehang-io/nps · GitHub

  • 下载客户端并解压,运行

    ./npc -server=xxxxxx:8024 -vkey=xxxxxx
    
    2020/05/24 20:00:59.554 [I] [npc.go:231]  the version of client is 0.26.7, the core version of client is 0.26.0
    2020/05/24 20:00:59.570 [I] [control.go:97] Loading configuration file conf/npc.conf successfully
    2020/05/24 20:01:20.574 [E] [control.go:111] dial tcp 172.0.0.1:8024: connectex: 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.
    2020/05/24 20:01:20.575 [I] [control.go:102] Reconnecting...
  • 中断运行并删除conf文件夹再运行

    2020/05/24 19:57:37.941 [I] [npc.go:231]  the version of client is 0.26.7, the core version of client is 0.26.0
    2020/05/24 19:57:37.957 [E] [control.go:94] Config file conf/npc.conf loading error open conf/npc.conf: The system cannot
  • 解决方式:

    • 参数没传进去就用的配置文件,参数能不能传进去与你用的shell用法有关,换个shell试试

4 NPS代理socks

  1. 实现:kali通过socks代理,访问蓝队内网2 Metasploitable的 ssh 服务。

  2. NPS WEB上配置:

    类型 内容
    模式 SOCKS代理
    客户端 ID 2
    备注 SOCKS_Proxy
    服务端端口 2333
  3. kali配置/etc/proxychains4.conf

    socks5          <your_vps_IP> 2333 Client1 Aadmin@123
    • 代理服务器IP为:VPS 的 IP
  4. kali通过NPS socks代理,访问蓝队内网2 Metasploitable的 ssh 服务。

    # proxychains ssh msfadmin@192.168.50.49
    The authenticity of host '192.168.50.49 (192.168.50.49)' can't be established.
    ED25519 key fingerprint is SHA256:6Z6oAq5VrJ6itY95hYppj4VxvrdVRplMQGjvER7fBOE.
    This key is not known by any other names.
    Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
    Warning: Permanently added '192.168.50.49' (ED25519) to the list of known hosts.
    msfadmin@192.168.50.49's password:
    msfadmin@metasploitable:~$ id
    uid=1000(msfadmin) gid=1000(msfadmin) groups=4(adm),20(dialout),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),107(fuse),111(lpadmin),112(admin),119(sambashare),1000(msfadmin)

5 NPS HTTP 代理

  1. 实现:kali通过NPS HTTP代理,创建一个只有自己能访问到蓝队内网2 Metasploitable的 web 服务代理。

  2. NPS WEB上配置:

    类型 内容
    模式 HTTP
    客户端 ID 2
    备注 HTTP_Proxy
    服务端端口 8082
  3. kali通过NPS HTTP 代理,访问到蓝队内网2 Metasploitable的 WEB 服务。

    • :此处的用户与密码是创建客户端的时,配置完成的

6 NPS代理tcp

  1. 实现:kali通过NPS tcp代理,访问蓝队内网2 Metasploitable的 ssh 服务。

  2. NPS WEB上配置:

    类型 内容
    模式 TCP
    客户端 ID 2
    备注 MSF_SSH
    服务端端口 2222
    目标 (IP:端口) 10.1.2.3:22
  3. kali通过NPStcp代理,访问蓝队内网2 Metasploitable的 ssh 服务。

    # ssh msfadmin@192.168.50.49 2222
    The authenticity of host '192.168.50.49 (192.168.50.49)' can't be established.
    ED25519 key fingerprint is SHA256:6Z6oAq5VrJ6itY95hYppj4VxvrdVRplMQGjvER7fBOE.
    This key is not known by any other names.
    Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
    Warning: Permanently added '192.168.50.49' (ED25519) to the list of known hosts.
    msfadmin@192.168.50.49's password:
    msfadmin@metasploitable:~$ id
    uid=1000(msfadmin) gid=1000(msfadmin) groups=4(adm),20(dialout),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),107(fuse),111(lpadmin),112(admin),119(sambashare),1000(msfadmin)

7 NPS代理通过自定义域名访问内网的 Web 服务(域名解析功能)

  1. 实现:kali通过NPS 域名解析功能,使用http://<your_vps_sub.domain>,访问蓝队内网2 Metasploitable 上的 WEB 服务器(80端口)。

  2. NPS WEB上配置:

    类型 内容
    客户端 ID 2
    备注 DNS_Paser
    主机 a.fcarey.com
    模式 所有
    URL路由 /
    目标 (IP:端口) 10.1.2.3:80
    • 如果想访问Win7 上的web服务器(80端口),127.0.0.1
  3. kali通过http://a.fcarey.com:8888,访问蓝队内网2 Metasploitable上的 WEB 服务器(80端口)。

    • :若没有域名又想做实验,确认效果:可以在本地修改host文件:

      192.168.50.49 a.fcarey.com

8 NPS私密代理

  1. 实现:kali通过NPS 私密代理代理,创建一个只有自己能访问到蓝队内网2 Metasploitable的 telnet 服务代理。

  2. NPS WEB上配置:

    类型 内容
    模式 私密代理
    客户端 ID 2
    备注 Screct_Proxy
    目标 (IP:端口) 10.1.2.3:23
    唯一标识密钥 Aadmin@123
  3. 访问端命令(此处为Kali下的命令): ./npc -server=192.168.50.49:8081 -vkey=Aadmin@123 -type=tcp -password=Aadmin@123 -local_type=secret

    # npc -server=192.168.50.49:8081 -vkey=Aadmin@123 -type=tcp -password=Aadmin@123 -local_type=secret
    2023/02/25 20:29:05.919 [I] [local.go:115] successful start-up of local tcp monitoring, port 2000
    2023/02/25 20:29:32.319 [D] [local.go:117] new secret connection
  4. kali通过NPS私密代理,访问到蓝队内网2 Metasploitable的 Telnet 服务。

    # telnet -l msfadmin 127.0.0.1 2000
    Password:
    Last login: Fri Feb 24 12:00:19 EST 2023 from 10.1.2.1 on pts/2
    Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686 The programs included with the Ubuntu system are free software;
    the exact distribution terms for each program are described in the
    individual files in /usr/share/doc/*/copyright. Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
    applicable law. To access official Ubuntu documentation, please visit:
    http://help.ubuntu.com/
    No mail.
    msfadmin@metasploitable:~$

9 高级功能

https://ehang-io.github.io/nps/#/feature

10 交个朋友

跳板攻击之:NPS代理转发的更多相关文章

  1. ssh代理转发

    实验环境 serverA:172.16.2.116 serverB:172.16.2.225 serverC:172.16.2.115 "代理转发"是针对ssh认证过程的一种转发 ...

  2. curl运行json串,代理转发格式

    curl -b 'uin=o0450654733; skey=@tq9xjRvYy' -H "Content-Type: application/json" -X POST -d ...

  3. windows下使用密钥登录Linux及xshell代理转发

    1.密钥登录原理 一般我们使用xshell访问远程主机(Linux主机)时,都是先请管理员给我们开一个账户,即为我们设置一个一个用户名和对应的密码,然后我们就可以使用下面的方式登录到远程主机了: 在这 ...

  4. IIS充当代理转发请求到Kestrel

    接着上篇博文为ASP.NetCore程序启用SSL的code,这篇将介绍如何用IIS充当反向代理的角色转发请求到Kestrel服务器 与ASP.NET不同,ASP.netCore使用的是自托管web服 ...

  5. Nginx代理转发Apache+svn

    1.安装svn和httpd yum install httpd yum install subversion mod_dav_svn 创建仓库目录 mkdir -p /var/www/svn 3.创建 ...

  6. nginx反向代理转发后页面上的js css文件无法加载【原创】

    故障现象:nginx做代理转发后,发现页面上的js css文件无法加载,页面样式乱了. 原因:没有配置静态资源 解决js css文件无法加载无法访问的问题 解决办法: 修改配置文件nginx.conf ...

  7. Docker Kubernetes hostPort 代理转发

    Docker Kubernetes  hostPort 代理转发 hostPort: 1. 类似docker -p 映射宿主级端口到容器. 2. 容器所在的主机暴露端口转发到指定容器中. 3. hos ...

  8. IIS充当反向代理转发请求到Kestrel

    接着上篇博文为ASP.NetCore程序启用SSL的code,这篇将介绍如何用IIS充当反向代理的角色转发请求到Kestrel服务器 介绍 与ASP.NET不同,ASP.netCore使用的是自托管w ...

  9. iis和apache共用80端口,IIS代理转发apache

    为什么共用80端口应该不用多说了,服务器上程序运行环境有很多套,都想抢用80端口,所以就有了共用80端口的解决方案. 网上很多的教程一般都是设置APACHE使用默认80端口,代理转发IIS的网站,II ...

  10. (转)基于live555的流媒体代理转发服务器

    对于并发量并不大而且对性能要求不是很高的流媒体传输模块,live555还是很好的选择,下面说一下我所实现的流媒体代理服务器(目前只能实现对H264单视频的转发)代理转发主要 对于并发量并不大而且对性能 ...

随机推荐

  1. kubernetes数据持久化StorageClass动态供给(二)

    存储类的好处之一便是支持PV的动态供给,它甚至可以直接被视作为PV的创建模版,用户用到持久性存储时,需要通过创建PVC来绑定匹配的PV,此类操作需求较大,或者当管理员手动创建的PV无法满足PVC的所有 ...

  2. Windows 10 读取bitlocker加密的硬盘出现参数错误怎么解决?

    我为了数据安全,用windows专业版的bitlocker加密了一个固态硬盘SSD做的移动硬盘(u盘同理),在家里电脑(windows10 家庭版)打开的时候出现了参数错误 即使密码输入正确还是这个错 ...

  3. 网络I/O模型 解读

    网络.内核 网卡能「接收所有在网络上传输的信号」,但正常情况下只接受发送到该电脑的帧和广播帧,将其余的帧丢弃. 所以网络 I/O 其实是网络与服务端(电脑内存)之间的输入与输出 内核 查看内核版本 : ...

  4. .net6&7中如何优雅且高性能的使用Json序列化

    .net中的SourceGenerator让开发者编可以写分析器,在项目代码编译时,分析器分析项目既有的静态代码,允许添加源代码到GeneratorExecutionContext中,一同与既有的代码 ...

  5. 【JVM调优】Day02:CMS的三色标记算法、分区的G1回收器、短时停顿的ZGC回收器

    一.CMS及其三色标记算法 1.核心 标记整个图谱的过程分为多步 多个线程相互工作,才能标记完 标记的算法,JVM虚拟机.go语言使用的都是三色标记算法 2.含义 从那个地方开始,用三种颜色替代 一开 ...

  6. 7-3 停车场管理 (20point(s))

    设有一个可以停放n辆汽车的狭长停车场,它只有一个大门可以供车辆进出.车辆按到达停车场时间的先后次序依次从停车场最里面向大门口处停放 (即最先到达的第一辆车停放在停车场的最里面) .如果停车场已放满n辆 ...

  7. MySQL可视化软件(Navicat)部署与使用

    目录 一:可视化软件(Navicat) 1.什么是可视化软件? 2.什么是Navicat? 二:部署MySQL(Navicat) 1.Navicat连接本地MySQL 2.连接MySQL,输入密码,在 ...

  8. 【JVM】根节点枚举与安全点

    本文已收录至Github,推荐阅读 Java随想录 微信公众号:Java随想录 CSDN: 码农BookSea 转载请在文首注明出处,如发现恶意抄袭/搬运,会动用法律武器维护自己的权益.让我们一起维护 ...

  9. 修改数据时,一直提示"具有 XXX 的 字典管理 已存在(即数据已存在)

    原代码: class DictConfig(models.Model): """ 字典表 """ id = models.AutoField ...

  10. C语言 根据掩码计算网段的起止ip

    原文地址:https://www.yuque.com/docs/share/85a26263-484a-42f6-880b-2b511ae1bd20?# 根据ipv4掩码计算 #include < ...