52
Computer Science and Engineering 1 Web Application Hacker’s Toolkit

Web Application Hacker’s Toolkit

  • Upload
    alda

  • View
    55

  • Download
    2

Embed Size (px)

DESCRIPTION

Web Application Hacker’s Toolkit. Review. Web Applications characteristics. Functionality. Server side technologies: Scripting languages Web application platform Web server software Databases Back-end components Client-side technologies: Browser Extension technologies. - PowerPoint PPT Presentation

Citation preview

Page 1: Web Application Hacker’s Toolkit

Computer Science and Engineering 1

Web Application Hacker’s Toolkit

Page 2: Web Application Hacker’s Toolkit

ReviewReview

• Web Applications characteristics

Computer Science and Engineering 2

Page 3: Web Application Hacker’s Toolkit

FunctionalityFunctionality

• Server side technologies:– Scripting languages– Web application platform– Web server software– Databases– Back-end components

• Client-side technologies: – Browser Extension technologies

Computer Science and Engineering 3

Page 4: Web Application Hacker’s Toolkit

Application Application CharacteristicsCharacteristics

• Understand what application does and how it behaves– Content– Functionality

• Find out:– Application behavior– Core security mechanisms– Technologies being used

Computer Science and Engineering 4

Page 5: Web Application Hacker’s Toolkit

Enumerating Content Enumerating Content and Functionalityand Functionality

• Manual vs. automated browsing– Walk through the application– Follow every link– Navigate through multistage functions

• Web spidering– Tools to follow all links until no new content is

found– Can parse static HTML, multi-stage functionality,

form-based navigation, client-side JavaScript

Computer Science and Engineering 5

Page 6: Web Application Hacker’s Toolkit

Automated SpideringAutomated Spidering

• E.g., Burp Spider, WebScarab• General limitations:

– Cannot handle dynamically created menus– Limited depth to find links– May fail input validation for multistage functionality – Unique content is identified by URL not good for

form-based navigation– May fail authentication session

Computer Science and Engineering 6

Page 7: Web Application Hacker’s Toolkit

User Directed SpideringUser Directed Spidering

• User walks through the application and uses a spider to collect and analyze findings

• Good for– Unusual or complex navigation needs– User control of input data– User can login to application and pass authentication – User can decide on requested functions

Computer Science and Engineering 7

Page 8: Web Application Hacker’s Toolkit

APPLICATION HACKINGAPPLICATION HACKING

Computer Science and Engineering 8

Page 9: Web Application Hacker’s Toolkit

Hacking Steps 1.Hacking Steps 1.

• Configure browser to use spider• Browse the application normally

– Visit every link– Proceed through multi-stage functions– JavaScrip enabled/disabled; cookies

enabled/disabled• Review site map to identify non-visited content• Do an automated spidering

Computer Science and Engineering 9

Page 10: Web Application Hacker’s Toolkit

Discovering Hidden Discovering Hidden ContentContent

• Not directly linked to or reachable from the main page– E.g., testing and debugging content, different

functionality for different types of users, backup copies, archives, old version of files, default application functionality, log files, etc.

• Added attack points, sensitive content, etc. • Automated, brute-force attack: Burp Intruder

– Burp Suite Tutorial – The Intruder Tool, http://www.securityninja.co.uk/hacking/burp-suite-tutorial-the-intruder-tool/

Computer Science and Engineering 10

Page 11: Web Application Hacker’s Toolkit

Hacking Steps 2Hacking Steps 2

• Make unusual requests and identify response• Use site map to identify hidden content• Use brute-force attacks to identify how application handles requests• Manually review responses• Inferencing from published content (e.g., naming)

– Compile list of names of subdirectories– Identify naming schemes, file extensions– Review all client side code– Look at temporary files

Computer Science and Engineering 11

Page 12: Web Application Hacker’s Toolkit

Use Public InformationUse Public Information

• Find old resources• Search Engines:

– Advanced Search: resource, login, links, related– Google domains– Omitted results– Cashed versions– Other domains of the same organization

• Web archives, e.g., WayBack Machine

Computer Science and Engineering 12

Page 13: Web Application Hacker’s Toolkit

Web Server Web Server VulnerabilitiesVulnerabilities

• Web server software vulnerability

– Default content

– Sample and diagnostic scripts

– Standard functionality

• Wikto: a tool that checks for flaws in web servers

– http://sectools.org/tool/wikto/

