Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018...

138
Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher

Transcript of Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018...

Page 1: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Visiting the snake nestRecon Brussels 2018

Jean-Ian Boutin | Senior Malware Researcher

Matthieu Faou | Malware Researcher

Page 2: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Jean-Ian BoutinSenior Malware Researcher

Matthieu FaouMalware Researcher

@jiboutin @matthieu_faou

Page 3: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Agenda

1. Introduction

2. Infection Vectors

3. First Stages

4. Advanced First Stages

5. Second Stages

6. Infrastructure

7. Conclusion

Page 4: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Introduction

Page 5: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian
Page 6: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian
Page 7: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian
Page 8: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian
Page 9: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Is ESET doing attribution?

Page 10: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Turla in short

•One of the oldest espionage group

•Targets includes governments, government officials, diplomats, …

•Very large toolset targeting all major platforms

Page 11: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Infection Vectors

Page 12: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Overview

•Wateringhole

•Spearphishing

Page 13: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Watering Hole

•Planting scripts in targets’ favs websitesURL (past campaigns) Notes

http://www.namibianembassyusa.org Namibia Embassy - USA

http://www.avsa.org African Violet Societa of America

http://www.zambiaembassy.org Zambian Embassy - USA

http://russianembassy.org Russian Embassy - USA

http://au.int African Union

http://mfa.gov.kg Ministry of Foreign Affairs – Kyrgyzstan

http://mfa.uz Ministry of Foreign Affairs - Uzbekistan

Page 14: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Script Injection

1st level C&C

mentalhealthcheck.net

drivers.epsoncorp.com

rss.nbcpost.com

static.travelclothes.org

msgcollection.com

Page 15: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Script Injection

1st level C&C

mentalhealthcheck.net

drivers.epsoncorp.com

rss.nbcpost.com

static.travelclothes.org

msgcollection.com

Page 16: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Script Injection

1st level C&C

mentalhealthcheck.net

drivers.epsoncorp.com

rss.nbcpost.com

static.travelclothes.org

msgcollection.com

Page 17: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

PluginDetect

•Fingerprinting potential target through JS

Page 18: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Browser Extension

Page 19: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

C&C fetching

• Computes comments checksum

• Regular expression applied '(?:\\u200d)(?:#|@)?(\\w)'

• https://bitly.com/2kdhuHX

Page 20: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

C&C fetching

• Computes comments checksum

• Regular expression applied '(?:\\u200d)(?:#|@)?(\\w)'

• https://bitly.com/2kdhuHX

Page 21: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

•A bit disappointing that this one was not used…

Page 22: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian
Page 23: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Mosquito

Page 24: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Overview

•Campaign running since at least July 2016

• Infection vector is a fake flash installer

• Downloaded from http://admdownload.adobe.com *

•Use either a Win32 or a JScript backdoor

* We believe Adobe was not compromised

Page 25: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Tracing the infection chain

Page 26: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Something weird is happening on the network

Page 27: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Possible interception points

Page 28: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

During the installation…

http://get.adobe.com/stats/AbfFcBebD/q=<base64-encoded data>

Page 29: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Information exfiltrated to get.adobe.com over HTTP

Page 30: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian
Page 31: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

OSX/Snake

Page 32: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

OSX/Snake

Page 33: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

It even tricked researchers!

Page 34: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

1st Stages

Page 35: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Many have been documented

•Culex

•Tavdig

•Skipper

•Kopiluwak

•…

Page 36: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Tavdig/Wipbot

Page 37: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Tavdig

• (Older) backdoor used to assess target usefulness

•Can execute command, modify backdoor configuration, download additional files, etc

•Dropped through watering hole or spearphishing(old PDF CVE and macros)

Page 38: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Overall Architecture

•Used for• System fingerprinting

• OS version

• Computer name

• Current user name

• Local groups

• System directory

• System language, user language, timezone, uptime, etc

• Backdoor (upload/download file, execute, etc)

Page 39: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Different Versions

•Observations based on samples analyzedVersion Sample sightings Differences

A October 2013 – February 2014 • N/A

B April 2014 – July 2014 • Introduction of macro based Word dropper• Introduction of the two steps injection• Introduction of shell_traywnd injection trick

