Top Banner
Merovingio Mislead the malware Juan Carlos Montes Adrián Pulido
42

Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

Aug 18, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

MerovingioMislead the malware

Juan Carlos Montes

Adrián Pulido

Page 2: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

2

Index

• Malware Analysis

• what else?

• state of art

• why?

• PebHooking

• Merovingio

• Sandboxie

• Merovingio Agent

• DorianIA

• Merovingio Website

Page 3: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

3

Index

• Malware Analysis

• what else?

• state of art

• why?

• PebHooking

• Merovingio

• Sandboxie

• Merovingio Agent

• DorianIA

• Merovingio Website

Page 4: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

4

Malware Analysis

What else?

• New techniques

• Avoid signatures

• The market is dozed

• A lot of new samples every day

• It’s expensive complicated to have people focused on malware analysis in a CSIRT

Page 5: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

5

Malware Analysis

State of art

• Commercial products are similar• Same VM.• Same drivers.• Same look&feel.• SAME RESULTS.

• The commercial products are the same limits• One sample on each VM.

• Wait to reboot/reset the VM to start another analysis.

• The analysis spend 2-3 minutes all times. This time is not based on the behavior of the sample.

• Attached to the company for any grown.• And… the source code is not our.

Page 6: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

6

Malware Analysis

Why?

• Need “anything” to detect the new samples and behaviors

• Avoid the dependencies of the antivirus

• Avoid the problems with VM.• One sample on each VM• Samples are out of control on execution

• Accelerate the analysis

• Include some control on the execution

• Create a system to simulate behaviors

Page 7: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

7

Index

• Malware Analysis

• what else?

• state of art

• why?

• PebHooking

• Merovingio

• Sandboxie

• Merovingio Agent

• DorianIA

• Merovingio Website

Page 8: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

8

Pebhooking

• Published in Phrack #65• Dreg and [Shearer]

• Modify the PEB in the process to exchange real libraries for our libraries

• All dynamic loaded libraries will be hooked

• Only is necessary repair the main IAT

Page 9: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

9

Pebhooking

process

InheritedAddressSpaceReadImageFileExecOptionsBeingDebuggedSpareMutantImageBaseAddressLoaderData

PEBLengthInitializedSsHandleInLoadOrderModListInMemoryOrderModListInInitOrderModList Flink…

LoaderData

InLoadOrderModListInMemoryOrderModListInInitOrderModListBaseAddress 7C801000…BaseDllName “kernel32.dll”

LDR_MODULE

InLoadOrderModListInMemoryOrderModListInInitOrderModList…BaseDllName “xxxxxx.dll”

LDR_MODULEInLoadOrderModListInMemoryOrderModListInInitOrderModList…BaseDllName “ntdll.dll”

LDR_MODULE

Page 10: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

10

Pebhooking

process

InheritedAddressSpaceReadImageFileExecOptionsBeingDebuggedSpareMutantImageBaseAddressLoaderData

PEBLengthInitializedSsHandleInLoadOrderModListInMemoryOrderModListInInitOrderModList Flink…

LoaderData

InLoadOrderModListInMemoryOrderModListInInitOrderModListBaseAddress XXXXXXXXXX…BaseDllName “kernel32.dll”

LDR_MODULE

InLoadOrderModListInMemoryOrderModListInInitOrderModListBaseAddress 7C801000…BaseDllName “ph_k32.dll”

LDR_MODULEInLoadOrderModListInMemoryOrderModListInInitOrderModList…BaseDllName “ntdll.dll”

LDR_MODULE

Page 11: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

11

Pebhooking

• ph_ker32.dll• Export the same functions that kernel32.dll

• We must do a specific dll for each service pack

• The functions exported have the same ordinal as the original function

• We can manage any function we want• Store the return value

• Modify params in runtime

• Block the execution on any API

Page 12: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

12

Pebhooking

process

Download binaryExecute directly from memoryorDownload binaryWrite binary in disk………..………..

Working… My system

process

Download binaryExecute directly from memoryorDownload binaryWrite binary in disk……..……..

Working… My system

PEBHook

Download binaryCopy binary to safe zoneorDownload binaryCopy & execute & …

Sleep,GettickCount…

Page 13: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

13

Pebhooking: Source DEFS

Page 14: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

14

Pebhooking: Source OpenProcess

Page 15: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

15

Pebhooking: Source ReadProcessMemory

Page 16: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

16

Index

• Malware Analysis

• what else?

• state of art

• why?

• PebHooking

• Merovingio

• Origin

• Sandboxie

• Merovingio Agent

• DorianIA

• Merovingio Website

Page 17: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

17

Origin

• Need to inject DLL in all processes

• Retrieves logs and info

• Avoid infecting the machine

• Multithread

• Does a lot of analysis

• Use(r) friendly

• Controls the previous analysis

• …

Page 18: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

18

Merovingio

• “Virtual Machine”

• Sandboxie

• Pebhooking

• DorianIA

• And… this is the web!

Page 19: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

19

Merovingio

sample web site VirtualBox

SandBoxie

Pebhooking

