Contents

Bad Logic

Walkthrough

From the initial README.txt, we learn that KAPE has been run, which is used to find the most interesting artefacts for forensics investigation. A memory dump and a pcap are also available.

Pcap analysis

The capture is very big and takes some time to load. From Statistics > Capture File Properties, we see the capture was run during 7 days and 15h, which explains the big file size:

/images/btlo/bad_logic/ffa1c96a695c2107f650efc46e67bd29.png
Packet capture properties

HTTP traffic

When reviewing HTTP requests, we notice some weird ones from the IP 178.62.72[.]123, like this one:

/images/btlo/bad_logic/f4ffe7360c117384b86533e6b1a06159.png
First malicious IP

It appears that an attacker is exploiting a vulnerability on port 7001 on the host 172.31.4.99 to perform some command execution, in this case a ping to advertyzing.co[.]uk.

According to the user agent, the request is sent from python-requests 2.20.

To better understand the request, we can URL decode it twice using Cyberchef:

/images/btlo/bad_logic/f4fe8c5c9d8f5e19c99a6c91094eb6a0.png
Cyberchef results
What is the malicious domain used by the threat actor?
advertyzing.co[.]uk

By searching the GET request in a search engine, we find some articles about a vulnerability for Oracle WebLogic (CVE-2020-14882).

Which application did the threat actor exploit, what port does this run on and which CVE did the threat actor utilise?
WebLogic,7001,CVE-2020-14882

After the ping, the vulnerability is used again (the attacker must have received the ping on the domain advertyzing.co[.]uk confirming that the code execution worked) to download nc.exe using certutil.exe, a common LOLBins.

The threat actor has made good use of ‘Living off the land’ binaries (LOLBins). Which windows executable did they use to download a malicious file from their server?
Certutil.exe
What was the name of the malicious file they downloaded using this windows executable?
nc.exe

We also find a request for a ncat reverse shell which executes powershell:

/images/btlo/bad_logic/b7fa1fb1318ac476028dc50a71bf1871.png
Reverse shell

We could start by reviewing powershell events retrieved from the KAPE analysis.

By further investigating HTTP requests, the IP 95.181.232.7 is also interacting with the weblogic website a few hours after the initial compromission:

/images/btlo/bad_logic/f91e51059e6853e4635ac590b02935e8.png
Second malicious IP
Confirm the two IP addresses utilized by the threat actor:
178.62.72.123,95.181.232.7

If we review wireshark statistics, those two IPs are among those which interacted a lot with the victim IP.

The IP 178.62.72.123 is the top one which received packets from the victim:

/images/btlo/bad_logic/4cd96a6f5d35c7ceb4f150aa331d01aa.png
Network conversations - Packets received

Whereas the IP 95.181.232.7 is the second one which sent most packets to the victim:

/images/btlo/bad_logic/0aa1a15650565d8bfc699844bad2b690.png
Network conversations - Packets sent

KAPE analysis

The two following directories are related to KAPE:

  • Module_Options: results of programs (for example JLECmd for jump lists) that have been configured to be run when the tool was executed
  • Target_Options: Directory where files and directories are copied based on those specified to be recovered when the tool was executed

As we noticed a reverse shell serving a powershell command line, let’s start by reviewing powershell’s artefacts.

Powershell history

First let’s review the PSRealine command history as mentioned in this article.

In the administrator’s history, we get some interesting command, the tool LaZagne is used to dump credentials:

/images/btlo/bad_logic/43eb315eb7bc9e11f724ddef2715597c.png
Powershell history
What is the name of the password dumping tool used by the threat actor?
laZagne
What is the name of the text file the TA echo'ed out to?
password_extract.txt

KAPE’s live response

By reviewing artefacts found by KAPE in <C:\Users\BTLOTest\Desktop\MD-Artefacts\Module_Options\LiveResponse> directory, we can see dns entries to subdomains related to kryptex[.]org, which is a cryptocurrency miner:

/images/btlo/bad_logic/79327895f0d935dc9d3864a40a0da777.png
DNS cache

In the same directory, we also find scheduled tasks related to this software:

/images/btlo/bad_logic/38a79c174ff7da4c4ecdee41692d21a2.png
Scheduled tasks
The threat actor has used an off-the-shelf cryptominer, what is the name of the executable?
kryptex.exe

We also confirm the IP of the victim from the ipconfig.txt file:

/images/btlo/bad_logic/3ac81ef223e6d60921d952002979239a.png
Ipconfig

Host artefacts

We were able to access artefacts on the host itself because the investigation is done on the compromised host, which won’t likely be the case in a real world investigation. As those files were not recovered, we could have extracted them from the memory dump or find other artefacts that would point to them.

Kryptex

In the configuration file for the cryptocurrency software installed in <C:\Users\Administrator\AppData\Roaming\Kryptex>, we can find an email address which is most likely linked to the threat actor:

/images/btlo/bad_logic/3063464feb2e8d27a4c8b0d387555be4.png
Kryptex configuration file

Oracle Web Logic

According to the pcap analysis, the exploited service is WebLogic, we can review the related files to see if any legitimate files were used by the attacker.

By browsing the related directories in we fin in <C:\Oracle\Middleware\Oracle_Home\user_projects\domains\base_domain\bin> files that have been modified at 3/4/2021, the same date of the attack from the pcap and a different date than other files, which were all modified the last time the 3/1/2021:

/images/btlo/bad_logic/fea23fff44f529a7159138aa6dce27c0.png
Oracle Web Logic modified files

According to Oracle’s documentation, the script startWebLogic.cmd is the startup script for the WebLogic server.

It appears that the attacker added a call to StartWebLogic.bat which then executes StartWebLogic.exe with parameters similar to ncat (these are the only files with a .bat and .exe extension in the directory which is also suspicious):

/images/btlo/bad_logic/99788a541525421b8479b1c525e1a34a.png
startWebLogic.cmd
/images/btlo/bad_logic/ab85dc93d5622bebcdec70e78c3d990a.png
StartWebLogic.bat

If we get the hash of the executable and search it in VirusTotal, the file is recognized as nc.exe.

The threat actor has attempted an unusual way of persisting by editing a key file. Which configuration file have they altered?
startWebLogic.cmd

Memory dump analysis

Unfortunately, as specified in the README.txt, the installed version of Volatility won’t work because the dump is too big.

We can perform some strings analysis on it, but it is more difficult to get the context of the data returned. As the search takes some time, it’s better to do it when you already have some information and you can use specific keywords to have better results.

For example, if we perform a search for “certutil”, as we know it was used as a LOLbin:

/images/btlo/bad_logic/b500cfdbfc059c944b9d9ccfe0973c09.png
Certutil string occurences

We find again that it was used to download nc.exe, but we also see other domain that could be good to further investigate:

/images/btlo/bad_logic/d4a85fa41e82691c439a278099406220.png
Suspicious domain 1
/images/btlo/bad_logic/fca557e71827d6b2f4ae7c2a2bebb0c4.png
Suspicious domain 2

Final Notes

A lot of tools are available for this investigation and I only detailed places where I found interesting information.

For example I searched specific event IDs in logs at: <C:\Users\BTLOTest\Desktop\MD-Artefacts\Target_Options\C\Windows\System32\winevt\logs>, reviewed jump lists at: <C:\Users\BTLOTest\Desktop\MD-Artefacts\Target_Options\C\Users\Administrator\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations>, reviewed registry hives and many other places.

This investigation was a very good learning experience as you have so much places to look into and many tools to try.

This is one of the lab I like to come back to try new things, and if I find new interesting stuff, I will update this write up accordingly.

I hope you enjoyed the read !

Resources