one$flew$over$the$cuckoo’s$nest - hitbconference.hitb.org/hitbsecconf2012ams/materials/d1t1... ·...

56

Upload: ngocong

Post on 12-Apr-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$
Page 2: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

One  Flew  Over  the  Cuckoo’s  Nest  Hack  In  The  Box  2012  Amsterdam  May  24th  2012    

Page 3: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

INTRODUCTION  Chapter  0x01  

Page 4: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Who  we  are  

Page 5: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Here  

•  Claudio  “nex”  Guarnieri  @botherder  

•  Security  Researcher  at  iSIGHT  Partners  •  Core  Member  at  The  Shadowserver  FoundaNon  •  Full  Member  at  The  Honeynet  Project  •  Pizza,  pasta,  Ferrari  •  Cuckoo  Creator  and  Lead  Developer  

Page 6: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Not  here  

•  Alessandro  “jekil”  Tanasi  @jekil  

•  Dude  from  Hostmap,  SecDocs  •  Cuckoo  Core  Developer  and  Fussy  Bitch  Engineer    

•  Dario  “bagode”  Fernandes  •  Google  Summer  of  Code  2011  student  •  Cuckoo  Windows  components  developer  

Page 7: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

AUTOMATED  MALWARE  ANALYSIS  Chapter  0x02  

Page 8: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Problems  

•  Malwares  in  the  wild  are  way  too  many  •  Manual  analysis  takes  a  lot  of  Nme  •  StaNc  analysis  requires  strong  skillsets  •  Need  to  deal  with  packed,  polymorphic,  self-­‐modifying  code  

•  Performing  dynamic  analysis  manually  is  a  tedious  work  

Page 9: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

SANDBOX!  

Page 10: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Pros  

•  Can  automate  the  whole  analysis  process  •  Process  high  volumes  of  malwares  •  Usable  by  virtually  anyone  •  Get  actual  executed  code  •  Can  tweak  to  do  cool  sh1t  •  AutomaNng  is  cool  •  AutomaNng  is  cool  •  AutomaNng  is  cool  

Page 11: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Lets  you  focus  on  more  important  duNes  

and  sNll  get  paid  

Page 12: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Cons  

•  Commercial  soluNons  are  very  expensive  •  Some  porNons  of  the  malware  code  could  be  not  triggered  

•  Environment  could  be  detected  •  Difficult  to  successfully  automate  exploit  analysis  

•  Without  proper  consumpNon  of  the  results,  it  gets  useless  

Page 13: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

PreparaNon  

•  Need  to  define  your  requirements  and  expectaNons  

•  Need  to  design  the  analysis  environment  carefully  

•  Need  to  design  and  implement  a  proper  use  of  the  data  and  integraNon  with  other  systems  and  storages  

Page 14: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Ask  yourself  #1  

•  Why  do  I  need  a  Sandbox?  •  What  do  I  expect  to  achieve?  •  What  informaNon  is  most  relevant  to  me  or  to  my  organizaNon?  

•  Who  is  gonna  consume  the  results  and  what  for?  

•  How  can  I  make  it  easily  consumable  

Page 15: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Ask  yourself  #2  

•  Do  I  want  to  analyze  PDF  exploits?  •  Do  I  want  to  analyze  Office  exploits?  •  Do  I  want  to  analyze  PHP  and  Perl  scripts?  •  Do  I  want  to  analyze  browsers’  exploits?  •  What  else  do  I  want  to  analyze?  •  Do  I  want  it  to  communicate  with  the  outside?  

Page 16: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

CUCKOO  SANDBOX  Chapter  0x03  

Page 17: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

What  is  it  

•  Automated  malware  analysis  system  •  Uses  virtualizaNon  •  Easy  to  use  •  Easy  to  customize  •  Every  single  piece  of  it  it’s  Open  Source!  

Page 18: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

History  

•  Google  Summer  of  Code  2010  •  DRG  Security  InnovaNon  Grant  2011  finalist  •  Google  Summer  of  Code  2011  •  Malwr.com  •  Google  Summer  of  Code  2012  •  Rapid7  Magnificent7  winner  of  1st  round  hbp://community.rapid7.com  

powered  by  

Page 19: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

It  can  

•  Analyze  PE32,  PDF,  DOC,  URLs,  PHP,  Perl,  Python  scripts…  you  name  it  

•  Be  fully  customized  to  do  whatever  you  want  •  Be  integrated  in  larger  threat  intelligence  frameworks  

 

Page 20: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

It  generates  

•  Win32  funcNons  calls  trace  •  Dropped  files  •  Screenshots  •  Network  traffic  dump  •  Comprehensive  reports  

