Automating Security Tests With Selenium: by Brady Vitrano & Charles Neill Presented To OWASP San Antonio March 20th, 2015
Automating Security Tests With Selenium: by Brady Vitrano & Charles Neill Presented To OWASP San Antonio March 20th, 2015
Automating Security Tests With Selenium: by Brady Vitrano & Charles Neill Presented To OWASP San Antonio March 20th, 2015
2
Agenda
• The goals
• Selenium/Tools/Language Introduction
• Security Engineering Introduction
• Create and run security tests
• Scalable Testing with the Grid
• Takeaways
• Q&A
• Git Repo -
https://github.com/cneill/selenium-security-stuff
The Goals
• What is Selenium?
– Earth Metal
– Atomic Number: 34
– Atomic Weight: 78.96
– Tool to control web browsers and
devices
• Selenium Modes
– WebDriver API
• Support Remote Browsers
– Selenium IDE Recorder
• Runs locally
Browser Automation with Selenium
• Selenium Webdriver
– REST API based works with various browsers and devices
– JSON Wire Protocol
• https://code.google.com/p/selenium/wiki/JsonWireProtocol
– W3 WebDriver (Draft 11 Feb 2015)
• https://w3c.github.io/webdriver/webdriver-spec.html
• Programming Languages
– Python – (Covered Today)
– Ruby (Merlot – Rackspace Gem)
– Javascript (Protractor)
– Java (???)
Using Selenium / Examples
Very basics of a webpage functionality test include:
Explanation:
www.rackspace.com 8
Selenium / Examples
Example 1:
• open a new Firefox browser
• load the Yahoo homepage
• search for “seleniumhq”
• close the browser
www.rackspace.com 9
Selenium / Examples - Page Elements
www.rackspace.com 10
Selenium / Examples – Inspecting Elements
www.rackspace.com 11
Selenium / Examples – How to access page elements
• There are several different ways the webdriver can find HTML elements:
IPython is a helpful way to explore the Selenium API. Tab completion will help you find interesting methods
www.rackspace.com 12
Security Engineering Introduction
www.rackspace.com 17
Why Scripted Tests?
• Don't we want to just throw some fuzz strings at the app and hope it
returns a 500 error?
– We want to eliminate false positives, because we might not be around to
watch the test execution and dig through it manually (e.g. if this is being
run in a Jenkins gating job)
• Writing test cases is harder than just loading a wordlist into BURP
– Sure, the first time! But once you write some code, you can re-use it over
and over again, and you can define success/failure in a more detailed way
for each test
www.rackspace.com 18
Why Selenium?
• Run tests with real-world browsers, and inspect tests in the browser
if you want
• Flexible test running – you can run tests locally, or spin up a whole
cluster of headless nodes to test in parallel
www.rackspace.com 20
Why NOT Selenium?
• If you're just doing HTTP requests and searching for regexes in the
page source code, this can be done much faster by other means
– For this reason, Selenium isn't particularly well-suited to API testing
www.rackspace.com 21
Security Automation Demo!
www.rackspace.com 22
Selenium Grid
• Preinstalled on Vagrant
• SSH into Vagrant Box
– vagrant ssh
• Start Grid
– sudo dsgrid start
• Add Multiple Firefox Nodes
– sudo dsgrid nodes add firefox
– sudo dsgrid nodes add firefox
• Verify Selenium Hub is Running
– http://localhost:49044/grid/console
Run Automation Against the Grid
Instead of this:
Use this:
Reference
• https://w3c.github.io/webdriver/webdriver-spec.html
• http://www.seleniumhq.org/
• https://github.com/cneill/selenium-security-stuff
• OWASP Top Ten Project:
https://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project
• SQL injection: https://www.owasp.org/index.php/SQL_Injection
• Cross Site Scripting (XSS):
https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29
Questions?
brady.vitrano@RACKSPACE.COM
charles.neill@RACKSPACE.COM
THANK YOU
© RACKSPACE LTD. | RACKSPACE® AND FANATICAL SUPPORT® ARE SERVICE MARKS OF RACKSPACE US, INC. REGISTERED IN THE UNITED STATES AND OTHER COUNTRIES. | WWW.RACKSPACE.COM