• Nikto: checks for potentially dangerous files/CGIs, checks for outdated versions of over 1200 servers, and version specific problems, configuration issues, etc.  http://sectools.org/tool/nikto

Computer Science and Engineering 13

Page 14: Web Application Hacker’s Toolkit

Additional MappingsAdditional Mappings

• Functional paths – URL query parameters

• Discovering Hidden Parameters– Try default parameter names, e.g, debug, test, hide,

etc.– Monitor responses to identify anomalies

• Analyzing Applications– Functionality, behavior, security

• Server side functionality

Computer Science and Engineering 14

Page 15: Web Application Hacker’s Toolkit

Mapping the Attack Mapping the Attack SurfaceSurface

• Use the results of the analysis to find vulnerabilities

Computer Science and Engineering 15

Page 16: Web Application Hacker’s Toolkit

Easy picking: @Easy picking: @

• Hidden symbol in URL • Change IP address (only the info to the right of @

is used)• Browser vulnerability

– “You are about to log in to the site “cse.sc.edu” with the username “farkas”, but the website does not require authentication. This may be an attempt to trick you.”

• Twitter – executable JavaScript after @

16

Page 17: Web Application Hacker’s Toolkit

Who is at risk?Who is at risk?

• Client: browsers– Complex systems– Plug-ins, extensions– Server authentication

• JavaScript and paid ads ease of propagating malicious code

• Never trust a client on the server side• Never trust a browser on the client side

17

Page 18: Web Application Hacker’s Toolkit

Improve client securityImprove client security

• Install patches to the browser• Update commonly used plug-ins• Eliminate unused plug-ins• Heed your browser warnings• Make antivirus software watch browser and

downloads• Clear history, stored files, and cookies• If a file is not signed and trusted, don’t download it

18

Page 19: Web Application Hacker’s Toolkit

Improve server side Improve server side securitysecurity

• Never execute client input as code• Never allow client input to pass into the system without

validating it internally• Scrub client input for any known exploits and suspect

characters• Keep a layer of indirection between client input received and

the system• Manage sessions from inside the trust boundary and not on the

client side• Never encode secrets of functional variables in information

sent to the clies.

19

Page 20: Web Application Hacker’s Toolkit

Web Application Web Application Vulnerabilities Vulnerabilities

Computer Science and Engineering 20

Page 21: Web Application Hacker’s Toolkit

Biggest Threats to Biggest Threats to Web ApplicationsWeb Applications

• Cross-site scripting (XSS)• Cross-site request forgeries (CSRF)• Remote file uploads, (buffer overflow, SQL injection,

etc.)

• Trust between the client’s machine and the web applications.

21

Page 22: Web Application Hacker’s Toolkit

XSSXSS

• Inject client-side script into Web pages• Client views web page download script • Used for bypass access controls such as the same origin

policy– Permits scripts running on pages originating from the

same site ( scheme, hostname, and port number)  to access each other's Document Object Model with no specific restrictions

• XMLHttpRequest and Robots.txt

Computer Science and Engineering 22

Page 23: Web Application Hacker’s Toolkit

How to avoid XSS?How to avoid XSS?

• Scrub all input• Escape output for display• Use trusted solutions when available• Use separate variables for scrubbed input

23

Page 24: Web Application Hacker’s Toolkit

Cross-site request Cross-site request forgeryforgery

• Exploits the trust between server and client machine• Mostly http requests and responses• Based on how web pages are delivered along with

images and other web content

Page 25: Web Application Hacker’s Toolkit

Prevent CSRFPrevent CSRF

• Require verification and stages for sensitive applications

• Use anti-CSRF tokens in your forms and processing• Use post as the mean of taking form input

– Get: encodes the data of the form into the url of the recipient, appending it to the query string of the request

– Post: encodes it as a message

Page 26: Web Application Hacker’s Toolkit

Unrestricted file uploadUnrestricted file upload

• Users may upload malicious files• Uploaded files can be called by a url (if stored on the

web server)• Example: php

– Embedded in image files– Compile php code

26

Page 27: Web Application Hacker’s Toolkit

Avoid file upload Avoid file upload problemsproblems

• System should determine file name• Do not allow users to access the folders where content

is uploaded• Parse file extensions carefully or set your own file

