Hide
Hide
Description
I recreated a simulation where a hacker attacked a Exchange server
I have collected the necessary logs and some suspicious processes to support the
investigation process. Use your DFIR skills to answer the following questions:
1. Which service on the server did the hacker exploit?
2. What is the CVE identifier for the vulnerability that the hacker used?
3. What technique did the hacker use to maintain a connection with the system?
4. What is the malicious "file" that the hacker left behind?
5. Can you find the hidden secret with the key to open it?Ex: secret_key
Writeup
When I created this challenge, my goal was to introduce you to a real-world attack scenario
that is increasingly common today. I want everyone to gain a better understanding of how
to detect and defend against such types of attacks.
For a Exchange Server attack, the most critical aspects to consider are the server access
logs, Exchange service access logs, and event logs. Question 1 can be easily tackled if we
have an understanding of the architecture and keep track of the CVEs related to attacks on
this server. This way, we can focus on the Exchange services that are frequently targeted,
such as OWA, EWS, and ECP .... If you are not familiar with these services and the locations
where their logs are stored, you can find a summary of the services and their log storage
locations in the link bellow:
https://cyberpolygon.com/materials/okhota-na-ataki-ms-exchange-chast-1-proxylogon/#:
~:text=encrypting%20server%20data)-,Logs%20and%20Useful%20Events,-The%20source%20
events
In this case, within the EWS logs, we can observe multiple error segments related to
object type casting, with somewhat unusual names like 'SharpMemShell' and 'SystemXamll.'
This suggests that the error is likely associated with a hacker attempting to initialize an
instance of the 'SharpMemShell' class and 'SystemXamll.' However, the server typically
expects to receive an 'IDictionary' object by default.
And with some knowledge of web security, you can figure out that the attacker is exploiting
an insecure deserialization vulnerability.
At this point, it's quite certain that the hacker is exploiting the EWS service, so the answer
would be ews .
2. What is the CVE identifier for the vulnerability that the hacker used?
Once we know that the exploited service is EWS, we will focus on each CVE that has been
used to exploit this service to gather more clues. Searching on Google, easily find two CVEs,
namely CVE-2020-17144 and CVE 2021-42321, although there may be more. Our focus should
remain on the keywords 'ews' and 'deserialization.' However, it appears that the hacker has
deleted the IIS logs, which is a crucial lead for analysis. Fortunately, the process dump files
have been successfully extracted, so our next step will be to investigate these files for any
interesting findings.
The simplest approach is to use 'strings' and 'grep' to search for specific strings within the
PoC code that was used, and here are the results.
3. What technique did the hacker use to maintain a connection with the
system?
To maintain a connection with the server system after the attack, the attacker loaded a
malicious DLL file (based on Peterjson's blog and the publicly available PoC). Therefore, the
answer to this question would be to search for the DLL files loaded by the EWS process.
The content of the DLL file can be easily found by base64 decoding the segments within the
BinaryData tag while removing any bytes based on the DLL's magic byte header.
I used hexed.it
and after that, load the dump.dll to dnSpy, we can find out the malicious "file" is "Xaml.dll"
5. Can you find the hidden secret with the key to open it?Ex: secret_key
This question is related to finding something secret and the key to unlock that secret,
sounding somewhat like an encryption algorithm. After reviewing the source code of this
DLL file, it can be seen that it starts an HTTP listener with port 80 and a path prefix of
/isitdtu/ . It performs base64 decoding, decrypts a string obtained from the POST
parameter isitdtu , then executes and encrypts it, finally base64 encoding and returning it
to the client.
Source of Xaml.dll
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Web;
public Xaml()
{
Thread thread = new Thread(new ThreadStart(Xaml.HttpServerThread));
Thread.Sleep(0);
thread.Start();
}
So we can find out the value of the key used to encrypt/decrypt is md5("to^egopass")[:16]
Finally, we proceed to grep for the isitdtu strings.
=> ISITDTU{CONGRATULATE_YOU_WIN}_5b5135f4fba2e730