Page 21: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

hbp://www.flickr.com/photos/consonus/  

Page 22: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Cuckoo  Scheduler  

Analyzer  

cmonitor  &  chook  

Components  

Page 23: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Scheduler  

•  Main  component  •  Dispatches  the  pending  tasks  to  the  pool  of  machines  available  

•  Runs  all  the  juicy  modules  we’re  gonna  see  in  a  bit  

•  100%  Python  

Page 24: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Analyzer  

•  Component  that  instruments  the  guest  machine  

•  Chosen  depending  on  the  plaiorm  of  the  selected  machine  

•  Only  Windows  now,  but  can  support  more  •  Runs  the  malware  and  do  stuff  with  it  •  100%  Python  

Page 25: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Cmonitor  

•  DLL  using  chook  to  install  hooks  on  predefined  win32  funcNons  inside  process  memory  

•  Gets  injected  into  the  target  process  (QueueUserAPC  or  CreateRemoteThread)  

•  Logs  the  funcNons  calls  to  files  

Page 26: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Chook  

•  Custom  inline  hooking  library  •  Allows  definiNon  of  custom  hook  trampolines  •  Replaced  Microson  Detours  

Page 27: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Reason  #1  

Page 28: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$
Page 29: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$
Page 30: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Reason  #2  

Page 31: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Fetch  a  task  

Prepare  the  

analysis  

Launch  analyzer  in  virtual  machine  

Execute  an  

analysis  package  

Complete  the  

analysis  Store  the  results  

Process  and  

create  reports  

ExecuNon  flow  

Page 32: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$
Page 33: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Submission  

•  From  command-­‐line,  Python  API  or  SQLite  DB  •  Specify  file  path  •  Specify  analysis  package  and  its  opNons  •  Specify  machine  to  be  used  or  operaNng  system  

•  Specify  Nmeout,  priority  

Page 34: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Modules  &  CustomizaNon  

•  Analysis  Packages  •  Machine  Managers  •  Processing  •  ReporNng  •  Signatures  

Page 35: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Analysis  Packages  

•  Python  classes  J  •  Defines  how  the  analyzer  should  start  and  interact  with  the  malware  

•  Specified  at  submission  or  selected  upon  file  type  

•  Can  create  as  many  as  you  want  and  do  whatever    you  want  

Page 36: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$
Page 37: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$
Page 38: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

DEMO!  

Page 39: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Other  examples  

•  Honeyclient?  •  Banking  trojan  analyzer  •  USB  Honeypot  •  Up  to  you…  

Page 40: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$
Page 41: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Machine  Managers  

•  Yes,  Python  classes  J  •  Define  interacNon  with  virtualizaNon  sonware  

Page 42: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$
Page 43: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Processing  

•  Python  classes,  again  K  •  Modules  used  to  generate  a  container  of  normalized  informaNon  on  the  analysis  

•  Can  create  as  many  as  you  want  

Page 44: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$
Page 45: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$
Page 46: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Signatures  

•  Python  classes!  •  Look  for  paberns  or  specific  events  •  Assign  them  a  descripNon  and  severity  level  •  Give  context  to  the  reports  •  Help  non-­‐malware  experts  understand  •  Can  be  used  to  receive  email  alerts  

Page 47: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$
Page 48: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$
Page 49: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

ReporNng  

•  OMG  Python  classes  L  •  Use  the  normalized  results  and  do  something  with  them  

•  Can  create  as  many  as  you  want  

Page 50: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$
Page 51: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

or  mongo!  

Page 52: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Community  Effort  

•  Create  a  community  repository  for  sharing  modules  &  signatures  

•  Expand  our  line-­‐up  of  developers  and  contributors  

•  Make  Malwr.com  a  major  community  resource  for  malware  research  

Page 53: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Future  Work  

•  A  full-­‐fledged  web  interface  •  Improve  Windows  analysis  components  •  Support  for  other  operaNng  systems,  Mac  OS  X?  

•  Support  naNve  machines    

Page 54: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

Websites  

•  hbp://cuckoosandbox.org  •  hbp://github.com/cuckoobox/cuckoo  •  hbp://blog.cuckoobox.org  •  hbp://malwr.com  •  hbp://www.honeynet.org  

Page 55: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

?  

Page 56: One$Flew$Over$the$Cuckoo’s$Nest - HITBconference.hitb.org/hitbsecconf2012ams/materials/D1T1... ·  · 2017-10-15One$Flew$Over$the$Cuckoo’s$Nest Hack$In$The$Box$2012$Amsterdam$

THANK  YOU!  NOW  LET’S  GET  SOME  LUNCH!  

[email protected]