Dorian IA

Page 20: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

20

Merovingio

• Runs programs in a sandbox

• Prevents permament changes on the system

• Helps us to load our libraries in each process

• Isolates each program execution

Page 21: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

21

SandBoxie

Page 22: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

22

Merovingio Agent

• Tested in Windows XP and Windows 7

• Developed in Python v2.7

• Can manage as many sandboxed instances as we want

• Recover the logs and send us to next step

• Multithread

• Can receive more than one sample at the same time

• Decide on which instance must be executed the sample

• Free slot• Specific analysis

• Monitorizes the analysis to detected when it is finishing

Page 23: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

23

Merovingio Agent

Page 24: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

24

Merovingio Agent

• Searches new samples on the path

• Copies the new samples and analyzes them

• Monitorizes Sandboxie’s box

• Retrieve logs on the website

Page 25: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

25

Merovingio Agent

Page 26: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

26

Merovingio Agent

Page 27: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

27

Index

• Malware Analysis

• what else?

• state of art

• why?

• PebHooking

• Merovingio

• Sandboxie

• Merovingio Agent

• DorianIA

• Merovingio Website

Page 28: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

28

Dorian IA

• It is based on the workflows of the neural networks

• Set the time in each received log

• Analyze the log looking for patterns

• Create execution blocks

• Try to link the different blocks to create behaviors

• Show the results in a new log that is send to the website

• At the moment it can learn new behaviors, our aim is to create a real AI

Page 29: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

29

Dorian IA

LoadLibraryW|IMM32.DLLCreateFileW | C:\ikkka.exe|0x178CreateFileW|COMCTL32.DLL|0x4CLoadLibraryW|user32.dllWriteFile | 0x178 | 0x22800 | XXXXXXXXXCloseHandle | 0x4CCloseHandle | 0x178

Log from PebHooking

CreateFileW | C:\ikkka.exe | 0x178WriteFile | 0x178 | 0x22800 | XXXXXXXXXXCloseHandle | 0x178

Block

Page 30: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

30

Dorian IA

LoadLibraryW|IMM32.DLLCreateFileW | C:\itself.exe|0x77ReadFile | 0x22800 | XXXXXXXXXCloseHandle | 0x77DeleteFile | C:\autoexec.batCreateFileW | C:\ikkka.exe|0x178CreateFileW|COMCTL32.DLL|0x4CLoadLibraryW|user32.dllWriteFile | 0x178 | 0x22800 | XXXXXXXXXCloseHandle | 0x4CCloseHandle | 0x178

Log from PebHooking

CreateFileW | C:\ikkka.exe | 0x178WriteFile | 0x178 | 0x22800 | XXXXXXXXXXCloseHandle | 0x178

Block

CreateFileW | C:\itself.exe|0x77ReadFile | 0x22800 | XXXXXXXXXCloseHandle | 0x77

Block

• Read itself

• Write itself in other file

• Similar content: we use ssdeep to compare the information with threshold 95%

The sample was copied itself to another path.

DeleteFile | C:\autoexec.bat

Block

Page 31: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

31

Dorian IA: Source Rules

Rules:

-Self replicate

-Duplicate others files

-Delete it self

-Open process

- …

Page 32: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

32

Index

• Malware Analysis

• what else?

• state of art

• why?

• PebHooking

• Merovingio

• Sandboxie

• Merovingio Agent

• DorianIA

• Merovingio Website

Page 33: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

33

Website Features

• User management

• Able to upload different samples at the same time

• Hold the history to recover old reports

• Look for the samples by its filename or hash (SHA256,SHA1,MD5)

• All the communication with the agent is transparent to user

• Find malicious samples easily from the history

Page 34: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

34

Website Features

Home page / Send samples

Page 35: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

35

Website Screenshots

Page 36: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

36

Website Screenshots

Raw log

Page 37: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

37

Website Screenshots

Analysis

Page 38: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

38

Website Screenshots

API

Page 39: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

39

Website Achivements

• Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior

• The same machine can analyze over 20 samples both (VM or real)

• To grow we need add RAM memory to allocate more process or add a new machine to get 20 slots.

• Very cheap (information for 20 analysis):• Just one machine

• 4Ghz CPU (4 cores) and 4Gb RAM

• The analysis can be stopped when the sample finishes the execution

Page 40: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

40

Merovingio Numbers

• 720 samples can be analyzed in each sandboxed instance daily

• 14.400 samples use 20 instances in the sandboxie

• Only 1 cheap machine to get this numbers

Page 41: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

41

Questions??

• Any doubs??

• Any questions??

• Any donations??

• Donaciones??

Page 42: Juan Carlos Montes Adrián Pulido · 39 Website Achivements •Max. runtime 2 minutes, but the analysis stop when it doesn’t detect any new behavior •The same machine can analyze

42

Gracias!!!

Juan C. Montes

Mail personal: [email protected]

Mail CERT: [email protected]

Twitter: @jcmontes_tecAdrián Pulido

Mail personal: [email protected]

Mail CERT: [email protected]

Twitter: @winsock