Malware Stager Deobfuscation

Malware Stager Deobfuscation

During a recent challenge, I received an obfuscated malware stager that was a PowerShell script that needed investigating. This was my first time tackling de-obfuscation and I'm sure this was an easy sample, because I've seen video of analysts trying to breakdown multi-layer malware and it looks intimidating.?

Sample:?

No alt text provided for this image

If we look at this script, it's clear that it is encoded with base64, but they're also using other elements to obfuscate the script. The { } throughout the malware and the –f key at the bottom is indicative of a PowerShell string.format array. ?

No alt text provided for this image

We can use PowerShell to decipher the order in which to replace {2},{1},{0} with “=”,”P”,”T”. If you’re running Kali you can run PowerShell via pwsh. ?

So, {2} = P, {1} = t, {0} = =?

No alt text provided for this image

After replacing those characters it’s a bit cleaner, but if this is base64, there is still an issue. Base64 only uses alpha-numeric characters and “/” “+”. So, we must remove all of the single quotes.?

Utilizing CyberChef I removed the apostrophes and tried to decode the string, but it was decoding into nonsense.?

No alt text provided for this image

Next, I decided to remove the " ' " and the “+” symbol they were surrounding, followed by decoding the cleaned-up string. It decoded as unreadable data gain, so I ran file against the malware, and it stated that it was a gzip compressed file.?

No alt text provided for this image

I renamed the malware file, malware.gz and then used gzip to decompress it.?

No alt text provided for this image

This gave me the ability to read the obfuscated code and to glean the information needed to finish the challenge.?

No alt text provided for this image

Lessons Learned:?

I will continue to work on my skills so I have the ability to extract data/characters from large strings. I tried to use “cut”, but it proved too difficult and using string.replace in Python kept giving me a “string termination” error. Utilizing regex would probably have been the best bet, but my skills are currently very neophyte.?

?

I would also take care and be very careful when removing or replacing characters in these strings manually, because it can throw off the base64 decoding.?

要查看或添加评论,请登录

Daniel McNally的更多文章

  • Project 1 - DVWA

    Project 1 - DVWA

    During the latest FXBG Hackers meeting, a newcomer attended for the second time. He expressed an interest in…

  • Security Analyst Notes: Things to Remember

    Security Analyst Notes: Things to Remember

    Over the last two years during my training, I've been taking notes along the way on all different topics that have been…

    7 条评论
  • PyScript Domains > 72 Char.

    PyScript Domains > 72 Char.

    Last night I was reading one of the go-to blue team compendiums, Blue Team Handbook, by Don Murdoch and it was going…

    1 条评论
  • Malware Analysis Notes: Putty.exe

    Malware Analysis Notes: Putty.exe

    I finally was able to get back around to working on the PMAT course by, HuskyHacks and TCM Security. These are my notes…

    1 条评论
  • Snort 3 vs MiTM Attacks

    Snort 3 vs MiTM Attacks

    Executive Summary: There are pros and cons when using Snort's Intrusion Prevention and Intrusion Detection System…

  • Manual Log Parsing with Cut, AWK and Python

    Manual Log Parsing with Cut, AWK and Python

    This will be a quick tutorial aimed at people who are infosec newbies or are new to Linux in general that are…

    1 条评论
  • Blue Team CTF: Warzone 1

    Blue Team CTF: Warzone 1

    To continue to work on my ability to parse logs and sniff out possible IOC's, I will be tackling another blue team CTF…

  • Splunk BOTSv3 AWS & WINEvent

    Splunk BOTSv3 AWS & WINEvent

    AWS S3 Bucket Challenge Today I will be finishing up my Splunk course with 2 more blue team CTFs. The first challenge…

    1 条评论
  • Splunk BOTSv3 Web & OneDrive

    Splunk BOTSv3 Web & OneDrive

    The past week I’ve been spending most of my time trying to complete a Splunk learning path to gain an understanding of…

  • CTF: SNORT Basics Pt. 1

    CTF: SNORT Basics Pt. 1

    Today I will be running through a blue team CTF focused on using the IDS/IPS Snort. Snort can be used both passively…

    5 条评论

社区洞察

其他会员也浏览了