phase&2:&scanning& - ccssccss.usc.edu › 530 › spring12 › 2.10.pdftraceroute& a...

65
Phase 2: Scanning Detec0ng informa0on useful for breakin Live machines Network topology Firewall configura0on Applica0ons and OS types Vulnerabili0es

Upload: others

Post on 05-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Phase  2:  Scanning  •  Detec0ng  informa0on  useful  for  break-­‐in  

–  Live  machines  –  Network  topology  –  Firewall  configura0on  –  Applica0ons  and  OS  types  –  Vulnerabili0es  

Page 2: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Network  Mapping  •  Finding  live  hosts  

–  Ping  sweep  –  TCP  SYN  sweep  

•  Map  network  topology    –  Traceroute  

•  Sends  out  ICMP  or  UDP  packets  with  increasing  TTL  •  Gets  back  ICMP_TIME_EXCEEDED  message  from  

intermediate  routers  

 

Page 3: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Traceroute  

A   R1   R2   R3   db  

www  

mail  

1.  ICMP_ECHO  to  www.vic0m.com  TTL=1  

1a.  ICMP_TIME_EXCEEDED    from  R1  

vic0m.com  

A:  R1  is  my  first  hop  to  www.vic0m.com!  

Page 4: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Traceroute  

A   R1   R2   R3   db  

www  

mail  

2.  ICMP_ECHO  to  www.vic0m.com  TTL=2  

2a.  ICMP_TIME_EXCEEDED    from  R2  

vic0m.com  

A:  R1-­‐R2  is  my  path  to  www.vic0m.com!  

Page 5: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Traceroute  

A   R1   R2   R3   db  

www  

mail  

3.  ICMP_ECHO  to  www.vic0m.com  TTL=3  

3a.  ICMP_TIME_EXCEEDED    from  R3  

vic0m.com  

A:  R1-­‐R2-­‐R3  is  my  path  to  www.vic0m.com!  

Page 6: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Traceroute  

A   R1   R2   R3   db  

www  

mail  

4.  ICMP_ECHO  to  www.vic0m.com  TTL=4  

4a.  ICMP_REPLY    from  www.vic0m.com  

vic0m.com  

A:  R1-­‐R2-­‐R3-­‐www  is  my  path  to  www.vic0m.com  

Page 7: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Traceroute  

A   R1   R2   R3   db  

www  

mail  

Repeat  for  db  and  mail  servers  

vic0m.com  

A:  R1-­‐R2-­‐R3-­‐www  is  my  path  to  www.vic0m.com          R1-­‐R2-­‐R3-­‐db  is  my  path  to  db.vic0m.com          R1-­‐R2-­‐R3-­‐mail  is  my  path  to  mail.vic0m.com  è Victim network is a star with R3 at the center              

Page 8: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Network  Mapping  Tools  •  Cheops  

–  Linux  applica0on  –  hYp://cheops-­‐ng.sourceforge.net/Automa0cally  

performs  ping  sweep  and  network  mapping  and  displays  results  in  GUI  

Dangerous  

Page 9: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Defenses  Against  Network  Mapping  And  Scanning  

•  Filter  out  outgoing  ICMP  traffic  –  Maybe  allow  for  your  ISP  only  

•  Use  Network  Address  Transla0on  (NAT)  

NAT  box  

A  

B  

C  D  

Internal  hosts  with  192.168.0.0/16  

1.2.3.4  8.9.10.11  

Request  1.2.3.4  

Reply  1.2.3.4  

Page 10: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

How  NATs  Work  •  For  internal  hosts  to  go  out  

–  B  sends  traffic  to  www.google.com  –  NAT  modifies  the  IP  header  of  this  traffic  

•  Source  IP:  B  èNAT  

•  Source  port:  B’s  chosen  port  Y  è  random  port  X  –  NAT  remembers  that  whatever  comes  for  it  on  port  X  

should  go  to  B  on  port  Y  

