pacsec tokyo november 2014 tentacle: environment-sensitive ... · tentacle implementation details...

53
Ver 2.00.01 TENTACLE: Environment-Sensitive Malware Palpation FFRI, Inc. http://www.ffri.jp PacSec Tokyo November 2014 Yosuke Chubachi, Kenji Aiko

Upload: others

Post on 21-Mar-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

1 Ver 2.00.01

TENTACLE: Environment-Sensitive Malware Palpation

FFRI, Inc. http://www.ffri.jp

PacSec Tokyo November 2014

Yosuke Chubachi, Kenji Aiko

Page 2: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

About us

2

Yosuke Chubachi is a security engineer at FFRI, Inc. since this spring. He studied at the graduate school of information system engineering, University of Tsukuba. He is a Security Camp lecturer and a member of executive committee of SECCON since 2012.

Kenji Aiko is a programmer at FFRI, Inc., and is a one of the developers of "FFR yarai" which is a targeted attack protection software. He is a Security Camp lecturer and a member of executive committee of SECCON since 2012.

Page 3: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Contents •  Background/Motivation

•  Taxonomy  of  anti-‐‑‒sandbox  techniques

•  Tentacle  Design

•  Implementation

•  Experiments

•  Conclusion

3

Page 4: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Background

•  Malware  explosion– 120,000,000/recent  year

•  Antivirus  is  dead…?

4

AV Test: Statistics –New Malware- (Nov. 05 2014 viewed) http://www.av-test.org/en/statistics/malware/

Page 5: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

We need dynamic and automated malware analysis

•  “Scalability”  is  most  important  factor  in  information  explosion  era– Cloud– Bigdata–  IoT

•  Malware  analysis  also  needs  “scalable”  methodology– Automation  is  justice

5

Page 6: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Obi wan said, “Use the sandbox, Luke”

•  Security  engineer  and  researcher  use  sandbox  environment  for  malware  analyzing

•  Automated  dynamic  analysis  technology  also  based  on  VM/application  sandbox– Anubis(online  sandbox)– Cuckoo  Sandbox(VirtualBox  base)– Some  commercial  UTM  Appliance– Some  commercial  endpoint  security  solution

6

Page 7: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Sophisticated malware strike back

•  Sophisticated  malware  arms  many  anti-‐‑‒analyze  techniques•  Naturally  using  targeted  attacks,  cyber  espionage,  banking  malware

• We  called  those  malware  “evasive  malware”  

7

Page 8: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Related work

•  BareCloud  [Dhilung  K  et  al.,  USENIX  SECʼ’14]–  “5,835  evasive  malware  out  of  110,005  recent  samples”

•  Prevalent  Characteristics  in  Modern    Malware[Gabriel  et  al.,  BH  USA  ʻ‘14]–  “80%  malware  detect  vmware  using  backdoor  port”

8

What do you think?

Page 9: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Case study: Citadel

•  Some  citadel  detects  the  execution  environment  and  do  not  engage  in  malicious  behavior  when  the  current  host  differs  from  the  infected  host– To  avoid  dynamic  malware  detection(like  sandbox  analysis)

•  Showing  2  examples– Host-‐‑‒fingerprinting– VM/Sandbox  detection

9

Page 10: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Host-fingerprinting

•  Embedding  infected  hostʼ’s  unique  value  into  execution  binary

10

Citadel

Unpacker

Malicious code

Self-rewriting when

original malware execution

Environment-sensitive Citadel

Unpacker

Malicious code with host unique

value

Different signature pattern

Page 11: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Host-fingerprinting(cont’d) •  Getting  GUID  on  system  drive  using  the  GetVolumeNameForVolumeMountPoint()

•  Comparing  running  hostʼ’s  GUID  value  and  embedded  infected  hostʼ’s  value

•  Process  executes  malicious  code  if  GUID  values  are  consistent

11

Infected host’s GUID(packed)

Unpacked GUID Format:

{XXXXXXXX-XXXX-XXXX-XXXXXXXX}

Unpack

Environment-sensitive Citadel

Unpacker

Malicious code with host unique

value

Page 12: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

VM/Sandbox detection

•  Checking  processʼ’s  product  name  –  like  ”*vmware*”,  ”*virtualbox”

•  Scanning  specific  files  and  devices– C:\popupkiller.exe– C:\stimulator.exe– C:\TOOLS\execute.exe– \\.\NPF_̲NdisWanIp– \\.\HGFS– \\.\vmci– \\.\VBoxGuest  