C September 2015 – November 2015 • Introduction of code obfuscation through “this” pointer• Introduction of list of injectable processes instead of just

iexplore.exe

Page 40: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Version C process list

•Hash-based process name search

•Crackable through John the Ripper

icq.exe msimn.exe opera.exe

chrome.exe pidgin.exe firefox.exe

outlook.exe iexplore.exe jusched.exe

browser.exe icqlite.exe adobearm.exe

adobeupdater.exe

Page 41: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Tavdig word attachment

•Malicious macro embedded in document

•Macro decrypts payload and launches it

Page 42: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Tavdig word attachment

•Malicious macro embedded in document

•Macro decrypts payload and launches it

File size

Page 43: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Tavdig word attachment

•Malicious macro embedded in document

•Macro decrypts payload and launches it

Checksum

Page 44: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Skipper

Page 45: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Skipper

•Minimal backdoor used against governmental and diplomatic institutions since at least 2014

•Can execute commands, ex-filtrate files and download additional malware

•Delivered in malicious macros, JS attachments

Page 46: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Skipper vs. Tavdig

Page 47: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Skipper vs. Tavdig

Page 48: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Skipper vs. Tavdig

Page 49: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Skipper Development

• C:\Users\admin\Documents\Visual Studio 2012\Projects\dws\x64\Release\

GetPidByProcessName_x64.pdb

• C:\Users\work4\Documents\Visual Studio 2012\Projects\KOTEL 24.11.16 No COOKIE

No STORAGE only

BODY\KOTEL_2.1\x64\Release\

GetPidByProcessName_x64.pdb

Page 50: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Skipper Development

• C:\Users\admin\Documents\Visual Studio 2012\Projects\dws\x64\Release\

GetPidByProcessName_x64.pdb

• C:\Users\work4\Documents\Visual Studio 2012\Projects\KOTEL 24.11.16 No COOKIE

No STORAGE only

BODY\KOTEL_2.1\x64\Release\

GetPidByProcessName_x64.pdb

Page 51: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Skipper email attachment

•SECTION_INTERNET-NOTICE_TO_ALL_USERS_13-05-2016.pdf.js

Page 52: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

WinRAR archive content

Loader

Process Injection

C&C Comm

Page 53: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Skipper Misc

• Implements a bunch of anti-emulation tricks

Page 54: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Skipper Misc

• Implements a bunch of anti-emulation tricks

Page 55: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Skipper Misc

• Implements a bunch of anti-emulation tricks

Page 56: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Skipper Misc

• Implements a bunch of anti-emulation tricks

Page 57: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Skipper Misc

• Implements a bunch of anti-emulation tricks

Page 58: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian
Page 59: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Misc – OPSEC failure

•Operators use Vim!!

• https://[C&C server]/rss.php~

Page 60: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Advanced 1st stages

Image credit: SpaceX

Page 61: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Mosquito

Page 62: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Win32 Mosquito

•1st or 2nd stage (Skipper)

•Deployed in Eastern Europe on diplomats’ machines

•Uses a custom packer

Page 63: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Packer – Opaque predicates

Page 64: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Packer – Anti-sandbox/emulation

•Call to SetupDiGetClassDevs(0,0,0,0xFFFFFFFF)

•Last parameter value is undocumented

•Expect 0xE000021A as return value

Page 65: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Components

Page 66: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Components

Backdoor

Page 67: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Components

BackdoorLoader

Page 68: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Components

BackdoorLoader

Encrypted log file

Page 69: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Persistence 1/2

•CLSID hijacking• Ex: Ntshrui.dll

Page 70: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Persistence 2/2

•Create a new admin account: HelpAssistant

• Enable remote administrative actions for this user

•Maybe used to spy or regain control if the backdoor is

deleted.

Page 71: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Where are you export table?

Page 72: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Export table patching

Page 73: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

I’m here!

Page 74: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Encryption

•Data is xored with a generated key•No, I won’t show you the xor loop :D

•Generation algorithm looks like BlumBlumShub• Takes a key and a modulo to generate a bytes stream

Page 75: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Network communications

•C&C• HTTPs

• URI: /scripts/m/query.php?id=<base64 data>

• SATCOM IP addresses and Cloudflare

Page 76: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Network communications

•C&C• HTTPs

• URI: /scripts/m/query.php?id=<base64 data>