–  Google  replies,  NAT  modifies  the  IP  header  •  Des0na0on  IP:  NAT  èB  •  Des0na0on  port:  X  è  Y  

Page 11: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

How  NATs  Work  •  For  public  services  offered  by  internal  hosts  

–  You  adver0se  your  web  server  A  at  NAT’s  address  (1.2.3.4  and  port  80)  

–  NAT  remembers  that  whatever  comes  for  it  on  port  80  should  go  to  A  on  port  80  

–  External  clients  send  traffic  to  1.2.3.4:80  –  NAT  modifies  the  IP  header  of  this  traffic  

•  Des0na0on  IP:  NAT  èA  •  Des0na0on  port:  NAT’s  port  80  è  A’s  service  port  80  

–  A  replies,  NAT  modifies  the  IP  header  •  Source  IP:  AèNAT  •  Source  port:  80  è  80  

Page 12: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

How  NATs  Work  •  What  if  you  have  another  Web  server  C  

–  You  adver0se  your  web  server  A  at  NAT’s  address  (1.2.3.4  and  port  55)  –  not  a  standard  Web  server  port  so  clients  must  know  to  talk  to  a  diff.  port  

–  NAT  remembers  that  whatever  comes  for  it  on  port  55  should  go  to  C  on  port  80  

–  External  clients  send  traffic  to  1.2.3.4:55  –  NAT  modifies  the  IP  header  of  this  traffic  

•  Des0na0on  IP:  NAT  èC  •  Des0na0on  port:  NAT’s  port  55è  C’s  service  port  80  

–  C  replies,  NAT  modifies  the  IP  header  •  Source  IP:  CèNAT,  source  port:  80  è  55    

Page 13: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Port  Scanning  •  Finding  applica0ons  that  listen  on  ports  •  Send  various  packets:  

–  Establish  and  tear  down  TCP  connec0on  –  Half-­‐open  and  tear  down  TCP  connec0on  –  Send  invalid  TCP  packets:  FIN,  Null,  Xmas  scan  –  Send  TCP  ACK  packets  –  find  firewall  holes  –  Obscure  the  source  –  FTP  bounce  scans  –  UDP  scans  –  Find  RPC  applica0ons   Dangerous  

Page 14: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Port  Scanning  •  Set  source  port  and  address  

–  To  allow  packets  to  pass  through  the  firewall  –  To  hide  your  source  address  

•  Use  TCP  fingerprin0ng  to  find  out  OS  type  –  TCP  standard  does  not  specify  how  to  handle  

invalid  packets  –  Implementa0ons  differ  a  lot  

Page 15: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Port  Scanning  Tools  

•  Nmap  –  Unix  and  Windows  NT  applica0on  and  GUI  –  hYp://nmap.org/  –  Various  scan  types    –  Adjustable  0ming   Dangerous  

Page 16: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Defenses  Against  Port  Scanning  •  Close  all  unused  ports  •  Remove  all  unnecessary  services  •  Filter  out  all  unnecessary  traffic  •  Find  openings  before  the  aYackers  do  •  Use  smart  filtering,  based  on  client’s  IP  

Page 17: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Firewalk:  Determining  Firewall  Rules  •  Find  out  firewall  rules  for  new  connec0ons  •  We  don’t  care  about  target  machine,  just  about  

packet  types  that  can  get  through  the  firewall  –  Find  out  distance  to  firewall  using  traceroute  –  Ping  arbitrary  des0na0on  selng  TTL=distance+1  –  If  you  receive  ICMP_TIME_EXCEEDED    

message,  the  ping  went  through  

Page 18: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Defenses  Against  Firewalking  •  Filter  out  outgoing  ICMP  traffic  •  Use  firewall  proxies  

–  This  defense  works  because  a  proxy  recreates  each  packet  including  the  TTL  field  

Page 19: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Vulnerability  Scanning  •  The  aYacker  knows  OS  and  applica0ons  installed  on  

live  hosts  –  He  can  now  find  for  each  combina0on  

