SlideShare une entreprise Scribd logo
1  sur  44
Télécharger pour lire hors ligne
All you ever wanted to
   know about BeEF
 Antisnatchor – ZeroNights 2012 -
           Москва
About antisnatchor
•    Lead core developer of BeEF
•    Application security researcher
•    Loves Ruby, Javascript and OpenBSD
•    Kubrick fan
•    Водка fan
BeEF
•  The most robust framework to
   control the browser of a victim
   entirely with Javascript.

•  Each browser is likely to be within
   a different security context, and
   each context may provide a set of
   unique attack vectors.
High Level Architecture
Lets start to play with it
•  BeEF Live CD
   -­‐>	
  thanks	
  Ben	
  Waugh	
  

  –  Based on Ubuntu L
  –  Latest (GIT): BeEF, Metasploit, sqlmap
  –  No GUI
  –  Exclusive release at ZeroNights 2012
•  Latest Ruby + gem dependencies
   pre-installed:
  –  If you have issues installing BeEF, use
     the live CD (i.e. don’t bother us :-)
BeEF XHR internals
BeEF XHR internals
BeEF XHR internals
BeEF XHR internals
BeEF XHR internals
BeEF XHR internals
BeEF XHR internals
Other communication
          channels
•  WebSockets
  –  Almost real-time communication, high
     responsiveness
  –  Both WebSocket and WebSocketSecure
     are supported
  –  Just start BeEF with the following
     configuration (main config.yaml):
Attack the user
•  Trick the user to click/accept using
   visual social engineering
   techniques, like:
   –  Fake flash update
   –  Clippy
   
•  Automate WebCloning and Mass Mailing
   with the Social Engineering extension
Fake flash update
Fake flash update
                          by	
  Mike	
  Haworth,	
  an8snatchor	
  

•  Prompts the user to install an
   update to Adobe Flash Player
•  The file to be delivered could be a
   Chrome or Firefox extension

•  Chrome <= 20 is required for the
   chrome extension delivery 
•  (Chrome >= 21 enables extensions
   coming only from Google WebStore)
Clippy
Clippy
Clippy
                            by	
  vt,	
  denden	
  

•  Original code:
   http://clippy.ajbnet.com/ by sprky0
•  Display the old Microsoft Clippy
   helper icon, prompting the user to
   do stuff. Click YES:
  –  Download and run executable
  –  Click on links
  –  enter data
Social Engineering
         for the masses
•  The idea was to have new BeEF
   features, exposed with the RESTful
   API, to:
  –  send phishing emails using HTML
     templates;
  –  clone webpages, harvest credentials;
  –  client-side pwnage.
Social Engineering
 for the masses: WebCloner
•  Clone a webpage and serve it on
   BeEF, then automatically:
  –  modify the page to intercept POST
     requests.
  –  add the BeEF hook to the page
  –  if the page can be framed, after POST
     interception load the original page on
     an overlay iFrame, otherwise redirect
     to original page
Social Engineering
           for the masses: WebCloner
•  curl	
  -­‐H	
  "Content-­‐Type:	
  applica8on/json;	
  charset=UTF-­‐8"	
  -­‐d	
  
   '{"url":"hKps://	
  login.yahoo.com/config/login_verify2",	
  
   "mount":"/"}'	
  -­‐X	
  POST	
  hKp://<BeEF>/api/	
  seng/clone_page?	
  
   token=53921d2736116dbd86f8f7f7f10e46f1	
  

	
  	
  
•  If you register loginyahoo.com, you
   can specify a mount point of /config/
   login_verify2, so the phishing url
   will be (almost) the same
Social Engineering
 for the masses: MassMAiler
•  Do your phishing email campaigns 

  –  Get a sample email from your target
     (possibly with company footer/HTML)
  –  Copy the HTML content in a new BeEF
     email template
  –  Download images so they will be added
     inline.
  –  Add you malicious links/attachments
  –  Send the email to X targets -> Fun!
Social Engineering
for the masses: MassMAiler
Social Engineering
   for the masses: MassMAiler
•  curl	
  -­‐H	
  "Content-­‐Type:	
  applica8on/json;	
  charset=UTF-­‐8"	
  -­‐d	
  'body'	
  -­‐X	
  
   POST	
  hKp://<BeEF>/api/	
  seng/send_mails?
   token=0fda00ea62a1102f	
  	
  