12

Page 13: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Citadel behavior of host/environment inconsistency

•  For  example:– Process  termination– Running  fake(or  harmless)  code

13

Not really matter

A serious matter Initialization

(unpack) Sandbox(incl. VM)

Detection Malicious routine

Decoy routine

If running on an analyzing environment

Page 14: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Citadel runtime activities

14

Initialization

Scouting

Malicious Behavior

unpack

Environment-awareness

Memory Persistent storage

Network

Host fingerprinting

Malicious code execution

Code injection

Connecting C&C server

Unauthorized Access

Page 15: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Aim of evasive malware

•  Signature-‐‑‒based  AV  detection  avoiding

•  Anti-‐‑‒analyzing– Anti-‐‑‒security  engineer– Sandbox  evasion

15

Page 16: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Motivation

•  An  automatic  investigation  into  a  condition  used  by  sandbox  evasion–  Faking  bare-‐‑‒metal  environment  on  sandboxes  

16

Pass! Initialization (unpack)

Sandbox(incl. VM) Detection

Malicious routine

Transparent Sandbox Using Investigated Conditions

Page 17: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

TAXONOMY OF ANTI-SANDBOX Know  Your  Enemy

17

Page 18: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Taxonomy of anti-sandbox techniques

•  Anti-‐‑‒sandbox  maneuver– Environment  awareness•  Using    result  of  sandbox  detection

–  (Stalling  code)–  (User  interaction  checks)

•  Sandbox  (debug/sandbox/vm)  detection– Artifact  fingerprinting– Execution  environment  fingerprinting– Execution  timing  detection

18

Page 19: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Environment awareness

•  Checking  host  environments•  If  malware  runs  decoy  routine  then  it  detects  analyzerʼ’s  sign– Malicious  behavior  never  executed

19

Initialization (unpack)

Sandbox(incl. VM) Detection

Malicious routine

Decoy routine

If running on an analyzing environment

Page 20: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Sandbox (debug/sandbox/vm) detection

20

Host

Environment aware Malware

VM related Artifacts

Sandbox specific Artifacts

VMM?

Hardware

Execution Environment Fingerprinting

Artifact Fingerprinting

Execution Timing Detection

Page 21: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Artifact fingerprinting

•  Sandbox/VM  related  processes–  Like  vmware,  virtualbox  etc.

•  Sandbox/VM  environment  specific  files

•  Sandbox/VM  environment  specific  registry  keys

•  Sandbox/VM  environment    specific  devices  and  its  attributes–  ex).  QEMU  HDD  vendor  name

•  Sandbox/VM  Specific  I/O  port–  VMWare  backdoor  port  is  most  famous  artifact  in  malware

21

Page 22: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Execution environment fingerprinting

•  Using  virtual  machine  implementation  specific  platform  value  and  reaction– CPUID  instruction  result– Redpill•  Using  LDT/GDT  and  IDT  incongruousness

–  Interesting  research  here:  Cardinal  Pill  Testing

22

Page 23: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Execution timing detection

•  For  example:using  clock  count  differential  –  Traditional  anti-‐‑‒debug  technique

23

Comparing two TSC differentials

Page 24: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Targets of today’s presentation

•  Anti-‐‑‒sandbox  maneuverü Environment  awareness•  Using    result  of  sandbox  detection

p Stalling  codep User  interaction  checks

•  Sandbox  (debug/sandbox/vm)  detectionü Artifact  fingerprintingü Execution  environment  fingerprintingp Execution  timing  detection

24

Page 25: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

TENTACLE: DESIGN

Automatically  disarmament  system  for  armed  malware  with  anti-‐‑‒sandboxing

25

Page 26: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Concept: malware palpation

1.  “Thousand  form”  sandbox  runs  malware  again  and  again– Changing  “virtual”  artifacts  exposure  each  execution  for  execution  branch  detection

2.  Retroactive  condition  analysis–  Specifying  “branch  condition”  on  unnatural  process  termination

26

Page 27: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Malware palpation

•  Sandbox  runs  same  malware  again  and  again•  Sandbox  fakes  different  sandbox-‐‑‒related  artifacts  each  malware  execution– Detecting  execution  difference  using  code  execution  integrity(CEI)  

27

user-space kernel-space

Runtime & Libraries

Sandbox

vmmouse.sys

API emulator faking

user-space kernel-space

Runtime & Libraries