•  Vulnerability  exploits  •  Common  configura0on  errors  •  Default  configura0on    

•  Vulnerability  scanning  tool  uses  a  database  of  known  vulnerabili0es  to  generate  packets  

•  Vulnerability  scanning  is  also  used  for  sysadmin  

Page 20: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Vulnerability  Scanning  Tools  •  SARA  

–  hYp://www-­‐arc.com/sara  •  SAINT  

–  hYp://www.saintcorpora0on.com  •  Nessus  

–  hYp://www.nessus.org  

Dangerous  

Page 21: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Defenses  Against    Vulnerability  Scanning  

•  Close  your  ports  and  keep  systems  patched  •  Find  your  vulnerabili0es  before  the  aYackers  do  

Page 22: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

At  The  End  Of  Scanning  Phase    •  AYacker  has  a  list  of  “live”  IP  addresses    

•  Open  ports  and  applica0ons  at  live  machines  •  Some  informa0on  about  OS  type  and  version  of  live  

machines  •  Some  informa0on  about  applica0on  versions  at  

open  ports  •  Informa0on  about  network  topology  •  Informa0on  about  firewall  configura0on  

Page 23: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Phase  3:  Gaining  Access  •  Exploit  vulnerabili0es  

–  Exploits  for  a  specific  vulnerability  can  be  downloaded  from  hacker  sites  

–  Skilled  hackers  write  new  exploits  

What  is  a  vulnerability?  What  is  an  exploit?  

Page 24: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Stack-­‐Based  Overflow  AYacks  

•  Stack  stores  important  data  on  procedure  call  

Func0on  call  arguments  

Return  address  

Saved  frame  ptr  

Local  variables  for  called  procedure  

TOS  

Memory  address  increases  

Page 25: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Stack-­‐Based  Overflow  AYacks  

•  Consider  a  func0on  void sample_function(char* s) { char buffer[10]; strcpy(buffer, s); return; }  

•  And  a  main  program  void main() { int i; char temp[200]; for(i=0; i<200;i++) temp[i]=‘A’; sample_function(temp); return; }  

Argument  is  larger  than  we  expected  

…  

Page 26: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Stack-­‐Based  Overflow  AYacks  

•  Large  input  will  be  stored  on  the  stack,    overwri0ng  system  informa0on  

Func0on  call  arguments  

Return  address  

Saved  frame  ptr  

s,buffer[10]  TOS  

Memory  address  increases  OverwriYen  

by  A’s  

Page 27: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Stack-­‐Based  Overflow  AYacks  

•  AYacker  overwrites  return  address  to  point  somewhere  else  

–  “Local  variables”  por0on  of  the  stack  –  Places  aYack  code  in  machine  language  at  that  

por0on  –  Since  it  is  difficult  to  know  exact  address  of  the  

por0on,  pads  aYack  code  with  NOPs  before  and  ater  

Page 28: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Stack-­‐Based  Overflow  AYacks  

•  Intrusion  Detec0on  Systems  (IDSs)  could  look  for  sequence  of  NOPs  to  spot  buffer  overflows  

–  AYacker  uses  polymorphism:  he  transforms  the  code  so  that  NOP  is  changed  into  some  other  command  that  does  the  same  thing,    e.g.  MOV  R1,  R1  

–  AYacker  XORs  important  commands  with  a  key  –  AYacker  places  XOR  command  and  the  key  just  

before  the  encrypted  aYack  code.  XOR  command  is  also  obscured  

Page 29: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Stack-­‐Based  Overflow  AYacks  

•  What  type  of  commands  does  the  aYacker  execute?  

–  Commands  that  help  him  gain  access  to  the  machine  

–  Writes  a  string  into  inetd.conf  file  to  start  shell  applica0on  listening  on  a  port,  then  “logs  on”  through  that  port  

–  Starts  Xterm  

Page 30: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Stack-­‐Based  Overflow  AYacks  

•  How  does  an  aYacker  discover  stack-­‐based  overflow?  