•  Where body is:
{	
  "template":	
  "default",	
  "subject":	
  "Hi	
  from	
  BeEF",	
  	
  
	
  	
  	
  "fromname":	
  "BeEF",	
  
	
  	
  	
  "link":	
  "hKp://www.microsob.com/",	
  "linktext":	
  "hKp://	
  	
  	
  
beefproject.com",	
  "recipients":	
  [{	
  	
  
	
  	
  "user1@gmail.com":	
  "Michele",	
  "user2@an8snatchor.com":	
  	
  	
  
"An8snatchor"	
  	
  
}]}	
  	
  
Social Engineering
 for the masses: MassMAiler
•  More info about the Social
   Engineering extension:
  –  http://blog.beefproject.com/2012/09/
     beef-web-cloning-beef-mass-
     mailing.html 
  –  Read the code: <beef>/extensions/
     social_engineering/rest/
     socialengineering.rb
Attack the network
•  Identify and fingerprint alive hosts
   in the hooked browser internal
   network
  –  Port scanning
  –  Network fingerprinter -> jboss exploit
•  IPEC techniques + BeEF Bind
Attack the network: network
       fingerprinter




•  Identify common services available
   on HTTP (apache, Jboss, printers,
   etc..) given a range of IPs
Attack the network: network
       fingerprinter


•  Given an array of default image
   path, width, height, we can
   determine cross-domain if a service
   is serving that image.
Attack the network:
        Port scanner




•  Scan for default nmap ports, or
   selected ports you define, on a
   specified IP
Attack the network:
         Port scanner
•  Combines 3 methods:
  –  Image loading (similar to network
     fingerprinter)
  –  WebSockets
•  Most effective: scanning for
   selected ports (20/30 ports)
IPEC Techniques
               and BeEF Bind
•  Research released at RuxCon 2012
•  Write up here:
  –  hKp://blog.beefproject.com/2012/11/revitalizing-­‐inter-­‐
     protocol.html	
  	
  
•  Slides and screencast demo:
  –  hKp://www.slideshare.net/micheleorru2/roo8ng-­‐your-­‐
     internals-­‐exploi8ng-­‐internal-­‐network-­‐vulns-­‐via-­‐the-­‐
     browser-­‐using-­‐beef-­‐bind	
  	
  
  –  hKp://vimeo.com/52801406	
  
Hook Persistence
•  Reduce the likelihood that we will
   loose the hooked browser if the
   victim browse away:
  –  Iframe_keylogger
  –  Man in the browser
  –  Confirm close
Iframe Keylogger
                                by	
  an8snatchor	
  

•  Loads a same-domain resource in an
   overlay 100% width/eight Iframe
•  Attach a keypress listener to the
   iframe -> log keystrokes with
   Javascript
  –  Ideally you want to load the login page
     of the hooked domain
    •  And get credentials. Who cares about
       stealing cookies in 2012?
Iframe Keylogger
•  Persistence is also Achieved
  –  If the victim is browsing the in the
     same tab hooked (foreground Iframe),
     the background communication will
     still be running
•  If the target domain uses X-Frame-
   Options properly, we can’t use this
   module
Man in the Browser
                      by	
  Mathias	
  Karlsson,	
  Graziano,	
  an8snatchor	
  

•  Hijack user navigation entirely in
   Javascript
  –  Same-domain link: load the resource in
     the current page
  –  Cross-domain link: opens in new tab
  –  Form submissions are sniffed
  –  AJAX calls are hijacked too
•  Works always in Chrome/Safari/
   Firefox. Need to be ported to IE/Opera.
Confirm Close
                         by	
  an8snatchor	
  

•  Shows a confirm dialog to the user
   when he tries to close a tab. 
•  If he click yes, re-display the
   confirm dialog.
Evasion and Obfuscation
•  Default techniques
•  Whitespace encoding
•  Writing new techniques
Why?
•  There are people implementing
   dumb regexes to detect BeEF
   (hook.js, Server headers) 
•  We want to be stealthy, especially
   during pentests