parser• White list extensions• Be secure with the .htaccess file (controls accesses to

the files on the server

27

Page 28: Web Application Hacker’s Toolkit

Adobe FlashAdobe Flash

• 99% of all internet connected machines use AdobeFlesh• No internal automated update capability• Flash security policy: Same Origin

– Can be modified by XML cross-domain policy declaration

• Can facilitate XSS, CSRF, DNS rebiding

28

Page 29: Web Application Hacker’s Toolkit

Ways of Attacking Ways of Attacking ApplicationsApplications

• Use of a web browser only• Use of an intercepting web proxy• Use of a standalone application scanner

Computer Science and Engineering 29

Page 30: Web Application Hacker’s Toolkit

Web BrowsersWeb Browsers

• Choice of web browser impacts the effectiveness of the attack

• Most popular browsers:– Internet Explorer– Firefox– Chrome

• Extensions: additional web browser functionalities

Computer Science and Engineering 30

Page 31: Web Application Hacker’s Toolkit

IEIE

• Declining number of users but still the leader• Native support for ActiveX control• Must work with Windows platform • Anti-XSS filter with IE 8• Extensions:

– HttpWatch: analyzes HTTP requests and responses, details of headers, cookies, URLs, request parameters, HTTP status codes, and redirect

Computer Science and Engineering 31

Page 32: Web Application Hacker’s Toolkit

Integrated Testing Suits Integrated Testing Suits

• Intercepting proxy• Achilles proxy: early, basic proxy, standalone

application, displayed each request and response for editing

• Modern proxies: – Highly functional tool suits– Several interconnected tools to facilitate common

tasks of attacks– Useful for both defense and offense

Computer Science and Engineering 32

Page 33: Web Application Hacker’s Toolkit

Some of the ToolsSome of the Tools

• Differ widely in their functionalities• The best one: Burp Suite• Others:

– WebScarab

– Paros

– Zed Attack Proxy

– Andiparos

– Fiddler

– Etc.

Computer Science and Engineering 33

Page 34: Web Application Hacker’s Toolkit

How the Tools WorkHow the Tools Work

• Several complementary tools that share information about the target application

Computer Science and Engineering 34

IE

Attacker Target application

Toolkit: monitors interaction between the attacker and the targetapplication. Stores all requests and responses and all detailsabout the target application.

Page 35: Web Application Hacker’s Toolkit

Toolkit ElementsToolkit Elements

1. An intercepting proxy

2. A web application spider

3. A customizable web application fuzzer

4. A vulnerability scanner

5. A manual request tool

6. Functions for analyzing session cookies and tokens

7. Other functions and utilities

Computer Science and Engineering 35

Page 36: Web Application Hacker’s Toolkit

1. Intercepting Proxies1. Intercepting Proxies

• Must configure the attacker’s browser to use an intercepting proxy (listen at a specified port)– Can be easily configured for the 3 most popular

browsers• If you are using a thick client and cannot configure a

proxy you need to modify the OS files to resolve the hostname used by the application to allow the proxy to listen on this communication

Computer Science and Engineering 36

Page 37: Web Application Hacker’s Toolkit

1. Intercepting Proxies1. Intercepting Proxies

• Basic HTTP messages: Intercepting proxy acts as a normal web proxy

Computer Science and Engineering 37

IE

Attacker

The web browser send the hostnameof the application.

The proxy resolves the corresponding IP addressand converts the request to a non-proxy equivalent message.

ProxyCONNECT

Page 38: Web Application Hacker’s Toolkit

Computer Science and Engineering 38

1. Normal Web Proxy1. Normal Web Proxy

• HTTPS messages

Computer Science and Engineering 38

IE

Client

Proxy

After the connection wasestablished, the proxy acts as a TCP-levelrelay between the client and the application.

CONNECT

SSL handshake

Page 39: Web Application Hacker’s Toolkit

Computer Science and Engineering 39

Computer Science and Engineering 39

1. Intercepting Proxy1. Intercepting Proxy

• HTTPS messages

Computer Science and Engineering 39

IE

Attacker

Proxy

After the connection wasestablished, the proxy acts as a TCP-levelrelay between the client and the application.

CONNECT

SSL handshake SSL handshake

Page 40: Web Application Hacker’s Toolkit

Computer Science and Engineering 40

40

SSL HandshakeSSL Handshake

1. C S: CLIENTHELLO2. S C: SERVERHELLO

[CERTIFICATE]

[SERVERKEYEXCHANGE]

[CERTIFICATEREQUEST]

SERVERHELLODONE3. C S: [CERTIFICATE]

CLIENTKEYEXCHANGE[CERTIFICATEVERIFY]CHANGECIPHERSPECFINISH

4. S C: CHANGECIPHERSPECFINISH

Phase 1

Phase 2

Phase 3

Phase 4

Security capabilities

Optional server messages

Client key exchange

Change cipher suite

Page 41: Web Application Hacker’s Toolkit

Fake CertificatesFake Certificates

• Proxies certificate may not be accepted– Cross-domain requests– Users’ trust

• Burp Suite: generates a unique CA certificate for the current user. Use this to generate new certificates for the proxy.

Computer Science and Engineering 41

Page 42: Web Application Hacker’s Toolkit

Common features of the Common features of the Intercepting ProxiesIntercepting Proxies

• Fine-grained intercepting rules• Detailed history of all requests and responses• Automated match and replace rules for dynamic

modification of the requests and responses• Access to proxy’s functionality within the web browser• Utilities

Computer Science and Engineering 42

Page 43: Web Application Hacker’s Toolkit

2. Web Application 2. Web Application SpiderSpider

• Share data with intercepting proxies• Manual spidering followed by automated spidering• Challenges:

– Form-based navigation

– JavaScript enabled navigation

– Multistage functions

– Authentication and sessions

– Parameter-based identifications

– Tokens and cookies

Computer Science and Engineering 43

Page 44: Web Application Hacker’s Toolkit

Common Functionalities Common Functionalities of Web Spiders of Web Spiders

• Automatic update or the site map based on data supplied by the proxy

• Parsing proxy data for links• Fine-grained control over the scope of spidering• Automatic parsing and analysis of HTML forms,

scripts, comments, images• Automated and user-guided submission of forms• Automatic retrieval of the root of all enumerated

directories

Computer Science and Engineering 44

Page 45: Web Application Hacker’s Toolkit

3. Web Application 3. Web Application FuzzersFuzzers

• Use automation to perform common attack tasks• Common features:

– Manually configured probing for common vulnerabilities

– A set of built-in payload and functions to generate arbitrary payload

– Save attack results and response data

– Customizable functions for viewing and analyzing responses

– Functions tor extracting useful data from the applications

Computer Science and Engineering 45

Page 46: Web Application Hacker’s Toolkit

4. Web Application 4. Web Application Vulnerability ScannersVulnerability Scanners

• Passive scanning: monitoring the requests and responses passing through the local proxy– Detect vulnerabilities: clear text password, incorrect cookie,

etc

– Non-invasive, often used for penetration testing

• Active scanning: sending new requests to the target application – To tests for XSS vulnerability, HTTP header injection, etc.

– Can be potentially dangerous

Computer Science and Engineering 46

Page 47: Web Application Hacker’s Toolkit

5. Manual request 5. Manual request ToolsTools

• Functionality to issue a single request and view its response

• Can be very useful when need slight modification of the request based on the responses

• Can be both standalone tool and web browser-based

• Common features:

– Integration with other suit components

– Keep record on all requests and responses

– Multitabbed interface: handle multiple items

Computer Science and Engineering 47

Page 48: Web Application Hacker’s Toolkit

6. Session Token 6. Session Token AnalyzerAnalyzer

• Randomness of session cookies• Burp Sequencer: standard statistical tests

Computer Science and Engineering 48

Page 49: Web Application Hacker’s Toolkit

Testing WorkflowTesting Workflow

Computer Science and Engineering 49

Browser

Interc. ProxySpider

Content Disc.

Scanner Repeater Fuzzer Token analyzer

P. history Site map

Vulnerabilities

Recon and analysis

Vulnerability detectionand exploitation

activepassivePassive

scanning

Confirm vulnerabilities

Page 50: Web Application Hacker’s Toolkit

Alternatives to Alternatives to Intercepting ProxiesIntercepting Proxies

• Non-traditional applications– Cannot use proxy

• Browser extensions– Extend functionality– Does not interfere with the network-layer

communication between the server and the browser– Allows to submit arbitrary request to the application

Computer Science and Engineering 50

Page 51: Web Application Hacker’s Toolkit

MethodologyMethodology

1. Recon and analysis– Map application content

– Analyze application

2. Analysis– Application logic: test client side controls and for logic flaws

– Access handling: test authentication, session management, access control

– Input handling: fuzz all parameters, test specific functionalities

– Application hosting: test for shared hosting issues, test the web server

– Miscellaneous checks

– Information leakage

Computer Science and Engineering 51

Page 52: Web Application Hacker’s Toolkit

Next ClassNext Class

Buffer overflow and application software insecurity

Computer Science and Engineering 52