–  Looks  at  the  source  code  –  Runs  applica0on  on  his  machine,  tries  to  supply  

long  inputs  and  looks  at  system  registers  

•  Read  more  at  –  hYp://insecure.org/su/smashstack.html  

Page 31: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Defenses  Against    Stack-­‐Based  Overflows  

•  For  system  administrators:  –  Apply  patches,  keep  systems  up-­‐to-­‐date  –  Disable  execu0on  from  the  stack  –  Monitor  writes  on  the  stack  –  Store  return  address  somewhere  else  –  Monitor  outgoing  traffic  

•  For  sotware  designers  –  Apply  checks  for  buffer  overflows  –  Use  safe  func0ons  

Page 32: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Network  AYacks  

•  Sniffing  for  passwords  and  usernames  •  Spoofing  addresses •  Hijacking  a  session  

Page 33: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Sniffing  •  Looking  at  raw  packet  informa0on  on  the  

wire  –  Some  media  is  more  prone  to  sniffing  –  Ethernet  –  Some  network  topologies  are  more  prone  to  

sniffing  –  hub  vs.  switch  

Page 34: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Sniffing  On  a  Hub  •  Ethernet  is  a  broadcast  media  –  every  

machine  connected  to  it  can  hear  all  the  informa0on  

–  Passive  sniffing  For  X   For  X  

X  

A  

R  Y  

Page 35: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Sniffing  On  a  Hub  •  AYacker  can  get  anything  that  is  not  

encrypted  and  is  sent  to  LAN  –  Defense:  encrypt  all  sensi0ve  traffic  –  Tcpdump  

•  hYp://www.tcpdump.org  –  Snort  

•  hYp://www.snort.org  –  Ethereal  

•  hYp://www.ethereal.com  

Page 36: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Sniffing  On  a  Switch  •  Switch  is  connected  by  a  separate  physical  

line  to  every  machine  and  it  chooses  only  one  line  to  send  the  message  

For  X  

X  

A  

R  Y  

Page 37: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Sniffing  On  a  Switch  –  Take  1  •  AYacker  sends  a  lot  of  ARP  messages  for  fake  

addresses  to  R  –  Some  switches  send  on  all  interfaces  when  their  

table  overloads  For  X  

X  

A  

R  Y  

Page 38: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Sniffing  On  a  Switch  –  Take  2  •  Address  Resolu0on  Protocol  (ARP)  maps  IP  

addresses  with  MAC  addresses  

1.  For  X  

2.  Who  has  X?  

X  

A  

R  Y  

Page 39: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Sniffing  On  a  Switch  –  Take  2  •  AYacker  uses  ARP  poisoning  to  map  his  MAC  

address  to  IP  address  X  

3.  For  X,  MAC  (A)  

1.  I  have  X,  MAC(A)  

X  

A  

R  Y  

5.  A  sends  this  back  to  R,  to  be  sent  to  MAC(X)  8.  A  sends  this  back  to  R,  to  be  sent  to  MAC(Y)  

Page 40: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Ac0ve  Sniffing  Tools  •  Dsniff  

–  hYp://www.monkey.org/~dugsong/dsniff  –  Also  parses  applica0on  packets  

for  a  lot  of  applica0ons  –  Sniffs  and  spoofs  DNS  

Dangerous  

Page 41: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Spoofing  DNS  •  AYacker  sniffs  DNS  requests,  replies  with  his  

own  address  faster  than  real  server  (DNS  cache  poisoning)  

•  When  real  reply  arrives  client  ignores  it  •  This  can  be  coupled  with  man-­‐in-­‐the-­‐middle  

aYack  on  HTTPS  and  SSH  

Page 42: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Sniffing  Defenses  •  Use  end-­‐to-­‐end  encryp0on  •  Use  switches  

–  Sta0cally  configure  MAC  and  IP  bindings  with  ports  

•  Don’t  accept  suspicious  cer0ficates    

Page 43: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