The Extension
•  4 obfuscation techniques:
  –  Scramble: randomize variables/cookies
     names. regex searching for ‘beef’ fail
  –  Minify: remove whitespaces, comments
  –  Base_64: adds a bootstrapper and
     encode in base64
  –  Whitespace Encoding
The Extension
•  Write your Own!
  –  Add the ruby class into obfuscation/
     directory
  –  Implement the following methods:
    •  need_bootstrap
    •  Get_bootstrap
    •  execute
Whitespace Technique
•  ‘Kolisar’ technique ported to BeEF
   by Jean Louis Huynen (galypette)
•  Binary encoded ASCII values:
  –  0 -> tab (‘t’)
  –  1 -> space (‘ ’)
Get in touch!
•  Public mailing list: 
   –  beef-subscribe@bindshell.net
•  Twitter: @beefproject, @antisnatchor
•  GitHub: 
  –  https://github.com/beefproject/beef
•  Youtube: 
  –  http://www.youtube.com/user/
     TheBeefproject
•  Vimeo (antisnatchor): 
  –  http://vimeo.com/user1924142
Thanks
•  давайте выпьем водки

Contenu connexe

Tendances

WordPress security for everyone
WordPress security for everyoneWordPress security for everyone
WordPress security for everyoneVladimír Smitka
 
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome ExtensionsI'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome ExtensionsKrzysztof Kotowicz
 
Defending Against Application DoS attacks
Defending Against Application DoS attacksDefending Against Application DoS attacks
Defending Against Application DoS attacksRoberto Suggi Liverani
 
Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!WordCamp Cape Town
 
RIT 2009 Intellectual Pwnership
RIT 2009 Intellectual PwnershipRIT 2009 Intellectual Pwnership
RIT 2009 Intellectual PwnershipRob Fuller
 
Domino Security - not knowing is not an option (2016 edition)
Domino Security - not knowing is not an option (2016 edition)Domino Security - not knowing is not an option (2016 edition)
Domino Security - not knowing is not an option (2016 edition)Darren Duke
 
WordPress performance tuning
WordPress performance tuningWordPress performance tuning
WordPress performance tuningVladimír Smitka
 
Cloud Device Insecurity
Cloud Device InsecurityCloud Device Insecurity
Cloud Device InsecurityJeremy Brown
 
NotaCon 2011 - Networking for Pentesters
NotaCon 2011 - Networking for PentestersNotaCon 2011 - Networking for Pentesters
NotaCon 2011 - Networking for PentestersRob Fuller
 
Windows Attacks AT is the new black
Windows Attacks   AT is the new blackWindows Attacks   AT is the new black
Windows Attacks AT is the new blackRob Fuller
 
Dirty Little Secrets They Didn't Teach You In Pentest Class v2
Dirty Little Secrets They Didn't Teach You In Pentest Class v2Dirty Little Secrets They Didn't Teach You In Pentest Class v2
Dirty Little Secrets They Didn't Teach You In Pentest Class v2Rob Fuller
 
Design Reviewing The Web
Design Reviewing The WebDesign Reviewing The Web
Design Reviewing The Webamiable_indian
 
Dmk Bo2 K7 Web
Dmk Bo2 K7 WebDmk Bo2 K7 Web
Dmk Bo2 K7 Webroyans
 
A @textfiles approach to gathering the world's DNS
A @textfiles approach to gathering the world's DNSA @textfiles approach to gathering the world's DNS
A @textfiles approach to gathering the world's DNSRob Fuller
 
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015 Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015 lokeshpidawekar
 
Attacker Ghost Stories - ShmooCon 2014
Attacker Ghost Stories - ShmooCon 2014Attacker Ghost Stories - ShmooCon 2014
Attacker Ghost Stories - ShmooCon 2014Rob Fuller
 
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2Chris Gates
 
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting ClassThe Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting ClassRob Fuller
 
Cross Context Scripting attacks & exploitation
Cross Context Scripting attacks & exploitationCross Context Scripting attacks & exploitation
Cross Context Scripting attacks & exploitationRoberto Suggi Liverani
 

Tendances (20)

WordPress security for everyone
WordPress security for everyoneWordPress security for everyone
WordPress security for everyone
 
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome ExtensionsI'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions
 
Defending Against Application DoS attacks
Defending Against Application DoS attacksDefending Against Application DoS attacks
Defending Against Application DoS attacks
 
Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!
 
