SlideShare ist ein Scribd-Unternehmen logo
1 von 72
Simple Web Security
BambooFox & NCTUCSC
$$whoami
> fuyu0425 / a0919610611
> 傅裕夫
> 資工系大三
> NA of CSC
> TA of CSCC
> Full-stack Web Developer
> a0919610611@gmail.com / fuyu0425@cs.nctu.edu.tw
> Github ( https://github.com/a0919610611 )
Outline
● HTTP
● BurpSuite
● OWASP Top 10 Vulnerabilities
● XSS
● CSRF
● SQL Injection
● Google Hacking
● Practice Platform (bWapp and WebGoat)
● Next Step
HTTP
How the web page works ?
HTTP / HTTPS
HTTP - Introduction
HyperText Transfer Protocol
● Request
○ Method Ex: GET/POST/PUT/DELETE
● Response
● Header
● Body
● based on TCP
● stateless (important !!!)
Request
Response
So... How server know who you are?
HTTP - Cookie and Session
● Cookie
○ Stored in browser
○ Browser will auto send cookie to the server .
● Session
○ Stored in server side
○ Stored in database or cache
○ Server use session to identify user.
HTTP - Authentication Flow Chart
1. You type username and password at login page.
2. Server check and create a session stored in database.
3. Server use HTTP header : Set-Cookie to make browser store cookie and
value is the session id .
4. When you view protected page . Browser auto send the cookie .
5. Server check the session is in the database , and know who you are.
6. Check your permission and response right page for you.
Hacker only need you cookie !
Why so complex ?
Because HTTP is stateless !!
How to analyze ?
Burpsuite
a proxy server that can intercept and modify request before sending to server
OWASP Top 10 Vulnerabilities
1. Injection
2. Broken Authentication and Session Management
3. Cross-Site Scripting (XSS)
4. Broken Access Control
5. Security Misconfiguration
6. Sensitive Data Exposure
7. Insufficient Attack Protection
8. Cross-Site Request Forgery (CSRF)
9. Using Components with Known Vulnerabilities
10. Underprotected APIs
XSS
Cross-site Scripting
XSS - Introduction
● Hacker ineject script (javscript) to make browser execute.
● Normal Content
○ <p> Hi~ </p>
● Malicious Content
○ <p> <script> { script content }</script></p>
○ hacker can use javscript to steal you cookie and sensitive information .
XSS - XSS types
● Reflected XSS
○ Not stored in database.
○ Need user to click URL with malicious parameter.
● Stored XSS
○ Stored malicious content in database
○ take message board for example , if hacker leave a message “<script>alert()</script>,
everyone will now be alerted .
● DOM-based XSS
○ with malicious payload to modify the DOM to trigger attack.
XSS - How to defend
replace <script> to $lt;script$gt; ...
Use HTML Entities
XSS - Some useful tips
● <a href=javascript:alert(1)> xss </a>
● <button onclick=”alert(1)”> click me !</button>
● <body onload=”alert(1);”> this is body </body>
● <p onmouseover=”alert(1);”> xss </p>
● <img src=x onerror=”alert(1);” />
XSS - Practice
● XSS Game ( https://xss-game.appspot.com )
● bwapp
● webgoat
XSS - XSS Game Level 1 (Reflected XSS)
XSS - XSS Game Level 2 ( Stored XSS)
XSS - XSS Game Level 3 - Analyze (1)
XSS - XSS Game Level 3 - Analyze (2)
XSS - XSS Game Level 3 - Injection
1. when page load , it will called window.onload
2. window.onload => choosetab (self.location.hash.substr(1))
○ google.com#1234 => self.location.hash = “#1234”
○ “#1234”.substr(1) = “1234”
3. then replace the content with "<img src='/static/level3/cloud" + num + ".jpg' />"
4. the num is what we can control !!
5. let’s injection
6. use img’s onerror hook
XSS - XSS Game Level 3 - Injection
XSS - WebGoat
XSS - WebGoat
Browser will ignore donwside form if we don’t close upside !
Make request using image
CSRF
Cross-site Request Forgery
CSRF - Introduction
1. Recall that , browser will auto send the cookie.
2. if we can inject malicious request to the website , we can fake the real user .
3. XSS can help hacker , but not neccesary.
<img src=”http://tranfer.com/?money=99999&to=hakcer>
<img src=”http://tranfer.com/confirm”>
<iframe src=”http://tranfer.com/?money=99999&to=hakcer>
CSRF - How to defend
● CSRF Token
○ generate special token for every request.
○ if hacker can’t steal token , then can’t fake the request.
● Origin Header
○ check the request is from the same website .
○ take last slide’s request for example , check origin header is “transfer.com”
SQL Injection
SQL Injection - SQL
Structured Query Language
● SQL is used to communicate with a database.
● MySQL / MariaDB / PostgreSQL / MSSQL
● Use table to store data.
● Most used operation
○ SELECT
○ INSERT
○ UPDATE
○ DELETE
○ UNION
SQL
SQL Injection - SQL Example
● SELECT
○ SELECT Store_Name FROM Store_Information;
● INSERT
○ INSERT INTO Store_Information (Store_Name, Sales, Txn_Date)
VALUES ('Los Angeles', 900, 'Jan-10-1999');
● UPDATE
○ UPDATE Store_Information
SET Sales = 500
WHERE Store_Name = 'Los Angeles' AND Txn_Date = 'Jan-08-1999';
● DELETE
○ DELETE FROM Store_Information WHERE Store_Name = 'Los Angeles';
● Union
○ SELECT Txn_Date FROM Store_Information UNION
SELECT Txn_Date FROM Internet_Sales;
What if we can control the SQL statement ?
SQL Injection - Example
If we have a login page can type username and password , what will server do to
check the login is valid ?
if my username = fuyu0425 and password = 11111111 , then type it on login page.
SELECT * FROM users WHERE username = ‘fuyu0425’ and
password = ‘11111111’ ;
then check the result is not empty .
SQL Injection - Example (2)
Now hacker want to login my user without my password , how can he do ?
hacker can type username = fuyu0425 ‘ or 1=1 -- and password = XXXX
Now SQL statement becomes
SELECT * FROM users WHERE username = ‘fuyu0425’ or
1=1 -- ’ and password = ‘11111111’ ;
Now hacker can login without knowing my password
Because -- is used for comment in SQL ;
SQL Injection - Injection types
● Normal injection
○ Use UNION , useful when you know the database schema
● Blind injection
○ Ask True or False questions and determines the answer based on the application response.
● Error-based injection
● Time-based injection
SQL Injection - Normal injection
Use Union to query what you want
SELECT * FROM users
WHERE username = ‘fuyu0425’ or 1=1
UNION SELECT * FROM books
-- ’ and password = ‘11111111’ ;
SQL Injection - Blind injection
Use Boolean to determine it can be injected or not
1. http://newspaper.com/items.php?id=2
SELECT title, description, body FROM items WHERE ID = 2
1. http://newspaper.com/items.php?id=2 and 1=1
SELECT title, description, body FROM items WHERE ID = 2 and 1=1
1. http://newspaper.com/items.php?id=2 and 1=2
SELECT title, description, body FROM items WHERE ID = 2 and 1=2
If 2’s result != 3’s result based on server response , we can suspect that it can be
injected.
SQL Injection - Practice
● AIS3 web 3
● SQL_Demo
● bwapp (http://www.itsecgames.com/)
● webgoat
SQL Injection - WebGoat
SQL Injection - WebGoat
SQL Injection - WebGoat
Google Hacking
Google is your friend (weapon ?)
Google Hacking - Introduction
● Google will index website for search engine.
● Google search bar has some keyword we can use.
● keyword:
○ intile:nctu
○ inurl:google.com
○ site:google.com
○ ext:html
● Operator:
○ | : or
○ + : and
○ - : not
Google Hacking - Search
intitle:index.of /.git
Google Hacking - Search
intitle:"index of" passwd
Practice Platform
bWapp and WebGoat
bwapp
bwapp - Install
● download the bee-box https://sourceforge.net/projects/bwapp/files/bee-box/
● and follow the INSTALL.txt
WebGoat
WebGoat - Install
● install java
○ apt-get install default-jre (kail pre-installed)
● wget or download
https://github.com/WebGoat/WebGoat/releases/download/7.1/webgoat-
container-7.1-exec.jar
● java -jar webgoat-container-7.1-exec.jar
● go to localhost:8080/WebGoat/login.mvc (Case Sensitive !!)
Next Step
Next Step
● CTF
● Penetration Test
● A good web developer with awareness with security
Don’t do bad thing !!!
Reference
● Last years’ slides. https://bamboofox.github.io/tutorial/2016/09/27/106-club-
course.html
● https://dzone.com/articles/jwtjson-web-tokens-are-better-than-session-cookies
● https://www.w3schools.com/html/html_entities.asp
● http://www.lijyyh.com/2013/06/web-application-security-risks-and.html
Thank you for listening !

Weitere ähnliche Inhalte

Was ist angesagt?

[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...
[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...
[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...OWASP Russia
 
XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?Yurii Bilyk
 
PHP Experience 2016 - [Palestra] Json Web Token (JWT)
PHP Experience 2016 - [Palestra] Json Web Token (JWT)PHP Experience 2016 - [Palestra] Json Web Token (JWT)
PHP Experience 2016 - [Palestra] Json Web Token (JWT)iMasters
 
Two scoops of Django - Security Best Practices
Two scoops of Django - Security Best PracticesTwo scoops of Django - Security Best Practices
Two scoops of Django - Security Best PracticesSpin Lai
 
Ignite Talk: I AM a robot, how do I log in?
Ignite Talk: I AM a robot, how do I log in?Ignite Talk: I AM a robot, how do I log in?
Ignite Talk: I AM a robot, how do I log in?VMware Tanzu
 
Not just popups- Jaffna meetup
Not just popups- Jaffna meetupNot just popups- Jaffna meetup
Not just popups- Jaffna meetupSivakumar Prakhash
 
Integrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptIntegrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptFrancois Marier
 
Integrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptIntegrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptFrancois Marier
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)OWASP Khartoum
 
Polyglot payloads in practice by avlidienbrunn at HackPra
Polyglot payloads in practice by avlidienbrunn at HackPraPolyglot payloads in practice by avlidienbrunn at HackPra
Polyglot payloads in practice by avlidienbrunn at HackPraMathias Karlsson
 
JavaScript Security
JavaScript SecurityJavaScript Security
JavaScript SecurityJason Harwig
 
Cross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterCross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterMichael Coates
 
Google analyticspresncsuwebdev
Google analyticspresncsuwebdevGoogle analyticspresncsuwebdev
Google analyticspresncsuwebdevNick Young
 
Ekoparty 2017 - The Bug Hunter's Methodology
Ekoparty 2017 - The Bug Hunter's MethodologyEkoparty 2017 - The Bug Hunter's Methodology
Ekoparty 2017 - The Bug Hunter's Methodologybugcrowd
 
6.2. Hacking most popular websites
6.2. Hacking most popular websites6.2. Hacking most popular websites
6.2. Hacking most popular websitesdefconmoscow
 

Was ist angesagt? (20)

[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...
[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...
[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...
 
Vulpes tribes backend
Vulpes tribes backendVulpes tribes backend
Vulpes tribes backend
 
XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?
 
PHP Experience 2016 - [Palestra] Json Web Token (JWT)
PHP Experience 2016 - [Palestra] Json Web Token (JWT)PHP Experience 2016 - [Palestra] Json Web Token (JWT)
PHP Experience 2016 - [Palestra] Json Web Token (JWT)
 
Two scoops of Django - Security Best Practices
Two scoops of Django - Security Best PracticesTwo scoops of Django - Security Best Practices
Two scoops of Django - Security Best Practices
 
Ignite Talk: I AM a robot, how do I log in?
Ignite Talk: I AM a robot, how do I log in?Ignite Talk: I AM a robot, how do I log in?
Ignite Talk: I AM a robot, how do I log in?
 
Not just popups- Jaffna meetup
Not just popups- Jaffna meetupNot just popups- Jaffna meetup
Not just popups- Jaffna meetup
 
Integrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptIntegrity protection for third-party JavaScript
Integrity protection for third-party JavaScript
 
Demystifying REST
Demystifying RESTDemystifying REST
Demystifying REST
 
Integrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptIntegrity protection for third-party JavaScript
Integrity protection for third-party JavaScript
 
Li How To2 10
Li How To2 10Li How To2 10
Li How To2 10
 
Cross Site Scripting (XSS)
Cross Site Scripting (XSS)Cross Site Scripting (XSS)
Cross Site Scripting (XSS)
 
Polyglot payloads in practice by avlidienbrunn at HackPra
Polyglot payloads in practice by avlidienbrunn at HackPraPolyglot payloads in practice by avlidienbrunn at HackPra
Polyglot payloads in practice by avlidienbrunn at HackPra
 
JavaScript Security
JavaScript SecurityJavaScript Security
JavaScript Security
 
JSON Web Token
JSON Web TokenJSON Web Token
JSON Web Token
 
Cross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning CenterCross Site Scripting - Mozilla Security Learning Center
Cross Site Scripting - Mozilla Security Learning Center
 
Google analyticspresncsuwebdev
Google analyticspresncsuwebdevGoogle analyticspresncsuwebdev
Google analyticspresncsuwebdev
 
Ekoparty 2017 - The Bug Hunter's Methodology
Ekoparty 2017 - The Bug Hunter's MethodologyEkoparty 2017 - The Bug Hunter's Methodology
Ekoparty 2017 - The Bug Hunter's Methodology
 
6.2. Hacking most popular websites
6.2. Hacking most popular websites6.2. Hacking most popular websites
6.2. Hacking most popular websites
 
Xss talk, attack and defense
Xss talk, attack and defenseXss talk, attack and defense
Xss talk, attack and defense
 

Ähnlich wie Simple web security

Security Best Practices for Bot Builders
Security Best Practices for Bot BuildersSecurity Best Practices for Bot Builders
Security Best Practices for Bot BuildersMax Feldman
 
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya MorimotoSQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya MorimotoPichaya Morimoto
 
Neoito — Secure coding practices
Neoito — Secure coding practicesNeoito — Secure coding practices
Neoito — Secure coding practicesNeoito
 
Tuenti: Web Application Security
Tuenti: Web Application SecurityTuenti: Web Application Security
Tuenti: Web Application SecurityTuenti
 
Tuenti: Web Application Security
Tuenti: Web Application SecurityTuenti: Web Application Security
Tuenti: Web Application SecurityGuille -bisho-
 
SQL injection Colombo Cybersecurity Meetup
SQL injection Colombo Cybersecurity MeetupSQL injection Colombo Cybersecurity Meetup
SQL injection Colombo Cybersecurity MeetupJanith Malinga
 
Bsidesvienna sentinel v0.4
Bsidesvienna sentinel v0.4Bsidesvienna sentinel v0.4
Bsidesvienna sentinel v0.4nibod
 
DEFCON 23 - Lance buttars Nemus - sql injection on lamp
DEFCON 23 - Lance buttars Nemus - sql injection on lampDEFCON 23 - Lance buttars Nemus - sql injection on lamp
DEFCON 23 - Lance buttars Nemus - sql injection on lampFelipe Prado
 
Security on Rails
Security on RailsSecurity on Rails
Security on RailsDavid Paluy
 
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009mirahman
 
Don't get stung - an introduction to the OWASP Top 10
Don't get stung - an introduction to the OWASP Top 10Don't get stung - an introduction to the OWASP Top 10
Don't get stung - an introduction to the OWASP Top 10Barry Dorrans
 
Pentesting RESTful webservices
Pentesting RESTful webservicesPentesting RESTful webservices
Pentesting RESTful webservicesMohammed A. Imran
 
Mr. Mohammed Aldoub - A case study of django web applications that are secur...
Mr. Mohammed Aldoub  - A case study of django web applications that are secur...Mr. Mohammed Aldoub  - A case study of django web applications that are secur...
Mr. Mohammed Aldoub - A case study of django web applications that are secur...nooralmousa
 
Dmytro Kochergin - "The OWASP TOP 10 - Typical Attacks on Web Applications an...
Dmytro Kochergin - "The OWASP TOP 10 - Typical Attacks on Web Applications an...Dmytro Kochergin - "The OWASP TOP 10 - Typical Attacks on Web Applications an...
Dmytro Kochergin - "The OWASP TOP 10 - Typical Attacks on Web Applications an...LogeekNightUkraine
 
Case Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultCase Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultMohammed ALDOUB
 

Ähnlich wie Simple web security (20)

Security Best Practices for Bot Builders
Security Best Practices for Bot BuildersSecurity Best Practices for Bot Builders
Security Best Practices for Bot Builders
 
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya MorimotoSQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
 
Owasp top 10 2013
Owasp top 10 2013Owasp top 10 2013
Owasp top 10 2013
 
New web attacks-nethemba
New web attacks-nethembaNew web attacks-nethemba
New web attacks-nethemba
 
Neoito — Secure coding practices
Neoito — Secure coding practicesNeoito — Secure coding practices
Neoito — Secure coding practices
 
Tuenti: Web Application Security
Tuenti: Web Application SecurityTuenti: Web Application Security
Tuenti: Web Application Security
 
Tuenti: Web Application Security
Tuenti: Web Application SecurityTuenti: Web Application Security
Tuenti: Web Application Security
 
How to identify and prevent SQL injection
How to identify and prevent SQL injection  How to identify and prevent SQL injection
How to identify and prevent SQL injection
 
SQL injection Colombo Cybersecurity Meetup
SQL injection Colombo Cybersecurity MeetupSQL injection Colombo Cybersecurity Meetup
SQL injection Colombo Cybersecurity Meetup
 
Bsidesvienna sentinel v0.4
Bsidesvienna sentinel v0.4Bsidesvienna sentinel v0.4
Bsidesvienna sentinel v0.4
 
DEFCON 23 - Lance buttars Nemus - sql injection on lamp
DEFCON 23 - Lance buttars Nemus - sql injection on lampDEFCON 23 - Lance buttars Nemus - sql injection on lamp
DEFCON 23 - Lance buttars Nemus - sql injection on lamp
 
Security on Rails
Security on RailsSecurity on Rails
Security on Rails
 
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009
 
Don't get stung - an introduction to the OWASP Top 10
Don't get stung - an introduction to the OWASP Top 10Don't get stung - an introduction to the OWASP Top 10
Don't get stung - an introduction to the OWASP Top 10
 
Web Security
Web SecurityWeb Security
Web Security
 
Pentesting RESTful webservices
Pentesting RESTful webservicesPentesting RESTful webservices
Pentesting RESTful webservices
 
Mr. Mohammed Aldoub - A case study of django web applications that are secur...
Mr. Mohammed Aldoub  - A case study of django web applications that are secur...Mr. Mohammed Aldoub  - A case study of django web applications that are secur...
Mr. Mohammed Aldoub - A case study of django web applications that are secur...
 
Dmytro Kochergin - "The OWASP TOP 10 - Typical Attacks on Web Applications an...
Dmytro Kochergin - "The OWASP TOP 10 - Typical Attacks on Web Applications an...Dmytro Kochergin - "The OWASP TOP 10 - Typical Attacks on Web Applications an...
Dmytro Kochergin - "The OWASP TOP 10 - Typical Attacks on Web Applications an...
 
Case Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by DefaultCase Study of Django: Web Frameworks that are Secure by Default
Case Study of Django: Web Frameworks that are Secure by Default
 
PHP Secure Programming
PHP Secure ProgrammingPHP Secure Programming
PHP Secure Programming
 

Kürzlich hochgeladen

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456KiaraTiradoMicha
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyAnusha Are
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 

Kürzlich hochgeladen (20)

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

Simple web security

  • 2. $$whoami > fuyu0425 / a0919610611 > 傅裕夫 > 資工系大三 > NA of CSC > TA of CSCC > Full-stack Web Developer > a0919610611@gmail.com / fuyu0425@cs.nctu.edu.tw > Github ( https://github.com/a0919610611 )
  • 3. Outline ● HTTP ● BurpSuite ● OWASP Top 10 Vulnerabilities ● XSS ● CSRF ● SQL Injection ● Google Hacking ● Practice Platform (bWapp and WebGoat) ● Next Step
  • 5. How the web page works ?
  • 6.
  • 8. HTTP - Introduction HyperText Transfer Protocol ● Request ○ Method Ex: GET/POST/PUT/DELETE ● Response ● Header ● Body ● based on TCP ● stateless (important !!!)
  • 11.
  • 12. So... How server know who you are?
  • 13. HTTP - Cookie and Session ● Cookie ○ Stored in browser ○ Browser will auto send cookie to the server . ● Session ○ Stored in server side ○ Stored in database or cache ○ Server use session to identify user.
  • 14. HTTP - Authentication Flow Chart 1. You type username and password at login page. 2. Server check and create a session stored in database. 3. Server use HTTP header : Set-Cookie to make browser store cookie and value is the session id . 4. When you view protected page . Browser auto send the cookie . 5. Server check the session is in the database , and know who you are. 6. Check your permission and response right page for you.
  • 15.
  • 16. Hacker only need you cookie !
  • 18. Because HTTP is stateless !!
  • 20. Burpsuite a proxy server that can intercept and modify request before sending to server
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26. OWASP Top 10 Vulnerabilities
  • 27. 1. Injection 2. Broken Authentication and Session Management 3. Cross-Site Scripting (XSS) 4. Broken Access Control 5. Security Misconfiguration 6. Sensitive Data Exposure 7. Insufficient Attack Protection 8. Cross-Site Request Forgery (CSRF) 9. Using Components with Known Vulnerabilities 10. Underprotected APIs
  • 29. XSS - Introduction ● Hacker ineject script (javscript) to make browser execute. ● Normal Content ○ <p> Hi~ </p> ● Malicious Content ○ <p> <script> { script content }</script></p> ○ hacker can use javscript to steal you cookie and sensitive information .
  • 30. XSS - XSS types ● Reflected XSS ○ Not stored in database. ○ Need user to click URL with malicious parameter. ● Stored XSS ○ Stored malicious content in database ○ take message board for example , if hacker leave a message “<script>alert()</script>, everyone will now be alerted . ● DOM-based XSS ○ with malicious payload to modify the DOM to trigger attack.
  • 31. XSS - How to defend replace <script> to $lt;script$gt; ... Use HTML Entities
  • 32. XSS - Some useful tips ● <a href=javascript:alert(1)> xss </a> ● <button onclick=”alert(1)”> click me !</button> ● <body onload=”alert(1);”> this is body </body> ● <p onmouseover=”alert(1);”> xss </p> ● <img src=x onerror=”alert(1);” />
  • 33. XSS - Practice ● XSS Game ( https://xss-game.appspot.com ) ● bwapp ● webgoat
  • 34. XSS - XSS Game Level 1 (Reflected XSS)
  • 35. XSS - XSS Game Level 2 ( Stored XSS)
  • 36. XSS - XSS Game Level 3 - Analyze (1)
  • 37. XSS - XSS Game Level 3 - Analyze (2)
  • 38. XSS - XSS Game Level 3 - Injection 1. when page load , it will called window.onload 2. window.onload => choosetab (self.location.hash.substr(1)) ○ google.com#1234 => self.location.hash = “#1234” ○ “#1234”.substr(1) = “1234” 3. then replace the content with "<img src='/static/level3/cloud" + num + ".jpg' />" 4. the num is what we can control !! 5. let’s injection 6. use img’s onerror hook
  • 39. XSS - XSS Game Level 3 - Injection
  • 41. XSS - WebGoat Browser will ignore donwside form if we don’t close upside ! Make request using image
  • 43. CSRF - Introduction 1. Recall that , browser will auto send the cookie. 2. if we can inject malicious request to the website , we can fake the real user . 3. XSS can help hacker , but not neccesary. <img src=”http://tranfer.com/?money=99999&to=hakcer> <img src=”http://tranfer.com/confirm”> <iframe src=”http://tranfer.com/?money=99999&to=hakcer>
  • 44. CSRF - How to defend ● CSRF Token ○ generate special token for every request. ○ if hacker can’t steal token , then can’t fake the request. ● Origin Header ○ check the request is from the same website . ○ take last slide’s request for example , check origin header is “transfer.com”
  • 46. SQL Injection - SQL Structured Query Language ● SQL is used to communicate with a database. ● MySQL / MariaDB / PostgreSQL / MSSQL ● Use table to store data. ● Most used operation ○ SELECT ○ INSERT ○ UPDATE ○ DELETE ○ UNION
  • 47. SQL
  • 48. SQL Injection - SQL Example ● SELECT ○ SELECT Store_Name FROM Store_Information; ● INSERT ○ INSERT INTO Store_Information (Store_Name, Sales, Txn_Date) VALUES ('Los Angeles', 900, 'Jan-10-1999'); ● UPDATE ○ UPDATE Store_Information SET Sales = 500 WHERE Store_Name = 'Los Angeles' AND Txn_Date = 'Jan-08-1999'; ● DELETE ○ DELETE FROM Store_Information WHERE Store_Name = 'Los Angeles'; ● Union ○ SELECT Txn_Date FROM Store_Information UNION SELECT Txn_Date FROM Internet_Sales;
  • 49. What if we can control the SQL statement ?
  • 50. SQL Injection - Example If we have a login page can type username and password , what will server do to check the login is valid ? if my username = fuyu0425 and password = 11111111 , then type it on login page. SELECT * FROM users WHERE username = ‘fuyu0425’ and password = ‘11111111’ ; then check the result is not empty .
  • 51. SQL Injection - Example (2) Now hacker want to login my user without my password , how can he do ? hacker can type username = fuyu0425 ‘ or 1=1 -- and password = XXXX Now SQL statement becomes SELECT * FROM users WHERE username = ‘fuyu0425’ or 1=1 -- ’ and password = ‘11111111’ ; Now hacker can login without knowing my password Because -- is used for comment in SQL ;
  • 52. SQL Injection - Injection types ● Normal injection ○ Use UNION , useful when you know the database schema ● Blind injection ○ Ask True or False questions and determines the answer based on the application response. ● Error-based injection ● Time-based injection
  • 53. SQL Injection - Normal injection Use Union to query what you want SELECT * FROM users WHERE username = ‘fuyu0425’ or 1=1 UNION SELECT * FROM books -- ’ and password = ‘11111111’ ;
  • 54. SQL Injection - Blind injection Use Boolean to determine it can be injected or not 1. http://newspaper.com/items.php?id=2 SELECT title, description, body FROM items WHERE ID = 2 1. http://newspaper.com/items.php?id=2 and 1=1 SELECT title, description, body FROM items WHERE ID = 2 and 1=1 1. http://newspaper.com/items.php?id=2 and 1=2 SELECT title, description, body FROM items WHERE ID = 2 and 1=2 If 2’s result != 3’s result based on server response , we can suspect that it can be injected.
  • 55. SQL Injection - Practice ● AIS3 web 3 ● SQL_Demo ● bwapp (http://www.itsecgames.com/) ● webgoat
  • 56. SQL Injection - WebGoat
  • 57. SQL Injection - WebGoat
  • 58. SQL Injection - WebGoat
  • 59. Google Hacking Google is your friend (weapon ?)
  • 60. Google Hacking - Introduction ● Google will index website for search engine. ● Google search bar has some keyword we can use. ● keyword: ○ intile:nctu ○ inurl:google.com ○ site:google.com ○ ext:html ● Operator: ○ | : or ○ + : and ○ - : not
  • 61. Google Hacking - Search intitle:index.of /.git
  • 62. Google Hacking - Search intitle:"index of" passwd
  • 64. bwapp
  • 65. bwapp - Install ● download the bee-box https://sourceforge.net/projects/bwapp/files/bee-box/ ● and follow the INSTALL.txt
  • 67. WebGoat - Install ● install java ○ apt-get install default-jre (kail pre-installed) ● wget or download https://github.com/WebGoat/WebGoat/releases/download/7.1/webgoat- container-7.1-exec.jar ● java -jar webgoat-container-7.1-exec.jar ● go to localhost:8080/WebGoat/login.mvc (Case Sensitive !!)
  • 69. Next Step ● CTF ● Penetration Test ● A good web developer with awareness with security
  • 70. Don’t do bad thing !!!
  • 71. Reference ● Last years’ slides. https://bamboofox.github.io/tutorial/2016/09/27/106-club- course.html ● https://dzone.com/articles/jwtjson-web-tokens-are-better-than-session-cookies ● https://www.w3schools.com/html/html_entities.asp ● http://www.lijyyh.com/2013/06/web-application-security-risks-and.html
  • 72. Thank you for listening !