• SATCOM IP addresses and Cloudflare

•Encrypted data in:• GET parameter (id)

• Cookie

• POST

Page 77: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Backdoor functions

•Download & execute additional files

•Launch a process

•Delete a file

•Exfiltrate a file

•Add/Delete a C&C server

Page 78: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Mosquito vs ComRAT

•Encryption algorithms are different

•Log structures are different

•Both use CLSID hijacking

•Overlap in the network infrastructure

•Some similarities in the code

Page 79: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Second Stages

Image credit: SpaceX

Page 80: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Advanced Functionalities

•Second stages implement similar concepts to stay persistent and hidden on the system

•They are meant to stay undected as long as possible

Page 81: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Carbon/Cobra

Page 82: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Overview

•Evolution of the previous rootkit

•Sophisticated backdoor

•Receive and dispatch tasks from other nodes

Page 83: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Architecture

•Dropper

•Loader

•Orchestrator

•Communication DLL

Page 84: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Development Timeline

Compilation date Orchestrator version Communication library version

2014-02-26 3.71 3.62

2016-02-02 3.77 4.00

2016-03-17 3.79 4.01

2016-03-24 3.79 4.01

2016-04-01 3.79 4.03

2016-08-30 3.81 ????

2016-10-05 3.81 ????

2016-10-21 3.81 ????

Page 85: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

C&C Communication

•Several steps are taken before beaconing out• Check for network

sniffers

• First GET request to root page of C&C

• Real request is made

Page 86: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

C&C Communication

•Data that should be sent to the C&C server is written to a file• Each blob is encrypted

with CAST-128

• extra 3DES encryption is configurable

Page 87: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Tasks

•Tasks are retrieved from a webpage

•Once decrypted, the tasks are added to a queue

Page 88: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Tasks

•Tasks are retrieved from a webpage

•Once decrypted, the tasks are added to a queue

Page 89: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Named pipe Communications

•Example of communication between modules

Page 90: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Named pipe Communications

•Tasks can be forwarded to another node

Page 91: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Named pipe Communications

•Tasks can be forwarded to another node

Page 92: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Named pipe Communications

•Tasks can be forwarded to another node

Page 93: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Named pipe Communications

•Tasks can be forwarded to another node

Page 94: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Named pipe Communications

•Tasks can be forwarded to another node

Page 95: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Task configuration file

• [CONFIG]•NAME (“cmd.exe” by default)

• ARG

• RESULT (“stdout” by default)

• COMPRESSION (“yes” by default)

• DELETE (“no” by default)

Page 96: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Kazuar

Page 97: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Overview

• .NET backdoor

•Crossplatform

•Similar in architecture to Carbon• Plugin support

•Working directory

• Configuration file

• Log file

• […]

Page 98: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

ConfuserEx

•LZMA code compression

•Anti debug

•Control flow obfuscation

•Strings obfuscation

Page 99: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

ConfuserEx

•LZMA code compression

•Anti debug

•Control flow obfuscation

•Strings obfuscation

Page 100: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Gazer/White Bear

https://chocolate80y.deviantart.com/art/bear-snake-149185270

Page 101: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Overview

•The most recent 2nd stage backdoor

•Similar architecture to the previously discussed backdoors

Page 102: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Gazer Architecture

Page 103: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Gazer Architecture

Page 104: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Gazer Architecture

Page 105: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Process injection list

•Standard ones:• iexplore.exe

• firefox.exe

• outlook.exe

• chrome.exe

• browser.exe

• opera.exe

• safari.exe

•Custom ones:• osoupd.exe

• acrotray.exe

• UpdaterUI.exe

• dropbox.exe

• onedrive.exe

Page 106: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Process injection list

•Standard ones:• iexplore.exe

• firefox.exe

• outlook.exe

• chrome.exe

• browser.exe

• opera.exe

• safari.exe

•Custom ones:• osoupd.exe

• acrotray.exe

• UpdaterUI.exe

• dropbox.exe

• onedrive.exe

Page 107: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Skipper relationship

•Seen in tandem

•Usage of code signing certificates

•We have seen Gazer being installed 24 hours after initial Skipper infection

Page 108: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

RunTime Type Information - RTTI

