In this writeup, I will show you how to write your own DLL to intercept an API function and receive user credentials entered into the application. Having implemented the DLL in the target process, we read the credentials and move on to the new user. Then, using a chain of misconfigured access lists, we gain full control of the domain. But first, let’s exploit the LDAP injection and upload a web shell to the server.
Our goal is to obtain superuser rights on the Analysis machine from the training site Hack The Box. The task level is difficult.
warning
It is recommended to connect to machines with HTB only via VPN. Do not do this from computers that contain data that is important to you, as you will end up on a shared network with other participants.
Intelligence service
Port scanning
Add the machine's IP address to /:
10.10.11.250 analysis.htb
And start scanning the ports.
Help: Port Scanning
Port scanning is the standard first step in any attack. It allows the attacker to know which services on the host are accepting the connection. Based on this information, the next step to obtain an entry point is selected.
The most famous scanning tool is Nmap. You can improve the results of its work using the following script:
#!/bin/bash
ports=$(nmap -p- --min-rate=500 $1 | grep ^(0-9) | cut -d '/' -f 1 | tr 'n' ',' | sed s/,$//)
nmap -p$ports -A $1
It works in two stages. The first one performs a regular quick scan, the second one performs a more thorough scan using the available scripts (option -A).
The script found many open ports, which is typical for Windows:
- 53 – DNS;
- 80 (HTTP) – Microsoft IIS/10.0 web server;
- 88 – Kerberos;
- 135 – remote procedure call service (Microsoft RPC);
- 139 – NetBIOS session service, NetLogon;
- 389 – LDAP;
- 445 – SMB;
- 464 – Kerberos password change service;
- 593 (HTTP-RPC-EPMAP) – used in DCOM and MS Exchange services;
- 636 – LDAP with SSL or TLS encryption;
- 3268 (LDAP) – to access the Global Catalog from the client to the controller;
- 3269 (LDAPS) – to access the Global Catalog from the client to the controller via a secure connection;
- 3306 – MySQL DBMS;
- 5985 – WinRM remote management service;
- 9389 – AD DS Web Services.
There is no Null session vulnerability on SMB, so we go straight to the web server.

Point of entry
We couldn’t find anything interesting on the site, so let’s start searching for hidden files and directories.
Help: web crawling with feroxbuster
One of the first steps when testing the security of a web application is to scan directories using a brute-force approach to find hidden information and functions that are not available to ordinary visitors. To do this you can use programs like dirsearch, DIRB or ffuf. I prefer feroxbuster.
When starting, specify the following parameters:
-u— URL;-w– dictionary (I use dictionaries from the set SecLists);-t— number of threads;-d— scanning depth.
Set all the necessary parameters and start scanning:
feroxbuster -u http://analysis.htb/ -w directory_2.3_medium_lowercase.txt -d 1 -t 256