Presented to OWASP San Antonio at Denim Group Introduction to Cross-Site Scripting with BeEF Created by: Charles Neill Modified Date: 2/5/2015.

Slides:



Advertisements
Similar presentations
Nick Feamster CS 6262 Spring 2009
Advertisements

Cross Site Scripting (XSS)
What is code injection? Code injection is the exploitation of a computer bug that is caused by processing invalid data. Code injection can be used by.
Creating Stronger, Safer, Web Facing Code JPL IT Security Mary Rivera June 17, 2011.
The XSS Files Find, Exploit, and Eliminate. Josh Little Security Engineer at global vertical market business intelligence company. 9 years in application.
©2009 Justin C. Klein Keane PHP Code Auditing Session 5 XSS & XSRF Justin C. Klein Keane
Cross Site Scripting & SQL injection
WebGoat & WebScarab “What is computer security for $1000 Alex?”
EECS 354 Network Security Cross Site Scripting (XSS)
Cross Site Scripting a.k.a. XSS Szymon Siewior. Disclaimer Everything that will be shown, was created for strictly educational purposes. You may reuse.
COMP 321 Week 12. Overview Web Application Security  Authentication  Authorization  Confidentiality Cross-Site Scripting Lab 12-1 Introduction.
9/9/2005 Developing "Secure" Web Applications 1 Methods & Concepts for Developing “Secure” Web Applications Peter Y. Hammond, Developer Wasatch Front Regional.
By Brian Vees.  SQL Injection  Username Enumeration  Cross Site Scripting (XSS)  Remote Code Execution  String Formatting Vulnerabilities.
Server-Side vs. Client-Side Scripting Languages
Sara SartoliAkbar Siami Namin NSF-SFS workshop July 14-18, 2014.
Browser Exploitation Framework (BeEF) Lab
© 2003 School of Computing, University of Leeds SY32 Secure Computing, Lecture 14 Implementation Flaws Part 2: Malicious Input and Data Validation Issues.
Introduction to the OWASP Top 10. Cross Site Scripting (XSS)  Comes in several flavors:  Stored  Reflective  DOM-Based.
Lecture 16 Page 1 CS 236 Online Cross-Site Scripting XSS Many sites allow users to upload information –Blogs, photo sharing, Facebook, etc. –Which gets.
CROSS SITE SCRIPTING..! (XSS). Overview What is XSS? Types of XSS Real world Example Impact of XSS How to protect against XSS?
1 SQL injection: attacks and defenses Dan Boneh CS 142 Winter 2009.
Lab 3 Cookie Stealing using XSS Kara James, Chelsea Collins, Trevor Norwood, David Johnson.
Handling Security Threats in Kentico CMS Karol Jarkovsky Sr. Solution Architect Kentico Software
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
WEB SECURITY WORKSHOP TEXSAW 2013 Presented by Joshua Hammond Prepared by Scott Hand.
Introduction to InfoSec – Recitation 10 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Workshop 3 Web Application Security Li Weichao March
PHP Security.
Cosc 4765 Server side Web security. Web security issues From Cenzic Vulnerability report
Cross-Site Scripting Vulnerabilities Adam Doupé 11/24/2014.
Prevent Cross-Site Scripting (XSS) attack
Dynamic Web Pages (Flash, JavaScript)
+ Websites Vulnerabilities. + Content Expand of The Internet Use of the Internet Examples Importance of the Internet How to find Security Vulnerabilities.
WEB SECURITY WEEK 3 Computer Security Group University of Texas at Dallas.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Web Application Access to Databases. Logistics Test 2: May 1 st (24 hours) Extra office hours: Friday 2:30 – 4:00 pm Tuesday May 5 th – you can review.
© All rights reserved. Zend Technologies, Inc. PHP Security Kevin Schroeder Zend Technologies.
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
Copyright 2007 © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Lecture 16 Page 1 CS 236 Online SQL Injection Attacks Many web servers have backing databases –Much of their information stored in a database Web pages.
Srikar Nadipally. Outline Finding and Exploiting XSS Vulnerabilities Standard Reflected XSS Stored XSS DOM based XSS Prevention of XSS attack Reflect.
Security Scanners Mark Shtern. Popular attack targets Web – Web platform – Web application Windows OS Mac OS Linux OS Smartphone.
School of Computing and Information Systems CS 371 Web Application Programming Security Avoiding and Preventing Attacks.
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 1 RubyJax Brent Morris/
OWASP Top Ten #1 Unvalidated Input. Agenda What is the OWASP Top 10? Where can I find it? What is Unvalidated Input? What environments are effected? How.
PHP2010/11 : [‹#›] PHP Security. PHP2010/11 : [‹#›] Two Golden Rules 1.FILTER external input Obvious.. $_POST, $_COOKIE, etc. Less obvious.. $_SERVER.
October 3, 2008IMI Security Symposium Application Security through a Hacker’s Eyes James Walden Northern Kentucky University
COOKIES and SESSIONS. COOKIES A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each.
By Sean Rose and Erik Hazzard.  SQL Injection is a technique that exploits security weaknesses of the database layer of an application in order to gain.
Cross Site Scripting and its Issues By Odion Oisamoje.
Crash Course in Web Hacking
Lecture 16 Page 1 CS 236 Online Web Security CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Presented By: Chandra Kollipara. Cross-Site Scripting: Cross-Site Scripting attacks are a type of injection problem, in which malicious scripts are injected.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
What Is XSS ? ! Cross-site scripting (XSS) is a type of computer security vulnerability typically found in Web applications. XSS enables attackers to.
By Collin Donaldson. Hacking is only legal under the following circumstances: 1.You hack (penetration test) a device/network you own. 2.You gain explicit,
JavaScript Invented 1995 Steve, Tony & Sharon. A Scripting Language (A scripting language is a lightweight programming language that supports the writing.
The OWASP Foundation OWASP XSS Remediation Cassia Martin Romain Gaucher April 7 th, 2011.
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
Javascript worms By Benjamin Mossé SecPro
Google’s Gruyere1 : An XSS Example Presented by: Terry Gregory
An Introduction to Web Application Security
Tonga Institute of Higher Education IT 141: Information Systems
CS 371 Web Application Programming
SQL Injection Attacks Many web servers have backing databases
Tonga Institute of Higher Education IT 141: Information Systems
CSC 495/583 Topics of Software Security Intro to Web Security
Tonga Institute of Higher Education IT 141: Information Systems
Presentation transcript:

Presented to OWASP San Antonio at Denim Group Introduction to Cross-Site Scripting with BeEF Created by: Charles Neill Modified Date: 2/5/2015

What is cross-site scripting? Cross-Site Scripting (referred to as XSS) is a type of web application attack where malicious client-side script is injected into the application output and subsequently executed by the user’s browser TL;DR: Not filtering out HTML and JavaScript in user input = bad It can be used to take over a user’s browser in a variety of ways 2

Why should I care about cross-site scripting? There was a time not too long ago when XSS was considered a low-risk type of security issue, because when compared to a server-side exploit, it seemed relatively benign As other issues like PHP remote file inclusions have become harder to exploit, XSS attacks have increased in prominence and sophistication Trick question: Which is worse, popping up an alert box or popping root on a server? 3

Who’s affected by cross-site scripting? Everyone. No, really – almost every site you can think of has had XSS problems at one time or another (and probably still does) Don’t believe me? Universal XSS in Internet Explorer (2015) [1] Tweetdeck (2014) [2]Tweetdeck PayPal (2013) – BONUS: discovered by a 17 year old kid [3]PayPal Google Finance (2013) [4]Google Finance 25 “Verasign-secured” online stores (2012) [5]25 “Verasign-secured” online stores McAfee (2011) [6]McAfee Visa (2010) [7]Visa 4

5 Some sites you might recognize

Object Placeholder 6 Some sites you might recognize

Object Placeholder 7 Some sites you might recognize

Boooooring… The classic proof-of-concept for XSS is a little alert box with some arbitrary text in it, or a picture of something silly. This doesn’t seem nearly dangerous enough to warrant concern. What else you got? 8

Introducing: BeEF What’s BeEF? From their website (beefproject.com):beefproject.com “BeEF is short for The Browser Exploitation Framework… BeEF looks past the hardened network perimeter and client system, and examines exploitability within the context of the one open door: the web browser.” 9

That description sounds scary, but what does it mean? Think of BeEF as a one-stop-shop to gain and retain control over a user’s browser, and do whatever you want with it This is like Metasploit (metasploit.com) for the browsermetasploit.com –You can even use Metasploit’s “browser_autopwn” tests to try to take over the browser How does one use BeEF? This is all it takes to insert into a page: Where’s the BeEF? 10

11 The BeEF Dashboard Monitor users by their IP, browser, OS See logs of their activity Trick the user into downloading malicious files Perform network reconnaissance And much more..

12 DEMO TIME! (Get excited)

So many attacks, so little time

Steal cookies Play a sound Get user-agent string See enabled plugins (e.g. Chrome PDF viewer, Java, etc.) 14 Basic Client-side Attacks

Man-in-the-browser Forge user requests Get form values / HTML contents Fake notifications (Chrome plugin bar, LastPass login, etc.) Tabnabbing 15 More Advanced Client-Side Attacks

Port scanning Network mapping Execute local Redis commands 16 Lateral Movement / Network Exploration

Never trust the user So what should I do to prevent XSS? 17

THANK YOU RACKSPACE® | 1 FANATICAL PLACE, CITY OF WINDCREST | SAN ANTONIO, TX US SALES: | US SUPPORT: | © RACKSPACE LTD. | RACKSPACE® AND FANATICAL SUPPORT® ARE SERVICE MARKS OF RACKSPACE US, INC. REGISTERED IN THE UNITED STATES AND OTHER COUNTRIES. |

Almost all client-side script injection comes down to the following characters: ( ) { } [ ] " ' ; / \ There are various ways to take care of these characters, but it is too context- dependent to give a one-size-fits-all answer The shortest answer is, make sure you’re only getting characters you expect when a user enters any kind of information - make sure you never display a user-entered string without properly encoding it Check out the links at the end of this presentation to learn more So what should I do to prevent XSS? (No, really) 19

Here’s some sample vulnerable JavaScript. See if you can spot the bad part. var lol = function () { var a = document.getElementById('a').value; document.write(a); } 20 Examples of XSS in code

Hmm, there’s the problem… var lol = function () { var a = document.getElementById('a').value; document.write(a); // Too easy } 21 Examples of XSS in code

Now for something a little more interesting. Remember, you also have to remember the third-party libraries you’re using. Some innocent-looking jQuery code: $(location.hash) // Wait, that’s it? 22 Examples of XSS in code

But you’re not only securing the code you write, but all the code you used… $(location.hash) // WHERE’S THE VULNERABLE PART?! Well, if we’re using jQuery and we visit the page …this will pop up one of those alert boxes [8]. 23 Examples of XSS in code

Here are some examples of how to filter HTML characters in a few simple scenarios in PHP (there should be similar functions in any language; check the links at the end of the PPT) $int = intval($_GET['a']); // This will never return anything other than an integer $str = htmlentities($_GET['b']); // This will encode any character for which there is // an HTML entity equivalent (e.g. > < ") // This is NOT always enough! [9] 24 Tips for filtering XSS

Pop quiz! What’s wrong with this PHP code: echo(' link '); 25 Getting around prevention measures

Pop quiz! What’s wrong with this PHP code: echo(' link '); What if we set $_GET['var'] to javascript:alert(/xss/); 26 Getting around prevention measures

27

QUESTIONS? 28

OWASP Links –Guide to Cross-site Scripting - –XSS Prevention Cheat Sheet - –DOM based XSS Prevention Cheat Sheet Resources

[1] [2] [3] [4] [5] [6] [7] [8] [9] 30 References

THANK YOU RACKSPACE® | 1 FANATICAL PLACE, CITY OF WINDCREST | SAN ANTONIO, TX US SALES: | US SUPPORT: | © RACKSPACE LTD. | RACKSPACE® AND FANATICAL SUPPORT® ARE SERVICE MARKS OF RACKSPACE US, INC. REGISTERED IN THE UNITED STATES AND OTHER COUNTRIES. |