•C++ class introspection (dynamic_cast, typeid, exception dispatcher) requires additional information to be stored in binary

•Gazer has this information. We can recover• Virtual Function Table (VFT)

• Class names

• Base classes

•Bonus: some binaries included function names

Page 109: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

RunTime Type Information - RTTI

•Looking for “.?AV” strings

Page 110: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Similarities exposed

Page 111: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Working directory similarities - Carbon

Page 112: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Working directory similarities - Kazuar

Page 113: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Working directory similarities - Kazuar

md5('log') XOR key

Page 114: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Working directory similarities - Gazer

• Moved to registry• %RootStoragePath%\{119D263D-68FC-1942-3CA3-46B23FA652A0}

• Object ID: a unique ID to identify the victim

• %RootStoragePath%\{1DC12691-2B24-2265-435D-735D3B118A70}

• Task Queue: linked list of tasks to be executed

• %RootStoragePath%\{28E74BDA-4327-31B0-17B9-56A66A818C1D}

• Plugins

• %RootStoragePath%\{31AC34A1-2DE2-36AC-1F6E-86F43772841F}

• Communication Module: the DLL that communicates with the C&C server

• %RootStoragePath%\{3CDC155D-398A-646E-1021-23047D9B4366}

• Autorun: the persistency method

Page 115: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Logs - Carbon

•Encrypted with CAST-128

•Format: Date|Time|Object-Id|Source|Mesage

Page 116: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Logs - Kazuar

•Encrypted with AES-256-CBC

•Format: process_name [PID]: message

Page 117: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Logs - Gazer

•Encrypted with 3DES

•Format: Hour:Min:Sec:Ms|[log ID] [log]

Page 118: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Configuration items – Carbon/Kazuar/Gazer

•Processes where to inject 3rd stage

•Last C&C contact time

•C&C list

•Victim ID

•Frequency and time of tasks execution

Page 119: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Configuration file – Carbon/Kazuar/Gazer

•Processes where to inject 3rd stage

•Last C&C contact time

•C&C list

•Victim ID

•Frequency and time of tasks execution

Page 120: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Interlude -Metasm

Page 121: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Leverage Metasm to dump encrypted data

•Custom RSA implementation

•Unable to decrypt data with standard libraries

•Why not use directly Gazer code?

Page 122: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Metasm

•Assembler / Disassembler / Compiler / Debugger

Page 123: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Metasm

•Assembler / Disassembler / Compiler / Debugger

•Scriptable in Ruby

Page 124: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Metasm

•Assembler / Disassembler / Compiler / Debugger

•Scriptable in Ruby

Page 125: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Metasm

•Assembler / Disassembler / Compiler / Debugger

•Scriptable in Ruby

•https://github.com/jjyg/metasm

Page 126: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Script

1. Put breakpoints on specific addresses

2. Debug the Gazer sample

3. Dump unencrypted data

Page 127: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Script

https://github.com/eset/malware-research/tree/master/turla/gazer_util.rb

Page 128: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Infrastructure

Page 129: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

First layer C&C server

Page 130: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

SATCOM Infrastructure

•Hide real C&C addresses

•Attribution is more difficult

•Take-down almost impossible

Page 131: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian
Page 132: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Infected machine

Page 133: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Infected machine

Satellite broadcasts traffic

Page 134: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Infected machine

SIGINT interception

Satellite broadcasts traffic

Page 135: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Infected machine

SIGINT interception

Real C&C server.Uses the IP address of a real SAT customer.

Satellite broadcasts traffic

Page 136: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Playing cat and mouse

•Gazer change in IOCs

•Carbon changes in IOCs

•Nautilus changes after NCSC UK report

•Mosquito DLLs no longer dropped on disk after our publication

Page 137: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

Conclusion

•Turla is still very active

•Really effective at tricking the users

•Large toolset•Most advanced backdoors used on the most protected

networks

Page 138: Visiting the snake nest - RECON.CX · 2019. 3. 5. · Visiting the snake nest Recon Brussels 2018 Jean-Ian Boutin | Senior Malware Researcher Matthieu Faou | Malware Researcher. Jean-Ian

www.eset.com | www.welivesecurity.com

Senior Malware Researcher

Matthieu FaouMalware Researcher

@jiboutin @matthieu_faou

Jean-Ian Boutin