What  Is  IP  Spoofing  •  Faking  somebody  else’s  IP  address  in  IP  

source  address  field  •  How  to  spoof?  

–  Linux  and  BSD  OS  have  func0ons  that  enable  superuser  to  create  custom  packets  and  fill  in  any  informa0on  

–  Windows  XP  also  has  this  capability  but  earlier  Windows  versions  don’t  

Page 44: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

IP  Address  Spoofing  in  TCP  packets  •  AYacker  cannot  see  reply  packets    

Alice  M   Bob  M  

AYacker  M  1.  SYN,  IP  Alice,  SEQA  

2.  SYN  SEQB,  ACK  SEQA    

3.  RESET  

Page 45: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Guessing  a  Sequence  Number  •  AYacker  wants  to  assume  Alice’s  iden0ty  

–  He  establishes  many  connec0ons  to  Bob  with  his  own  iden0ty  gets  a  few  sequence  numbers  

–  He  disables  Alice  (DDoS)  –  He  sends  SYN  to  Bob,  Bob  replies  to  Alice,  

aYacker  uses  guessed  value  of  SEQB  to  complete  connec0on  –  TCP  session  hijacking  

–  If  Bob  and  Alice  have  trust  rela0onship  (/etc/hosts.equiv  file  in  Linux)  he  has  just  gained  access  to  Bob  

–  He  can  add  his  machine  to  /etc/hosts.equiv  echo  “1.2.3.4”  >>  /etc/hosts.equiv  

Page 46: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Guessing  a  Sequence  Number  •  It  used  to  be  ISN=f(Time),  s0ll  is  in  some  

Windows  versions  

Page 47: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Guessing  a  Sequence  Number  •  On  Linux  ISN=f(0me)+rand  

Page 48: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Guessing  a  Sequence  Number  •  On  BSD  ISN=rand  

Page 49: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Spoofing  Defenses  •  Ingress  and  egress  filtering  •  Prohibit  source  rou0ng  op0on  •  Don’t  use  trust  models  with  IP  addresses  •  Randomize  sequence  numbers  

Page 50: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

At  The  End  of  Gaining  Access  •  AYacker  has  successfully  logged  onto  a  

machine  

Page 51: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Phase  4:  Maintaining  Access  •  AYacker  establishes  a  listening  applica0on  

on  a  port  (backdoor)  so  he  can  log  on  any  0me  with  or  without  a  password  

•  AYackers  frequently  close  security  holes  they  find  

Page 52: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Netcat  Tool  •  Similar  to  Linux  cat  command  

–  hYp://netcat.sourceforge.net/  –  Client:  Ini0ates  connec0on  to  any  port  on  remote  

machine  –  Server:  Listens  on  any  port  –  To  open  a  shell  on  a  vic0m  machine  

On victim machine: nc –l –p 1234 /* This opens a backdoor */ On attacker machine: nc 123.32.34.54 1234 –c /bin/sh /* This enters through a backdoor, opens a shell */

Dangerous  

Page 53: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Netcat  Tool  •  Used  for    

–  Port  scanning  –  Backdoor  –  Relaying  the  aYack  

Page 54: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Trojans  •  Applica0on  that  claims  to  do  one  thing  (and  

looks  like  it)  but  it  also  does  something  malicious  

•  Users  download  Trojans  from  Internet  (thinking  they  are  downloading  a  free  game)  or  get  them  as  gree0ng  cards  in  E-­‐mail,  or  as  Ac0veX  controls  when  they  visit  a  Web  site  

•  Trojans  can  scramble  your  machine  –  They  can  also  open  a  backdoor  on  your  system  

•  They  will  also  report  successful  infec0on  to  the  aYacker

Page 55: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Back  Orifice  •  Trojan  applica0on  that  can  

–  Log  keystrokes  –  Steal  passwords  –  Create  dialog  boxes  –  Mess  with  files,  processes  or  system  (registry)  –  Redirect  packets  –  Set  up  backdoors  –  Take  over  screen  and  keyboard  –  hYp://www.bo2k.com/  

