Combating control flow flattening in .NET malware

Thursday 29 September 2022, 14:30 - 15:00

Georgy Kucherin (Kaspersky)

It has become increasingly popular for targeted malware developers to create custom sophisticated obfuscators that make use of control flow transformation techniques. One such technique is control flow flattening. It basically rearranges lines of code in a chaotic manner, thus making analysis tedious.

While control flow flattening has previously been researched in the context of C and C++ binaries, virtually no attention has been given to unflattening .NET programs. Furthermore, existing deobfuscation software that removes unflattening in C/C++ programs cannot be applied to .NET binaries. That is because .NET code is compiled not to x86 assembly, but to a virtual bytecode called Common Intermediate Language.

Advanced threat actors favour using control flow flattening to protect their .NET implants. For example, this obfuscation was employed in early versions of the Kazuar backdoor. It has also recently been spotted in DoubleZero, a wiper discovered in March 2022 in Ukraine.

In this research, we detail how to remove control flow flattening from .NET binaries, taking the DoubleZero wiper as an example. To perform unflattening, we modify the source code of de4dot, a popular .NET deobfuscation framework. In the paper, we first explain how to restore DoubleZero’s original control flow. Then, we move from general to specific and demonstrate how to add a custom deobfuscator module to de4dot. Afterwards, we describe how de4dot’s block deobfuscation component comes in handy for implementing the unflattening algorithm. Along the way, we give multiple tips on how to use other de4dot’s features.

The paper is accompanied by extensively commented code of the unflattener. It manages to successfully deobfuscate all DoubleZero’s functions. It is possible to use this code as a basis for creating unflatteners of other .NET malware families.

 


Georgy-Kucherin.jpg

Georgy Kucherin

Georgy Kucherin is a junior researcher at Kaspersky’s Global Research and Analysis Team and a second-year student at Moscow State University. He is passionate about analysis of complex malware and reverse engineering. His previous research includes attribution of the SolarWinds attack and a thorough investigation of the FinSpy commercial spyware.

Back to VB2022 Programme page

Other VB2022 papers

The threat is stronger than the execution: realities of hacktivism in the 2020s

VB2022 paper: The threat is stronger than the execution: the realities of hacktivism in the 2020s

Uncovering a broad criminal ecosystem powered by one of the largest botnets, Glupteba

VB2022 paper: Uncovering a broad criminal ecosystem powered by one of the largest botnets, Glupteba

Zeroing in on XENOTIME: analysis of the entities responsible for the Triton event

VB2022 paper: Zeroing in on XENOTIME: analysis of the entities responsible for the Triton event

Prilex: the pricey prickle credit card complex

VB2022 paper: Prilex: the pricey prickle credit card complex

Exploit archaeology: a forensic history of in-the-wild NSO Group exploits

VB2022 paper: Exploit archaeology: a forensic history of in-the-wild NSO Group exploits

Hunting the Android/BianLian botnet

VB2022 paper: Hunting the Android/BianLian botnet

EvilPlayout: attack against Iran’s state TV and radio broadcaster

VB2022 paper: EvilPlayout: attack against Iran’s state TV and radio broadcaster

Russian wipers in the cyberwar against Ukraine

VB2022 paper: Russian wipers in the cyberwar against Ukraine

War of the worlds: a study in a ransomware IR learnings & victories

VB2022 paper: War of the worlds: a study in a ransomware IR learnings & victories

Script kiddy on the deep & dark web: looks serious? But empty suit!

VB2022 presentation: Script kiddy on the deep & dark web: looks serious? But empty suit!

SHAREM: shellcode analysis framework with emulation, a disassember, and timeless debugging

VB2022 paper: SHAREM: shellcode analysis framework with emulation, a disassember, and timeless debugging

Combating control flow flattening in .NET malware

VB2022 paper: Combating control flow flattening in .NET malware

(Encryption) time flies when you're having fun: the case of the exotic BlackCat ransomware

VB2022 paper: (Encryption) time flies when you're having fun: the case of the exotic BlackCat ransomware

Sha Zhu Pan: cocktail of cryptocurrency, social engineering and fake apps targeting Android and iPhone users

VB2022 paper: Sha Zhu Pan: cocktail of cryptocurrency, social engineering and fake apps targeting Android and iPhone users

Web3 + scams = it's a match!

VB2022 paper: Web3 + scams = it's a match!

Operation Dragon Castling: suspected APT group hijacks WPS Office updater to target East Asian betting companies

VB2022 paper: Operation Dragon Castling: suspected APT group hijacks WPS Office updater to target East Asian betting companies

