Matthew Profile picture
Mar 22, 2023 12 tweets 8 min read Read on X
🐀 AsyncRAT 🐀 - Defeating Obfuscation Using CyberChef

An overview of some advanced CyberChef tricks for decoding malware

[1/12] 🧵

#AsyncRAT #Decoding #CyberChef #Malware Decoding Decimal Values using cyberchefDecoding String Reverse Using CyberchefDecoding Replace Operations Using CyberChefExample of Using Registers and Regex to perform Replace Oper
[2/] First, some links if you wish to follow along.

The Malware File: bazaar.abuse.ch/sample/26c9f29…

Links to CyberChef Recipes:
github.com/embee-research…
[3] Decimal Values:

Some text is converted to decimal to hinder simple text based analysis.

To defeat:
- Subsection - This grabs encoded data without removing the rest of the script
- Regex - Grab the decimal and ignore the "chr" junk
- From Decimal - Decode the decimal Decimal Encoded Values "chr(45)" etc - Prior to De
[4] Decimal Values P2:

- Merge - Removes Subsection - Allowing future operations to apply to the entire script.
- Find/Replace - Remove remaining string concatenation ("+") etc
- Syntax Highlighter - Make the resulting script pretty Decimal Encoded ValuesCyberchef Recipe for Decoding Decimal ValuesBefore and After, Decoding Decimal Values
[5] Reversed Strings P1:

Reversed strings are used to further hinder analysis and evade simple text analysis.

To Defeat:
- Subsection - Grab only the reversed content, including references to the "StrReverse" function.
- Regex - Grab only content between quotes ".*" This... String Reverse (StrReverse) operations used by malware to hiUsing CyberChef to Decode "StrReverse" operations The output of previous cyberchef recipe, with strReverse ope
[6] .. gives us only the reversed string. Ignoring the "StrReverse" component.
- Reverse - Perform the string reverse operation
- Merge - Removes our subsection
- Syntax Highlighter - Make it all look pretty CyberChef Recipe for removing  and decoding StrReverse
[7] String Replace:

Replace operations are used to further obfuscate text.
#Deobfuscation is similar to above

To Defeat:
- Subsection - To retrieve all content related to the replace operation.
- Register - Using the same regex as before, but adds capture groups to...
[8] ... Adds capture groups so that we can group content and create variables for future operations. -
$R0 = Encoded String,$R1 = StringToRemove,$R2 = ReplaceValue) etc.
- Regular Expression - Now that our variables are made, we can use regex to show only the encoded value.
[9] Find/Replace - This allows us to perform the string replace using the previously created variables.
eg (From $R0; Remove all instances of $R1; Then Replace $R1 with the value $R2)

Merge - Remove the subsection
Syntax - Make it look pretty.

Before and After Before and After performing a string replace using CyberChef
[10] More String Replace:

The last encoding is the most simple, and simply uses variables to store strings, which are then concatenated together.

I couldn't find a way to decode this part using only Cyberchef (so let me know if you have a way)
[11] Luckily, this task is well suited for a simple print statement.

This can be achieved in the browser (ideally in a safe VM) after replacing the (&) with a more #javascript friendly (+).

Then pasting the content into the browser console.
[12] We now have the decoded values and can determine (mostly statically) what the malware is trying to achieve.

In this case, the malware script's ultimate goal is to execute a .bat script via #powershell.

Not the most exciting outcome but a cool study into #cyberchef :) Final Decoded Values From AsyncRAT .VBS loaderFinal decoded values

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Matthew

Matthew Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @embee_research

Mar 24
Malware Deobfuscation With DnSpy and CyberChef 👨‍🍳

Let's look at some beginner tips for identifying encrypted data with DnSpy.

We'll then utilise CyberChef to recreate the decryption and obtain the address of the C2 server.

[1/12] 🧵

#malware #cyberchef
Image
Image
[2/] Finding encrypted strings