Dangerous  

Page 56: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Trojan  Defenses  •  An0virus  sotware  •  Don’t  download  suspicious  sotware  •  Check  MD5  sum  on  trusted  sotware  you  

download  •  Disable  automa0c  execu0on  of  aYachments  

Page 57: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

At  the  End  of  Maintaining  Access  •  The  aYacker  has  opened  a  backdoor  and  

can  now  access  vic0m  machine  at  any  0me  

Page 58: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Phase  5:  Covering  Tracks  •  Rootkits  •  Alter  logs  •  Create  hard-­‐to-­‐spot  files  •  Use  covert  channels  

Page 59: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Applica0on  Rootkits  •  Alter  or  replace  system  components    

(for  instance  DLLs)  •  E.g.,  on  Linux  aYacker  replaces  ls  program  •  Rootkits  frequently  come  together  with  

sniffers:  –  Capture  a  few  characters  of  all  sessions  on  the  

Ethernet  and  write  into  a  file  to  steal  passwords  –  Administrator  would  no0ce  an  interface  in  

promiscuous  mode  •  Not  if  aYacker  modifies  an  applica0on  that  shows  

interfaces  -­‐  netstat    

Page 60: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Applica0on  Rootkits  •  AYacker  will  modify  all  key  system  

applica0ons  that  could  reveal  his  presence  –  List  processes  e.g.  ps  –  List  files  e.g.  ls  –  Show  open  ports  e.g.  netstat  –  Show  system  u0liza0on  e.g.  top  

•  He  will  also  subs0tute  modifica0on  date  with  the  one  in  the  past  

Page 61: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Defenses  Against  App.  Rootkits  •  Don’t  let  aYackers  gain  root  access  •  Use  integrity  checking  of  files:  

–  Carry  a  floppy  with  md5sum,  check  hashes  of  system  files  against  hashes  adver0sed  on  vendor  site  or  hashes  you  stored  before  

•  Use  Tripwire  –  Free  integrity  checker  that  saves  md5  sums  of  all  

important  files  in  a  secure  database  (read  only  CD),  then  verifies  them  periodically  

–  hYp://www.tripwire.org/    

Page 62: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Kernel  Rootkits  •  Replace  system  calls  

–  Intercept  calls  to  open  one  applica0on  with  calls  to  open  another,  of  aYacker’s  choosing  

–  Now  even  checksums  don’t  help  as  aYacker  did  not  modify  any  system  applica0ons  

–  You  won’t  even  see  aYacker’s  files  in  file  lis0ng  –  You  won’t  see  some  processes  or  open  ports  

•  Usually  installed  as  kernel  modules  •  Defenses:  disable  kernel  modules    

Page 63: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Altering  Logs  •  For  binary  logs:  

–  Stop  logging  services  –  Load  files  into  memory,  change  them  –  Restart  logging  service  –  Or  use  special  tool    

•  For  text  logs  simply  change  file  through  scripts  

•  Change  login  and  event  logs,  command  history  file,  last  login  data  

Page 64: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Defenses  Against  Altering  Logs  •  Use  separate  log  servers  

–  Machines  will  send  their  log  messages  to  these  servers  

•  Encrypt  log  files  •  Make  log  files  append  only  •  Save  logs  on  write-­‐once  media  

Page 65: Phase&2:&Scanning& - CCSSccss.usc.edu › 530 › spring12 › 2.10.pdfTraceroute& A R1& R2& R3& db www mail& 2.&ICMP_ECHO&to& & TTL=2& 2a.&ICMP_TIME_EXCEEDED&& from&R2& vicm.com &

Crea0ng  Hard-­‐to-­‐Spot  Files  •  Names  could  look  like  system  file  names,  but  

slightly  changed  –  Start  with  .  –  Start  with  .  and  add  spaces  –  Make  files  hidden  

•  Defenses:  intrusion  detec0on  systems  and  cau0on