Sandbox

Malware (fist execution)

API emulator Not found

Malware (second execution)

Page 28: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Code Execution Integrity(CEI)

•  CEI  shows  uniqueness  of  instruction  execution  history  –  Inspired  by  TPM  trust  chaining

•  “measurement”  per  instruction

28

Digest[i] = SHA1( fetched CPU instruction + Digest[i-1] ) mov $0x616b6157, %eax push %ebx push %eax mov $4, %edx mov $1, %ebx

0xb857616b61 0x53 0x50 0xba04000000 0xbb01000000

d[0] = SHA1(0xb857616b61) d[1] = SHA1(d[0] + 0x53) d[2] = SHA1(d[1] + 0x50) d[3] = SHA1(d[2] +0xba04000000) ...

Page 29: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Execution branch detection

•  Using  execution  step  count  and  code  execution  integrity(CEI)  value

29

in eax, dx; cmp ebx, jne notVmware

jmp isVmware notVmware: mov rc, 0 jmp done isVmware: mov rc, eax

jmp done

CEI[0]1

CEI[1]1

CEI[2]1

CEI[3]1 CEI[4]1

CEI[0]2

CEI[1]2

CEI[2]2

CEI[3]2

CEI[4]2

CEI[5]2

Page 30: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Retroactive condition analysis

•  Sandbox  retroactive  from  termination  to  terminated  reason  API    and  arguments  when  suspicious  termination– Only  a  few  steps  executions– To  terminate  before  network  activities

30

sub esp, 1024 mov ebx, esp push 400h push ebx push 0h call GetModuleFileNameA lea eax, MyPath push eax push ebx call lstrcmpA test eax, eax push 0h lea eax, MsgCaption push eax jz _ok lea eax, NGMsgText push eax push 0h call MessageBoxA invoke ExitProcess, NULL

_ok: lea eax, OKMsgText

Page 31: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

TENTACLE: IMPLEMENTATION know  thyself

31

Page 32: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Tentacle implementation overview

32

Host

user-space kernel-space

Runtime & Libraries

CPU Emulator FILE’ HEAP’

Runtime & Libraries (Virtualized)

Target’ Process

Memory Context’

Execution Context’

•  Tentacle  based  on  IA-‐‑‒32  CPU  emulator

Page 33: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

IA-32 CPU emulator-based sandbox

• We  have  already  CPU  Emulator-‐‑‒based  sandbox  for  win32  execution  (in-‐‑‒house  use)–  Like  IDA  Bochs  PE  operation  mode

33

CPU Emulator

Target Program (loaded)

Decode

Execution

Instruction Fetch

Address Resolution

Applying Execution Result

Page 34: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

IA-32 CPU Emulator: Virtual contexts

34

CPU Emulator Process

Target Process

Virtual CPU Contexts

Target Process’s VA Space contexts

Virtual Heap Contexts

Virtual Process Contexts

Virtual Module(DLL) Contexts

Virtual Resources (handle) Contexts

DLLs

Headers

Data

Code

Page 35: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

IA-32 CPU Emulator: API emulation

35

CPU Emulator Process

Target Process

API Emulation Components

DLLs

kernel32.dll

user32.dll

msvcrt.dll

advapi32.dll

Virtual kernel32 Functions

Virtual user32.dll Functions

Virtual msvcrt.dll Functions

Virtual advapi32.dll Functions

Virtualized Resource Manager

Page 36: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Limitations

•  The  original  CPU  emulator  supports  a  limited  API

•  The  original  CPU  emulator  supports  a  limited  CPU  instruction

36

Page 37: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Tentacle implementation details

•  Nyarlathotep  “Thousand  Form”  Sandbox– Camouflaging  sandbox/vm  related  artifact  existence  – Execution  branch  detection  using  CEI

•  Retroactive  condition  analysis

•  Necronomicon– Execution  logging  framework  

37

Page 38: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Necronomicon

•  Necrnomicon  logs  instruction  per  execution– Tracing  specific  API  call  and  its  arguments  for  Retroactive  condition  analysis•  lstrcmp,  GetModuleFileName,  GetVolumeNameForVolumeMountPoint…

•  Code  execution  integrity  calculation  per  execution–  For  execution  branch  detection

38

Page 39: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Nyarlathotep “Thousand Form” Sandbox

•  For  example,  VMWare  related  artifacts– backdoor  port–  vm-‐‑‒related  files  (2  files)–  registry  entries  (1  entry)

