Compiled
Recon
nmap_scan.log
.----. .-. .-. .----..---. .----. .---. .--. .-. .-.
| {} }| { } |{ {__ {_ _}{ {__ / ___} / {} \ | `| |
| .-. \| {_} |.-._} } | | .-._} }\ }/ /\ \| |\ |
`-' `-'`-----'`----' `-' `----' `---' `-' `-'`-' `-'
The Modern Day Port Scanner.
________________________________________
: http://discord.skerritt.blog :
: https://github.com/RustScan/RustScan :
--------------------------------------
😵 https://admin.tryhackme.com
[~] The config file is expected to be at "/home/rustscan/.rustscan.toml"
[~] Automatically increasing ulimit value to 5000.
Open 10.10.11.26:3000
Open 10.10.11.26:5000
Open 10.10.11.26:5985
Open 10.10.11.26:7680
[~] Starting Script(s)
[>] Running script "nmap -vvv -p {{port}} {{ip}} -vvv -sV -sC -Pn" on ip 10.10.11.26
Depending on the complexity of the script, results may take some time to appear.
Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times may be slower.
[~] Starting Nmap 7.93 ( https://nmap.org ) at 2024-07-28 19:24 UTC
NSE: Loaded 155 scripts for scanning.
NSE: Script Pre-scanning.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 19:24
Completed NSE at 19:24, 0.00s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 19:24
Completed NSE at 19:24, 0.00s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 19:24
Completed NSE at 19:24, 0.00s elapsed
Initiating Parallel DNS resolution of 1 host. at 19:24
Completed Parallel DNS resolution of 1 host. at 19:24, 0.04s elapsed
DNS resolution of 1 IPs took 0.04s. Mode: Async [#: 2, OK: 0, NX: 1, DR: 0, SF: 0, TR: 1, CN: 0]
Initiating Connect Scan at 19:24
Scanning 10.10.11.26 [4 ports]
Discovered open port 5985/tcp on 10.10.11.26
Discovered open port 3000/tcp on 10.10.11.26
Discovered open port 5000/tcp on 10.10.11.26
Discovered open port 7680/tcp on 10.10.11.26
Completed Connect Scan at 19:24, 0.08s elapsed (4 total ports)
Initiating Service scan at 19:24
Scanning 4 services on 10.10.11.26
Service scan Timing: About 50.00% done; ETC: 19:25 (0:00:50 remaining)
Service scan Timing: About 75.00% done; ETC: 19:26 (0:00:32 remaining)
Completed Service scan at 19:25, 98.83s elapsed (4 services on 1 host)
NSE: Script scanning 10.10.11.26.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 19:25
Completed NSE at 19:25, 5.20s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 19:25
Completed NSE at 19:25, 1.11s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 19:25
Completed NSE at 19:25, 0.00s elapsed
Nmap scan report for 10.10.11.26
Host is up, received user-set (0.079s latency).
Scanned at 2024-07-28 19:24:07 UTC for 106s
PORT STATE SERVICE REASON VERSION
3000/tcp open ppp? syn-ack
| fingerprint-strings:
| GenericLines, Help, RTSPRequest:
| HTTP/1.1 400 Bad Request
| Content-Type: text/plain; charset=utf-8
| Connection: close
| Request
| GetRequest:
| HTTP/1.0 200 OK
| Cache-Control: max-age=0, private, must-revalidate, no-transform
| Content-Type: text/html; charset=utf-8
| Set-Cookie: i_like_gitea=815377d51352f4b6; Path=/; HttpOnly; SameSite=Lax
| Set-Cookie: _csrf=4MohAr909PqaiS7QWFYKqQSeWCg6MTcyMjE5NDY1MzY4MTQ3NjUwMA; Path=/; Max-Age=86400; HttpOnly; SameSite=Lax
| X-Frame-Options: SAMEORIGIN
| Date: Sun, 28 Jul 2024 19:24:13 GMT
| <!DOCTYPE html>
| <html lang="en-US" class="theme-arc-green">
| <head>
| <meta name="viewport" content="width=device-width, initial-scale=1">
| <title>Git</title>
| <link rel="manifest" href="data:application/json;base64,eyJuYW1lIjoiR2l0Iiwic2hvcnRfbmFtZSI6IkdpdCIsInN0YXJ0X3VybCI6Imh0dHA6Ly9naXRlYS5jb21waWxlZC5odGI6MzAwMC8iLCJpY29ucyI6W3sic3JjIjoiaHR0cDovL2dpdGVhLmNvbXBpbGVkLmh0YjozMDAwL2Fzc2V0cy9pbWcvbG9nby5wbmciLCJ0eXBlIjoiaW1hZ2UvcG5nIiwic2l6ZXMiOiI1MTJ4NTEyIn0seyJzcmMiOiJodHRwOi8vZ2l0ZWEuY29tcGlsZWQuaHRiOjMwMDA
| HTTPOptions:
| HTTP/1.0 405 Method Not Allowed
| Allow: HEAD
| Allow: GET
| Cache-Control: max-age=0, private, must-revalidate, no-transform
| Set-Cookie: i_like_gitea=bdf03632a610e1db; Path=/; HttpOnly; SameSite=Lax
| Set-Cookie: _csrf=rDK7F0Pl67xeAlHlmxNsic5G-Xo6MTcyMjE5NDY2MTI5MjcwOTQwMA; Path=/; Max-Age=86400; HttpOnly; SameSite=Lax
| X-Frame-Options: SAMEORIGIN
| Date: Sun, 28 Jul 2024 19:24:21 GMT
|_ Content-Length: 0
5000/tcp open upnp? syn-ack
| fingerprint-strings:
| GetRequest:
| HTTP/1.1 200 OK
| Server: Werkzeug/3.0.3 Python/3.12.3
| Date: Sun, 28 Jul 2024 19:24:13 GMT
| Content-Type: text/html; charset=utf-8
| Content-Length: 5234
| Connection: close
| <!DOCTYPE html>
| <html lang="en">
| <head>
| <meta charset="UTF-8">
| <meta name="viewport" content="width=device-width, initial-scale=1.0">
| <title>Compiled - Code Compiling Services</title>
| <!-- Bootstrap CSS -->
| <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
| <!-- Custom CSS -->
| <style>
| your custom CSS here */
| body {
| font-family: 'Ubuntu Mono', monospace;
| background-color: #272822;
| color: #ddd;
| .jumbotron {
| background-color: #1e1e1e;
| color: #fff;
| padding: 100px 20px;
| margin-bottom: 0;
| .services {
| RTSPRequest:
| <!DOCTYPE HTML>
| <html lang="en">
| <head>
| <meta charset="utf-8">
| <title>Error response</title>
| </head>
| <body>
| <h1>Error response</h1>
| <p>Error code: 400</p>
| <p>Message: Bad request version ('RTSP/1.0').</p>
| <p>Error code explanation: 400 - Bad request syntax or unsupported method.</p>
| </body>
|_ </html>
5985/tcp open http syn-ack Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
7680/tcp open pando-pub? syn-ack
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
NSE: Script Post-scanning.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 19:25
Completed NSE at 19:25, 0.00s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 19:25
Completed NSE at 19:25, 0.00s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 19:25
Completed NSE at 19:25, 0.00s elapsed
Read data files from: /usr/bin/../share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 108.49 secondsGitea (3000)

Seems like we have access to source code of webapp on port 5000?

Great, that does seem to be the case. But the exploit will need Visual Studio :/
Gitea creds: test02:test02@compilation.htb:test02test02
Users:

HTTP (5000)
As we saw in the code we are able to send git repository link, it will get cloned and it will get compiled, after that ???
After some trial and error I decided to review the request (should have been the first thing!)
The request took like 1-2minute to arrive.
Note from the future:
READ THE FUCKING GIVEN FILES

Searching for git version: Security Advisory 2024-046: Multiple Vulnerabilities in Git
The vulnerability
CVE-2024-32002, with a CVSS score of 9.1, could allow a remote attacker to execute code on the affected device. To do so, an attacker would need to craft repositories with submodules in a way that exploits a bug in Git whereby it can be fooled into writing files not into the submodule's worktree but into a.git/directory. This allows writing a hook that will be executed while the clone operation is still running, giving the user no opportunity to inspect the code that is being executed.The vulnerability
CVE-2024-32004, with a CVSS score of 8.2, could allow an attacker, on multi-user machines, to create a local repository that appears as a partial clone that is missing an object. Then, when this repository is cloned, it causes Git to execute arbitrary code with the full permissions of the user performing the clone.The vulnerability
CVE-2024-32465, with a CVSS score of 7.4, could allow an attacker to bypass protections for cloning untrusted repositories. While this vulnerability has been covered in CVE-2024-32004, there are circumstances where the fixes for CVE-2024-32004 are not enough, e.g., when obtaining a.zipfile containing a full copy of a Git repository, it should not be trusted by default to be safe, as e.g., hooks could be configured to run within the context of that repository.
PoC: CVE-2024-32002: Exploiting Git RCE via git clone Blog: Exploiting CVE-2024-32002: RCE via git clone
Reverse Shell (Richard)
After some brainfuckery I rewrote script a bit and managed to get shell!
You need to create repositories on Gitea, first for hook and second for exploit (captain). hooked repo is actual exploit, which the app does for you.
TL;DR => Create repositories -> Run script -> Send captain git link to webapp -> wait few seconds -> profit
Oddly enough we are in bash, even tho I triggered powershell reverse shell... hmmm...
Information about user:
Winpeas:
Gitea (Internal)
Gitea configuration:
The Gitea has a database at C:\Program Files\gitea\data\gitea.db, I upgraded the shell to ConPtyShell so I was able to open HTTP server with python and exfiltrate file. Interesting table is user which contains user passwords:

We already have richard user and from linpeas enumeration he can't do much. emily is another user on system and we should try targeting her.
Practical Cryptography for Developers: https://cryptobook.nakov.com/mac-and-key-derivation/pbkdf2
Privilege Escalation (Emily)
Crack the password:
Luckily the password was easily found. (Use god level encryption methods, but users use weak ass passwords? EMOTIONAL DAMAGE! HumanOS do be trippy)
User.txt
Privilege Escalation (Administrator)
Upload and run winpeas again. During enumeration phase script died due to NFS Export Files? Considering the name of box it's worth looking into.

Get version of VS: (src)
Dotnet version:
Check the directory pointed by winpeas
After following some conversations it turns out root privilege escalation need CVE.
Microsoft » Visual Studio : Security Vulnerabilities, CVEs
CVE-2024-38081 was first choice as it was Elevation of Privilege Vulnerability, but description of this CVE was garbage! The only valid description I found was Defused > CVE-2024-38081
Next was CVE-2024-20656 which has beautiful post explaining everything in details: mdsec > CVE-2024-20656 – Local Privilege Escalation in the VSStandardCollectorService150 Service, and there's also PoC: https://github.com/Wh04m1001/CVE-2024-20656
Richard didn't have ability to query VSStandardCollectorService150, but Emily does:
Find the VSDiagnostics.exe full path and update path in PoC
Make relevant changes:

Note: Make sure to change build to Release mode! Debug kept failing...
Root.txt
etc
Hashdump
Root scripts
Last updated