RIT 2009 Intellectual Pwnership
RIT 2009 Intellectual PwnershipRIT 2009 Intellectual Pwnership
RIT 2009 Intellectual Pwnership
 
Domino Security - not knowing is not an option (2016 edition)
Domino Security - not knowing is not an option (2016 edition)Domino Security - not knowing is not an option (2016 edition)
Domino Security - not knowing is not an option (2016 edition)
 
B wapp – bee bug – installation
B wapp – bee bug – installationB wapp – bee bug – installation
B wapp – bee bug – installation
 
WordPress performance tuning
WordPress performance tuningWordPress performance tuning
WordPress performance tuning
 
Cloud Device Insecurity
Cloud Device InsecurityCloud Device Insecurity
Cloud Device Insecurity
 
NotaCon 2011 - Networking for Pentesters
NotaCon 2011 - Networking for PentestersNotaCon 2011 - Networking for Pentesters
NotaCon 2011 - Networking for Pentesters
 
Windows Attacks AT is the new black
Windows Attacks   AT is the new blackWindows Attacks   AT is the new black
Windows Attacks AT is the new black
 
Dirty Little Secrets They Didn't Teach You In Pentest Class v2
Dirty Little Secrets They Didn't Teach You In Pentest Class v2Dirty Little Secrets They Didn't Teach You In Pentest Class v2
Dirty Little Secrets They Didn't Teach You In Pentest Class v2
 
Design Reviewing The Web
Design Reviewing The WebDesign Reviewing The Web
Design Reviewing The Web
 
Dmk Bo2 K7 Web
Dmk Bo2 K7 WebDmk Bo2 K7 Web
Dmk Bo2 K7 Web
 
A @textfiles approach to gathering the world's DNS
A @textfiles approach to gathering the world's DNSA @textfiles approach to gathering the world's DNS
A @textfiles approach to gathering the world's DNS
 
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015 Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015
 
Attacker Ghost Stories - ShmooCon 2014
Attacker Ghost Stories - ShmooCon 2014Attacker Ghost Stories - ShmooCon 2014
Attacker Ghost Stories - ShmooCon 2014
 
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
 
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting ClassThe Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
 
Cross Context Scripting attacks & exploitation
Cross Context Scripting attacks & exploitationCross Context Scripting attacks & exploitation
Cross Context Scripting attacks & exploitation
 

Similaire à ZeroNights2012_BeEF_Workshop_antisnatchor

BeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-OrruBeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-OrruMichele Orru
 
Krzysztof kotowicz. something wicked this way comes
Krzysztof kotowicz. something wicked this way comesKrzysztof kotowicz. something wicked this way comes
Krzysztof kotowicz. something wicked this way comesYury Chemerkin
 
Something wicked this way comes - CONFidence
Something wicked this way comes - CONFidenceSomething wicked this way comes - CONFidence
Something wicked this way comes - CONFidenceKrzysztof Kotowicz
 
Mobile Hybrid Development with WordPress
Mobile Hybrid Development with WordPressMobile Hybrid Development with WordPress
Mobile Hybrid Development with WordPressDanilo Ercoli
 
GeneralMobile Hybrid Development with WordPress
GeneralMobile Hybrid Development with WordPressGeneralMobile Hybrid Development with WordPress
GeneralMobile Hybrid Development with WordPressGGDBologna
 
Learn Electron for Web Developers
Learn Electron for Web DevelopersLearn Electron for Web Developers
Learn Electron for Web DevelopersKyle Cearley
 
Html5 Application Security
Html5 Application SecurityHtml5 Application Security
Html5 Application Securitychuckbt
 
VoxxedDays Luxembourg - Abuse web browsers for fun & profits - Dominique Righ...
VoxxedDays Luxembourg - Abuse web browsers for fun & profits - Dominique Righ...VoxxedDays Luxembourg - Abuse web browsers for fun & profits - Dominique Righ...
VoxxedDays Luxembourg - Abuse web browsers for fun & profits - Dominique Righ...YaJUG
 
Be ef presentation-securitybyte2011-michele_orru
Be ef presentation-securitybyte2011-michele_orruBe ef presentation-securitybyte2011-michele_orru
Be ef presentation-securitybyte2011-michele_orruMichele Orru
 