Scarcuft's information-gathering activities

VB2022 paper: Scarcuft's information-gathering activities

Unmasking WindTape

VB2022 paper: Unmasking WindTape

Tracking the entire iceberg - long-term APT malware C2 protocol emulation and scanning

VB2022 paper: Tracking the entire iceberg - long-term APT malware C2 protocol emulation and scanning

Lazarus & BYOVD: evil to the Windows core

VB2022 paper: Lazarus & BYOVD: evil to the Windows core

Keeping up with the Emotets: configuration extraction and analysis

VB2022 paper: Keeping up with the Emotets: configuration extraction and analysis

Exploiting COVID-19: how threat actors hijacked a pandemic

VB2022 paper: Exploiting COVID-19: how threat actors hijacked a pandemic

The long arm of the prisoner: social engineering from Kenyan prisons

VB2022 paper: The long arm of the prisoner: social engineering from Kenyan prisons

CTA TIPS "What if"

VB2022 CTA Threat Intelligence Practitioners' Summit presentation: "What if"

CTA TIPS Finding IOCs in unexpected places

VB2022 CTA Threat Intelligence Practitioners' Summit presentation: Finding IOCs in unexpected places

CTA TIPS Threat intelligence sharing in practice – lessons learned from the Cyber Threat Alliance

VB2022 CTA Threat Intelligence Practitioners' Summit presentation: Threat intelligence sharing in practice – lessons learned…

CTA TIPS A Vulcan mindmeld: from your mind to my mind

VB2022 CTA Threat Intelligence Practitioners' Summit presentation: A Vulcan mindmeld: from your mind to my mind

CTA TIPS From threat intelligence to active defence based on Industroyer.V2

VB2022 CTA Threat Intelligence Practitioners' Summit presentation: From threat intelligence to active defence based on…

CTA TIPS Fireside chat: IMAGINE - changing the narrative in threat intelligence collaboration

VB2022 CTA Threat Intelligence Practitioners' Summit presentation: Fireside chat: IMAGINE - changing the narrative in threat…

CTA TIPS Enhanced threat intelligence for runtime detection

VB2022 CTA Threat Intelligence Practitioners' Summit presentation: Enhanced CTI with runtime memory forensics

CTA TIPS Tips for vetting and generating value in automated TI

VB2022 CTA Threat Intelligence Practitioners' Summit presentation: Tips for vetting and generating value in automated TI

CTA TIPS Closing keynote

VB2022 CTA Threat Intelligence Practitioners' Summit presentation: Closing keynote

The ATT&CK DarkHotel playbook: hunt and breach & attack simulation

VB2022 paper: The ATT&CK DarkHotel playbook: hunt and breach & attack simulation

Building resilience through threat intelligence (partner presentation)

VB2022 presentation: Building resilience through threat intelligence (partner presentation)

Workshop: Modern threat hunting

VB2022 workshop led by VirusTotal

Keynote: Why are you telling me this?

VB2022 keynote address: Why are you telling me this?

You OTA know: combating malicious Android system updaters

VB2022 paper: You OTA know: combating malicious Android system updaters

Creepy things that glow in the dark: a deep look at POLONIUM's undocumented tools

VB2022 paper: Creepy things that glow in the dark: a deep look at POLONIUM's undocumented tools

Lessons learned from 6 LAPSUS$ incident (responses)

VB2022 paper: Lessons learned from 6 LAPSUS$ incident (responses)

Your own personal Panda: inside the CVE-2022-1040 attack

VB2022 paper: Your own personal Panda: inside the CVE-2022-1040 attack

Operation MINAZUKI: underwater invasive espionage

VB2022 paper: Operation MINAZUKI: underwater invasive espionage

Good-bye macros: peeking into a threat landscape without Office macros

VB2022 paper: Good-bye macros: peeking into a threat landscape without Office macros

The impact of mobile networks on the 2022 Russian invasion of Ukraine

VB2022 paper: The impact of mobile networks on the 2022 Russian invasion of Ukraine

Not Safe for Windows (NSFW): a China-based threat with a lot to say

VB2022 paper: Not Safe for Windows (NSFW): a China-based threat with a lot to say

An inconvenient truth about Apple security updates

VB2022 paper: An inconvenient truth about Apple security updates

We have placed cookies on your device in order to improve the functionality of this site, as outlined in our cookies policy. However, you may delete and block all cookies from this site and your use of the site will be unaffected. By continuing to browse this site, you are agreeing to Virus Bulletin's use of data as outlined in our privacy policy.