•  Sandbox  fake  “in”  instruction  result  for  backdoor  port  check

•  Files  and  registry  entry  virtualization  used  by    sandboxʼ’s  own  virtual  resource  manager

39

Page 40: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Experiments

•  Disarmament  #01:  Artifact  fingerprinting  sample•  Disarmament  #02:  Comparing  Disk  GUID  value  sample•  Disarmament  #03:  Comparing  executable  file  path  sample

40

Page 41: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Disarmament #01: Artifact fingerprinting sample

41

int _tmain(int argc, _TCHAR* argv[]) {

int count = 0; delay(); if ( sbdetect_vmware_backdoor_port() > 0){ printf("VMWare backdoor port detected. I am on the virtual."); } if ( sbdetect_vmware_sysf01() == 0 ){ printf("vmmouse.sys detected. I am on the virtual.\n"); exit(1); } if ( sbdetect_vmware_sysf02() == 0 ){ printf("vmmouse.sys detected. I am on the virtual.\n"); exit(1); } if ( sbdetect_vmware_reg01() == 0 ){ printf("RegKey: \"SOFTWARE\\VMware, Inc.\\VMware Tools\"

detected. I am on the virtual.\n"); exit(1); } //Malicious behavior printf("malicious behavior\n”); return 0;

}

Page 42: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

sbdetect_vmware_backdoor_port()

42

int sbdetect_vmware_backdoor_port(void) { int rc = 0; __try { __asm { mov eax, 'VMXh' mov ebx, 0; mov ecx, 0xA mov edx, 'VX' // port in eax, dx; // read port cmp ebx, 'VMXh’ // Vmware echo ‘VMXh’ jne notVmware jmp isVmware notVmware: mov rc, 0 jmp done isVmware: mov rc, eax done: } } __except(EXCEPTION_EXECUTE_HANDLER) { rc = 0; } return rc; }

Page 43: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

sbdetect_vmware_sysf01()

43

// // Detect proven: Windows 7 32bit // Not detected: Windows 7 64bit // int sbdetect_vmware_sysf01() { DWORD ret;

TCHAR target[255] = "%WINDIR%\\system32\\drivers\\vmmouse.sys"; ret = GetFileAttributes(target);

if( ret != INVALID_FILE_ATTRIBUTES ){ return 0; }

else{ return 1; } }

Page 44: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

sbdetect_vmware_sysf02()

44

// // Detect proven: Windows 7 32bit // Not detected: Windows 7 64bit // int sbdetect_vmware_sysf02() { DWORD ret;

TCHAR target[255] = "%WINDIR%\\system32\\drivers\\vmhgfs.sys"; ret = GetFileAttributes(target);

if( ret != INVALID_FILE_ATTRIBUTES ){ return 0; }

else{ return 1; } }

Page 45: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Disarmament #01

45

Page 46: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Disarmament #02: Comparing Disk GUID value sample

46

.386

.model flat,stdcall option casemap:none include \masm32\include\windows.inc include \masm32\include\kernel32.inc includelib \masm32\lib\kernel32.lib include \masm32\include\user32.inc includelib \masm32\lib\user32.lib .data

DriveC db "C:\", 0 VolumeC db "\\?\Volume{8e7e8884-600d-11e4-

ae07-806e6f6e6963}\", 0 MsgCaption db "MESSAGE", 0 OKMsgText db "Normal Message", 0 NGMsgText db "Detect Message", 0

.code

start: sub esp, 1024 mov ebx, esp sub esp, 4 mov eax, esp push eax push ebx lea eax, DriveC push eax call GetVolumeNameForVolumeMountPointA lea eax, VolumeC push eax push ebx call lstrcmpA test eax, eax push 0h lea eax, MsgCaption push eax jz _ok lea eax, NGMsgText push eax push 0h call MessageBoxA invoke ExitProcess, NULL

_ok: lea eax, OKMsgText push eax push 0h call MessageBoxA invoke ExitProcess, NULL

end start

Page 47: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Disarmament #02

47

Page 48: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Disarmament #03 Comparing executable file path sample

48

.386

.model flat,stdcall option casemap:none include \masm32\include\windows.inc include \masm32\include\kernel32.inc includelib \masm32\lib\kernel32.lib include \masm32\include\user32.inc includelib \masm32\lib\user32.lib .data

MyPath db "C:\x\sample2.exe", 0 MsgCaption db "MESSAGE", 0 OKMsgText db "Normal Message", 0 NGMsgText db "Detect Message", 0

.code start sub esp, 1024

mov ebx, esp push 400h push ebx push 0h call GetModuleFileNameA lea eax, MyPath push eax push ebx call lstrcmpA test eax, eax push 0h lea eax, MsgCaption push eax jz _ok lea eax, NGMsgText push eax push 0h call MessageBoxA invoke ExitProcess, NULL

_ok: lea eax, OKMsgText push eax push 0h call MessageBoxA invoke ExitProcess, NULL

end start

Page 49: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Disarmament #03

49

Page 50: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Future work

•  Improving  anti-‐‑‒sandbox  detection  – Stalling  code  detection  and  evasion

•  Improving  sandbox  quality

50

Page 51: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Conclusions

•  This  is  proof  of  concept  of  automatically  disarmament  system  for  armed  malware  with  anti-‐‑‒sandboxing  with  CPU  emulator-‐‑‒based  sandbox

• We  introduced  anti-‐‑‒sandbox  taxonomy

51

"Know thy self, know thy enemy. A thousand battles, a thousand victories."- Sun Tzu

Page 52: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

Bibliography •  Analyzing Environment-Aware Malware, Lastline, 2014.05.25(viewed)

http://labs.lastline.com/analyzing-environment-aware-malware-a-look-at-zeus-trojan-variant-called-citadel-evading-traditional-sandboxes •  Martina Lindorfer, Clemens Kolbitsch, and Paolo Milani Comparetti. 2011. Detecting environment-sensitive malware. In Proceedings of the

14th international conference on Recent Advances in Intrusion Detection (RAID'11). Springer-Verlag, Berlin, Heidelberg, 338-357. •  lemens Kolbitsch, Engin Kirda, and Christopher Kruegel. 2011. The power of procrastination: detection and mitigation of execution-stalling

malicious code. In Proceedings of the 18th ACM conference on Computer and communications security (CCS '11). ACM, New York, NY, USA, 285-296.

•  Min Gyung Kang, Heng Yin, Steve Hanna, Stephen McCamant, and Dawn Song. 2009. Emulating emulation-resistant malware. In Proceedings of the 1st ACM workshop on Virtual machine security (VMSec '09). ACM, New York, NY, USA, 11-22.

•  Dhilung Kirat, Giovanni Vigna, and Christopher Kruegel. 2014. Barecloud: bare-metal analysis-based evasive malware detection. In Proceedings of the 23rd USENIX conference on Security Symposium (SEC'14). USENIX Association, Berkeley, CA, USA, 287-301.

•  Ulrich Bayer, Imam Habibi, Davide Balzarotti, Engin Kirda, and Christopher Kruegel. 2009. A view on current malware behaviors. In Proceedings of the 2nd USENIX conference on Large-scale exploits and emergent threats: botnets, spyware, worms, and more (LEET'09). USENIX Association, Berkeley, CA, USA, 8-8.

•  Aurélien Wailly. Malware vs Virtualization The endless cat and mouse play, 2014.05.25(viewed) http://aurelien.wail.ly/publications/hip-2013-slides.html

•  Lorenzo Martignoni, Roberto Paleari, Giampaolo Fresi Roglia, and Danilo Bruschi. 2009. Testing CPU emulators. In Proceedings of the eighteenth international symposium on Software testing and analysis (ISSTA '09). ACM, New York, NY, USA, 261-272.

•  Hao Shi, Abdulla Alwabel and Jelena Mirkovic. 2014. Cardinal Pill Testing of System Virtual Machines. In Proceedings of the 23rd USENIX conference on Security Symposium (SEC'14). USENIX Association, Berkeley, CA, USA,271-285.

•  Lorenzo Martignoni, Roberto Paleari, Giampaolo Fresi Roglia, and Danilo Bruschi. 2010. Testing system virtual machines. In Proceedings of the 19th international symposium on Software testing and analysis (ISSTA '10). ACM, New York, NY, USA, 171-182.

•  IDA Boch PE operation mode https://www.hex-rays.com/products/ida/support/idadoc/1332.shtml

52

Page 53: PacSec Tokyo November 2014 TENTACLE: Environment-Sensitive ... · Tentacle implementation details • Nyarlathotep “Thousand Form” Sandbox – Camouflaging sandbox/vmrelatedartifact

FFRI,Inc.

53

Thank you !

FFRI, Inc. http://www.ffri.jp