Config values are often initialised (and decrypted) early in execution. Hence the Entry Point is a great place to begin looking.

(In Dnspy, we can select a loaded file and use "Go To Entry Point")

Image
Image
Image
3/ Identifying Config Values

After locating the entry point, we can begin looking for signs of encrypted or obfuscated values.

The first method "Run" contains suspicious references to “”, as well as Arguments.IP and Arguments.Key StringDecrypt.Read
Image
Read 13 tweets
Jan 2
🔥Lumma Stealer - Manually Unpacking and Extracting C2's 🔥

Let's analyse a Lumma malware sample and manually unpack it with Dnspy and x32dbg.

We'll then leverage Ghidra and x32dbg to locate and decrypt four C2 addresses.

[1/24] 🖊️

#Malwareanalysis #Ghidra


Image
Image
Image
Image
1/ The initial sample can be found on Malware Bazaar

You can download it here if you'd like to follow along

bazaar.abuse.ch/sample/0ee580f…
2/ Checking What Were Up Against

Prior to manual analysis, we can submit the hash on @unpacme. This gives us an idea of how many "layers" of packing are present.

The initial sample is .NET based, but the payload is not. (This means we'll need both Dnspy and #Ghidra)
Image
Image
Read 25 tweets
Dec 30, 2023
How to Increase Your Engagement on Cyber-related Twitter Content ✏️

Tips and tricks learnt from writing about #malware on Twitter for 18 months😄

[1/9]
1/ Optimal Post Structure

Statement -> Explanation -> Conclusion

I've found this general flow is the easiest to create and for readers to follow. It follows the 1-2-1 structure by @Nicolascole77

If you don't yet have a post style/structure, this is a great place to start. Image
2/ Aim for Reposts Over Followers

The highest engagement posts are those that get reshared by large accounts.

You don't need a lot of followers for high engagement, as long as you can get reposted by someone who does. Image
Read 10 tweets
Dec 21, 2023
🔬Defeating Obfuscated .HTA Scripts to Obtain Cobalt Strike Shellcode 🔬

Let's look at Cyberchef, Manual Deobfuscation, Multi-stage script analysis and finally emulation to obtain a decoded C2.

[1/17]


Image
Image
Image
Image
2/ The analysis begins with obfuscated .hta script obtained from Malware Bazaar.

You can obtain the file here if you want to follow along.

bazaar.abuse.ch/sample/2c683d1…
3/ Initial Script Review.

The initial script contains multiple obfuscated strings, a partial powershell command, and a large blob of base64 text.
Image
Image
Read 17 tweets
Dec 20, 2023
🥷Defeating Obfuscated Malware 🥷

Today we take a look at a heavily obfuscated visual basic script containing Shellcode.

We'll use Regex, #Cyberchef and a Text Editor to deobfuscate #malware.

[1/18]


Image
Image
Image
Image
[2/] Initial #Malware Analysis

The initial script contains a mix of obfuscated and readable code.

The readable code contains references to Excel and Wscript. Image
[3/] Ignoring Plaintext

The plaintext code (in this case) suggests "how" the code is executed and not "what" is executed.

For this reason we can usually skip this component and focus on the obfuscated code.
Read 18 tweets
Dec 6, 2023
🐉Manual Shellcode Analysis Using Ghidra and x32dbg 🐉

17 tips for getting started with manual shellcode analysis (no relying on emulation to do the hard work 💪).

#Malware #Ghidra


Image
Image
Image
Image
[2/] Obtaining the Sample

If you want to follow along, you can obtain the sample from #Malware Bazaar using the link below.

bazaar.abuse.ch/sample/26f9955…
[3/] Verifying With Emulation

Prior to analysing with Ghidra or "advanced" tooling, it's a good idea to use an emulator (Like SpeakEasy) for verifying the code functionality.

Now you'll know what to look for in #Ghidra, x32dbg or other tooling. Image
Read 18 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(