WordPress Security and Best Practices
WordPress Security and Best PracticesWordPress Security and Best Practices
WordPress Security and Best PracticesRobert Vidal
 
DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...
DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...
DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...Felipe Prado
 
Rails security: above and beyond the defaults
Rails security: above and beyond the defaultsRails security: above and beyond the defaults
Rails security: above and beyond the defaultsMatias Korhonen
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeededm00se
 
Chrome extensions threat analysis and countermeasures
Chrome extensions threat analysis and countermeasuresChrome extensions threat analysis and countermeasures
Chrome extensions threat analysis and countermeasuresRoel Palmaers
 
Postcards from the post xss world- content exfiltration null
Postcards from the post xss world- content exfiltration nullPostcards from the post xss world- content exfiltration null
Postcards from the post xss world- content exfiltration nullPiyush Pattanayak
 
Hacktivity2011 be ef-preso_micheleorru
Hacktivity2011 be ef-preso_micheleorruHacktivity2011 be ef-preso_micheleorru
Hacktivity2011 be ef-preso_micheleorruMichele Orru
 
JS digest. Decemebr 2017
JS digest. Decemebr 2017JS digest. Decemebr 2017
JS digest. Decemebr 2017ElifTech
 
Oscon 2011-mueller-weinre
Oscon 2011-mueller-weinreOscon 2011-mueller-weinre
Oscon 2011-mueller-weinrepmuellr
 

Similaire à ZeroNights2012_BeEF_Workshop_antisnatchor (20)

BeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-OrruBeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-Orru
 
Krzysztof kotowicz. something wicked this way comes
Krzysztof kotowicz. something wicked this way comesKrzysztof kotowicz. something wicked this way comes
Krzysztof kotowicz. something wicked this way comes
 
Something wicked this way comes - CONFidence
Something wicked this way comes - CONFidenceSomething wicked this way comes - CONFidence
Something wicked this way comes - CONFidence
 
Mobile Hybrid Development with WordPress
Mobile Hybrid Development with WordPressMobile Hybrid Development with WordPress
Mobile Hybrid Development with WordPress
 
GeneralMobile Hybrid Development with WordPress
GeneralMobile Hybrid Development with WordPressGeneralMobile Hybrid Development with WordPress
GeneralMobile Hybrid Development with WordPress
 
Learn Electron for Web Developers
Learn Electron for Web DevelopersLearn Electron for Web Developers
Learn Electron for Web Developers
 
Html5 Application Security
Html5 Application SecurityHtml5 Application Security
Html5 Application Security
 
VoxxedDays Luxembourg - Abuse web browsers for fun & profits - Dominique Righ...
VoxxedDays Luxembourg - Abuse web browsers for fun & profits - Dominique Righ...VoxxedDays Luxembourg - Abuse web browsers for fun & profits - Dominique Righ...
VoxxedDays Luxembourg - Abuse web browsers for fun & profits - Dominique Righ...
 
Be ef presentation-securitybyte2011-michele_orru
Be ef presentation-securitybyte2011-michele_orruBe ef presentation-securitybyte2011-michele_orru
Be ef presentation-securitybyte2011-michele_orru
 
WordPress Security and Best Practices
WordPress Security and Best PracticesWordPress Security and Best Practices
WordPress Security and Best Practices
 
Burpsuite yara
Burpsuite yaraBurpsuite yara
Burpsuite yara
 
DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...
DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...
DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...
 
Rails security: above and beyond the defaults
Rails security: above and beyond the defaultsRails security: above and beyond the defaults
Rails security: above and beyond the defaults
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
 
Chrome extensions threat analysis and countermeasures
Chrome extensions threat analysis and countermeasuresChrome extensions threat analysis and countermeasures
Chrome extensions threat analysis and countermeasures
 
Security 101
Security 101Security 101
Security 101
 
Postcards from the post xss world- content exfiltration null
Postcards from the post xss world- content exfiltration nullPostcards from the post xss world- content exfiltration null
Postcards from the post xss world- content exfiltration null
 
Hacktivity2011 be ef-preso_micheleorru
Hacktivity2011 be ef-preso_micheleorruHacktivity2011 be ef-preso_micheleorru
Hacktivity2011 be ef-preso_micheleorru
 
JS digest. Decemebr 2017
JS digest. Decemebr 2017JS digest. Decemebr 2017
JS digest. Decemebr 2017
 
Oscon 2011-mueller-weinre
Oscon 2011-mueller-weinreOscon 2011-mueller-weinre
Oscon 2011-mueller-weinre
 

ZeroNights2012_BeEF_Workshop_antisnatchor

  • 1. All you ever wanted to know about BeEF Antisnatchor – ZeroNights 2012 - Москва
  • 2. About antisnatchor •  Lead core developer of BeEF •  Application security researcher •  Loves Ruby, Javascript and OpenBSD •  Kubrick fan •  Водка fan
  • 3. BeEF •  The most robust framework to control the browser of a victim entirely with Javascript. •  Each browser is likely to be within a different security context, and each context may provide a set of unique attack vectors.
  • 5. Lets start to play with it •  BeEF Live CD -­‐>  thanks  Ben  Waugh   –  Based on Ubuntu L –  Latest (GIT): BeEF, Metasploit, sqlmap –  No GUI –  Exclusive release at ZeroNights 2012 •  Latest Ruby + gem dependencies pre-installed: –  If you have issues installing BeEF, use the live CD (i.e. don’t bother us :-)
  • 13. Other communication channels •  WebSockets –  Almost real-time communication, high responsiveness –  Both WebSocket and WebSocketSecure are supported –  Just start BeEF with the following configuration (main config.yaml):
  • 14. Attack the user •  Trick the user to click/accept using visual social engineering techniques, like: –  Fake flash update –  Clippy •  Automate WebCloning and Mass Mailing with the Social Engineering extension
  • 16. Fake flash update by  Mike  Haworth,  an8snatchor   •  Prompts the user to install an update to Adobe Flash Player •  The file to be delivered could be a Chrome or Firefox extension •  Chrome <= 20 is required for the chrome extension delivery •  (Chrome >= 21 enables extensions coming only from Google WebStore)
  • 19. Clippy by  vt,  denden   •  Original code: http://clippy.ajbnet.com/ by sprky0 •  Display the old Microsoft Clippy helper icon, prompting the user to do stuff. Click YES: –  Download and run executable –  Click on links –  enter data
  • 20. Social Engineering for the masses •  The idea was to have new BeEF features, exposed with the RESTful API, to: –  send phishing emails using HTML templates; –  clone webpages, harvest credentials; –  client-side pwnage.
  • 21. Social Engineering for the masses: WebCloner •  Clone a webpage and serve it on BeEF, then automatically: –  modify the page to intercept POST requests. –  add the BeEF hook to the page –  if the page can be framed, after POST interception load the original page on an overlay iFrame, otherwise redirect to original page
  • 22. Social Engineering for the masses: WebCloner •  curl  -­‐H  "Content-­‐Type:  applica8on/json;  charset=UTF-­‐8"  -­‐d   '{"url":"hKps://  login.yahoo.com/config/login_verify2",   "mount":"/"}'  -­‐X  POST  hKp://<BeEF>/api/  seng/clone_page?   token=53921d2736116dbd86f8f7f7f10e46f1       •  If you register loginyahoo.com, you can specify a mount point of /config/ login_verify2, so the phishing url will be (almost) the same
  • 23. Social Engineering for the masses: MassMAiler •  Do your phishing email campaigns –  Get a sample email from your target (possibly with company footer/HTML) –  Copy the HTML content in a new BeEF email template –  Download images so they will be added inline. –  Add you malicious links/attachments –  Send the email to X targets -> Fun!
  • 24. Social Engineering for the masses: MassMAiler
  • 25. Social Engineering for the masses: MassMAiler •  curl  -­‐H  "Content-­‐Type:  applica8on/json;  charset=UTF-­‐8"  -­‐d  'body'  -­‐X   POST  hKp://<BeEF>/api/  seng/send_mails? token=0fda00ea62a1102f     •  Where body is: {  "template":  "default",  "subject":  "Hi  from  BeEF",          "fromname":  "BeEF",        "link":  "hKp://www.microsob.com/",  "linktext":  "hKp://       beefproject.com",  "recipients":  [{        "user1@gmail.com":  "Michele",  "user2@an8snatchor.com":       "An8snatchor"     }]}    
  • 26. Social Engineering for the masses: MassMAiler •  More info about the Social Engineering extension: –  http://blog.beefproject.com/2012/09/ beef-web-cloning-beef-mass- mailing.html –  Read the code: <beef>/extensions/ social_engineering/rest/ socialengineering.rb
  • 27. Attack the network •  Identify and fingerprint alive hosts in the hooked browser internal network –  Port scanning –  Network fingerprinter -> jboss exploit •  IPEC techniques + BeEF Bind
  • 28. Attack the network: network fingerprinter •  Identify common services available on HTTP (apache, Jboss, printers, etc..) given a range of IPs
  • 29. Attack the network: network fingerprinter •  Given an array of default image path, width, height, we can determine cross-domain if a service is serving that image.
  • 30. Attack the network: Port scanner •  Scan for default nmap ports, or selected ports you define, on a specified IP
  • 31. Attack the network: Port scanner •  Combines 3 methods: –  Image loading (similar to network fingerprinter) –  WebSockets •  Most effective: scanning for selected ports (20/30 ports)
  • 32. IPEC Techniques and BeEF Bind •  Research released at RuxCon 2012 •  Write up here: –  hKp://blog.beefproject.com/2012/11/revitalizing-­‐inter-­‐ protocol.html     •  Slides and screencast demo: –  hKp://www.slideshare.net/micheleorru2/roo8ng-­‐your-­‐ internals-­‐exploi8ng-­‐internal-­‐network-­‐vulns-­‐via-­‐the-­‐ browser-­‐using-­‐beef-­‐bind     –  hKp://vimeo.com/52801406  
  • 33. Hook Persistence •  Reduce the likelihood that we will loose the hooked browser if the victim browse away: –  Iframe_keylogger –  Man in the browser –  Confirm close
  • 34. Iframe Keylogger by  an8snatchor   •  Loads a same-domain resource in an overlay 100% width/eight Iframe •  Attach a keypress listener to the iframe -> log keystrokes with Javascript –  Ideally you want to load the login page of the hooked domain •  And get credentials. Who cares about stealing cookies in 2012?
  • 35. Iframe Keylogger •  Persistence is also Achieved –  If the victim is browsing the in the same tab hooked (foreground Iframe), the background communication will still be running •  If the target domain uses X-Frame- Options properly, we can’t use this module
  • 36. Man in the Browser by  Mathias  Karlsson,  Graziano,  an8snatchor   •  Hijack user navigation entirely in Javascript –  Same-domain link: load the resource in the current page –  Cross-domain link: opens in new tab –  Form submissions are sniffed –  AJAX calls are hijacked too •  Works always in Chrome/Safari/ Firefox. Need to be ported to IE/Opera.
  • 37. Confirm Close by  an8snatchor   •  Shows a confirm dialog to the user when he tries to close a tab. •  If he click yes, re-display the confirm dialog.
  • 38. Evasion and Obfuscation •  Default techniques •  Whitespace encoding •  Writing new techniques
  • 39. Why? •  There are people implementing dumb regexes to detect BeEF (hook.js, Server headers) •  We want to be stealthy, especially during pentests
  • 40. The Extension •  4 obfuscation techniques: –  Scramble: randomize variables/cookies names. regex searching for ‘beef’ fail –  Minify: remove whitespaces, comments –  Base_64: adds a bootstrapper and encode in base64 –  Whitespace Encoding
  • 41. The Extension •  Write your Own! –  Add the ruby class into obfuscation/ directory –  Implement the following methods: •  need_bootstrap •  Get_bootstrap •  execute
  • 42. Whitespace Technique •  ‘Kolisar’ technique ported to BeEF by Jean Louis Huynen (galypette) •  Binary encoded ASCII values: –  0 -> tab (‘t’) –  1 -> space (‘ ’)
  • 43. Get in touch! •  Public mailing list: –  beef-subscribe@bindshell.net •  Twitter: @beefproject, @antisnatchor •  GitHub: –  https://github.com/beefproject/beef •  Youtube: –  http://www.youtube.com/user/ TheBeefproject •  Vimeo (antisnatchor): –  http://vimeo.com/user1924142