Lesson 16_Hacking Web Application
Lesson 16_Hacking Web Application
A web application is a computer-based program that uses web browsers to carry out
specified functions online. It is popularly known as a web app.
Clien Serve
t r
Popular Web Applications
Amazon, Netflix, and WhatsApp are some popular web applications used daily.
In addition, web applications are furnished on the World Wide Web.
Amazo WhatsApp
n
Netfli
x
Web Application Architecture
Administration Tool
Administration Layer
API
Managemen Administration
Documentation
t
Third-Party
Metadata
Components of a Web Application Architecture
Clien Layer 1
t
Client
Client platform that hosts a web
browser
Serve
r Web/App Services
Server Layer 2
A well-known software application design that divides applications into three logical
and physical computer tiers is three-tier architecture.
Client
Firewall
Proxy
Data Layer
DBMS
Three-Tier Web Application Architecture: Layers
Layer 3
Presentation layer: It provides information
through a graphical user interface about services
frequently available through a web browser or web-
based application (GUI).
Layer 2
Application layer: It is derived from the
presentation tier, known as the logic tier, business
logic tier, or logic tier.
Layer 1
Data layer: Database servers are stored and
retrieved in this location.
N-Tier Web Application Architecture
N-tier web application architecture, as the name suggests, requires multiple layers,
primarily more than three layers.
Application
Server 1 N-tier architecture is also called
Client Data multi-layered architecture.
Server 1
It is an expansion of the three-layer
architecture by replicating the
Client Application
Server 2 application, data servers, or
specializing servers.
Data
Client Server 2
Application
Server 3
Web App Threats
What Is OWASP?
OWASP is a global non-profit organization based in Maryland, United States, dedicated to web
application security.
It is an online community that provides freely available articles, documentation, tools, etc.
OWASP Top 10
These ten are considered the most critical security risks to web applications:
1 2
Broken Access Cryptographic
Control Failure
3 4
Injectio Insecure
n Design
5 6
Security Vulnerable and
Misconfiguration Outdated
Components
7 8
Identification and Software and
Authentication Data
Failure Integrity Failure
9 1
Security Logging 0 Server Side
and Request Forgery
Monitoring Failure (SSRF)
Broken Access Control
https://www.pullrequest.com/blog/what-are-cryptographic-failures-and-how-to-prevent-giant-leaks/
Injection
A web application becomes vulnerable when an attacker sends incorrect data into
it. This process is known as code injection.
https://www.kiuwan.com/code-injection-vulnerabilities/
Insecure Design
Insecure design vulnerability occurs when the designs contain some flaws. It
represents the weakness in the current designs.
Example
Automated system
Website with no failed
login limits set
https://cheapsslsecurity.com/blog/what-are-the-owasp-top-10-vulnerabilities-and-how-to-mitigate-them/
Security Misconfiguration
Accounts
Finance
Administration
Transactions
Communication
Knowledge Mgmt
E-Commerce
Bus functions Database
Custom code
App configuration
Framework Development
This generally happens when the developer does not know what version of
the software is currently being used.
https://cheapsslsecurity.com/blog/what-are-the-owasp-top-10-vulnerabilities-and-how-to-mitigate-them/
Identification and Authentication Failure
https://support.f5.com/csp/article/K14998322
Software and Data Integrity Failures
https://www.wallarm.com/what/a04-2021-owasp-software-and-data-integrity-failures
Security Logging and Monitoring Failures
https://cheapsslsecurity.com/blog/what-are-the-owasp-top-10-vulnerabilities-and-how-to-mitigate-them/
Server-Side Request Forgery (SSRF)
An attacker could gain access and even modify the internal resources.
https://www.invicti.com/blog/web-security/server-side-request-forgery-vulnerability-ssrf/
Other Web App Threats
Cross- Remote
Director LDAP
site code
y injection
scripting executio
traversa
(XSS) n
l
When an
When an
attacker sends When the When malicious
attacker reads
malicious codes validation is malware is
files on the
to a web weak downloaded
server outside
application
of the directory
Hacking Methodology
Web App Hacking Methodology
6. Maintain
1. Set target
access
3. Vulnerability
4. Exploitation
scanning
https://static.packt-cdn.com/products/9781801819770/graphics/Images/B17765_07_01.p
Attacks Against Web Application
In hacking methodology, there are many vulnerabilities in the web application during the attack or
exploitation.
Some of the attacks against web applications are as follows:
7 40
% %
2
%
4
% SQL
16 Injection
% Path
Traversal
Local File
inclusion
Cross Site
scripting
OS
Commanding
Other
31 https://www.ptsecurity.com/upload/corporate/ww-en/images/analytics/article_300527/300527_3.jp
%
Countermeasures Against Web Application Attacks
https://img.freepik.com/premium-vector/hacker-is-trying-break-cyber-security_498048-118.j
Footprinting Infrastructure
Phone Domain
number name
Footprinting a web application
captures information about the target
Legal
IP address web application and its tracks.
documents
It can be considered as follows:
• Knowing about the website’s DNS
Email
Policies information
address
• Grabbing its network map
Footprinting
https://miro.medium.com/max/1400/1*PJdKWdEm9hnbZTDtzoJDvw.png
Tools Used in Footprinting
Footprinting is often done using hacking tools, either applications or websites, which allow the
hacker to locate information passively. Some tools used in footprinting of any web application
are listed below:
Tools are used to gather and track information. However, there is a need to reduce
infrastructure footprints. Some of the points that can be implemented are:
https://excellence-it.co.uk/wp-content/uploads/2019/06/
footprint1.png
Attacking Web Server
After footprinting, the hacker's main task is to attack the web app server.
https://devqa.io/assets/images/hacking-web-
servers.png
Attacks on Web Servers
An attacker attempts to take the web server down or make it unavailable to legitimate users. Some
attacks which are done on web servers are as follows:
File
uploa
d
CSR SQL
F I
User Hacker
Note: These attacks are also made directly on the website too, so don’t get confused
about web server and web application attacks.
http://www.valencynetworks.com/blogs/wp-content/uploads/2020/01/web-exploitation.jpg
Countermeasure Against Web Server Attacks
https://play-lh.googleusercontent.com/uXf-4EYiL-43zjGzmwQ93NcWhOduuAW_EX-
qs2Yzpi8O5efKokC08A4T4f7cjLqQDtJp=w600-h300-pc0xffffff-pd
Analyzing Web Application
https://ds6br8f5qp1u2.cloudfront.net/blog/wp-content/uploads/2017/05/web-application-testing.png?x825
Software and Tools Used in Web App Analysis
• Web proxies
• Web scanners
• Brute-forcers
• Fuzzers
• Web app testing frameworks
https://www.brainpulse.com/wp-content/uploads/2020/05/web-analysis-tool-1280x720.jp
Importance of Web Application Analysis
Businesses these days are directly dependent on web applications. This is why the
analysis is crucial.
https://www.rouge-media.com/wp-content/uploads/2019/05/web-app-illustration-1.pn
Client-Side Controls
https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ48u4Q1BK37S02-o-
0cjAGu75B_TveIB3F7g&usqp=CAU
Bypassing Client-Side Controls
https://blog.knowbe4.com/hubfs/iStock-1221578901.jpg
Preventing Client-Side Controls
To prevent bypassing client-side controls, restrictions are required on some fields which are
validated on the client side.
https://img.freepik.com/premium-photo/cybersecurity-protection-concept-technology-background_371307-31.jpg?w=
Bypass Client-Side Control
Duration: 15 mins
Problem Statement:
Steps to follow:
1. Setup proxy for Burp Suite
2. Setup Burp Suite
3. Enter commands to host DVWA
4. Go to File Upload in DVWA
5. Now, as desired by the control, change malware.py to jpeg
6. Use Burp Suite to bypass control on submission
SQL Injection Attack
After bypassing client-side controls, the SQLi attack is the most used attack over the
databases.
1. Hacker identifies
2. Malicious SQL
vulnerable, SQL-driven
query is validated,
website and injects
and command is
malicious SQL query via
executed by
• This attack is made by injecting SQL
input data 2 database commands in the input field on the
1 Website input fields client-side
3. Hacker is granted • This may lead to illegal database
access to view and
access and database manipulation
alter records or
potentially act as
database administrator
3
Hacker Database
https://miro.medium.com/max/600/0*cJMKpHYBNIOaXVPV.png
Input Validation Attack
Like SQLi attacks the user input fields. Input Validation attacks when the client
is not validated on the server side, or the user input is not sanitized.
http://1.bp.blogspot.com/-D2qsrpbiJA8/T5wEVFXcHVI/AAAAAAAAAHI/CD81zqztom4/s1600/7-Schema-Based-Input-
Validation.png
Countermeasures Against SQLi and Input Validation Attack
https://academy.avast.com/hs-fs/hubfs/New_Avast_Academy/SQL%20injection/What%20is%20a%20SQL%20injection.png?width=660&name=What%20is%20a%20SQL%20injection.png
SQL Injection Attack
Duration: 15 minutes
Problem Statement:
You are given a task to perform SQLi and Input Validation attacks.
Assisted Practice Guidelines
Steps to perform:
1. Enter commands to host DVWA
2. Go to the Login page of DVWA
3. Perform SQL injection attack
4. Attack successful
Broken Authentication
(1)
Connection established
Client Server
(2)
Packet sniffing
and find sequence
(3) number (3)
Established connection Established connection
Hacker PC
(4)
Sniffed packet
https://i0.wp.com/gbhackers.com/wp-content/uploads/2016/10/session.png?resize=567%2C238&ssl
Common Reasons for Broken Authentication
https://www.prplbx.com/static/665c5a21eb22a5aa5ae2e8106f9df486/4e258/card-image.p
Broken Authentication Attack Scenario
Authentication is broken when attackers can compromise passwords, user account information,
and other details to assume user identities.
The attack scenario is illustrated in the image:
Forgot your
password?
Enter your email
address to reset your POST/ password/reset HTTP
password. 1.1
carlos@normal- Host: evil-user.net
user.com
Reset your
password
Vulnerable
website
Hello carlos,
To reset your
password,click the
following link: </
Token= http://evil-user.net/ >
a0bs0hjdserfsnccbhc Password reset?
bejrfbcsdsbcjhefbes token=
https://www.prplbx.com/static/ee2ab4e8a5966dc80ce6994e15460bb9/b1945/figure5-password-reset-
poisoning.png
Countermeasures for Broken Authentication
Log
management
Search
• Use of secure authentication and
authorization protocols
Index
• Proper session management
Pinpoint
issues
https://www.prplbx.com/static/f054e423c8735f627bcd61a4f5b23c52/4b190/figure14.jp
Broken Authentication Vulnerability
Duration: 10 mins
Problem Statement:
You are given a task to check for broken authentication vulnerabilities in DVWA as
Weak Session ID
Assisted Practice Guidelines
Steps to follow:
1. Enter commands to host DVWA
2. Go to the Login page of DVWA
3. Now, perform an authentication check on Weak Session IDs
4. Now, verify this by inspecting the element
5. Verification of the vulnerability
Sensitive Data Exposure Vulnerability
Spear
Email filtering Compromised
phishing
(anti virus/spam) user
email
https://miro.medium.com/max/978/1*74LLez2daWXSvhSR0encrQ.jpeg
Sensitive Data Exposure Attack
Sensitive data exposures can result from weak encryption, software flaws, or human
error.
This given image illustrates the attack procedure:
2
The victim clicks the link
containing an unvalidated
3
Application redirects victim
parameter to attacker’s site
https://www.indusface.com/wp-content/uploads/2019/08/Sensitive_Data_Exposure_blog.jp
Countermeasures for Sensitive Data Exposure
https://cdn.acunetix.com/wp_content/uploads/2021/05/ACX-Vulnerabilities-Attacks-Technical-SEO-Posts-1000X525.
Sensitive Data Exposure
Duration: 10 mins
Problem Statement:
You are given a task to find out sensitive data exposure vulnerability.
Assisted Practice Guidelines
Steps to be followed:
1. Enter commands to host DVWA
2. Go to the Login page of DVWA
3. Go to XSS (Reflected)
4. Perform an attack to expose sensitive data
Attack Scenario of XEE
This attack occurs when a weakly configured XML parser processes XML input containing a
reference to an external entity. The following steps describe the attack scenario:
5
1
1.Hacker identifies a web application
with a weakly configured XML parser
Hacker and sends an XML request Web application
2
2
3
https://spanning.com/wp-content/uploads/2019/09/XML-external-entity-attack-example.pn
Countermeasure for XEE attack
https://www.indusface.com/wp-content/uploads/2020/07/how-to-prevent-xml-external-entities.pn
Remote File Inclusion
Remote File Inclusion is a vulnerability where the reference function is exploited by the
hacker.
Site is compromised.
Malware is installed. Server is hijacked Data is compromised
pages are defaced or Server is used as a Passwords and
deleted. DDoS bot. information are stolen
https://www.imperva.com/learn/wp-content/uploads/sites/13/2019/01/what-is-rfi-attack.png
Local File Inclusion
Local File Inclusion is when attackers trick a web application into running or exposing
files on a web server.
https://spanning.com/wp-content/uploads/2021/05/local-file-inclusion.png
Countermeasures for RFI and LFI
https://brightsec.com/wp-content/uploads/2021/12/Local-File-Inclusion-LFI.png
RFI or LFI Attack
Duration: 10 mins
Problem Statement:
Steps to be followed:
1. Enter commands to host DVWA
2. Go to the Login page of DVWA
3. Go to File Inclusion
XML External Entity Injection
This is an injection attack that allows the hackers to access the XML data, which the
application itself can access.
https://miro.medium.com/max/1400/0*prf8NM_OPXKLd13P
Directory Traversal
It is an attack where the hacker traverses the web server's directory for unauthorized
access.
passw
d
“/
etc”
https://cdn.invicti.com/app/uploads/2022/06/28120725/directory-path-traversal-attack.pn
Directory Traversal Attack Scenario
A Directory Traversal vulnerability results from insufficient filtering or validation of user browser
input. The steps in the attack scenario are:
https://example.com/?file=../../../../etc/passwd
https://spanning.com/wp-content/uploads/2020/10/directory-traversal-example.png
Countermeasures for Directory Traversal Attack
https://www.internetsecurity.tips/wp-content/uploads/2020/09/What-is-path-traversal-and-how-to-prevent-it-
1280x720.png
Directory Traversal Attack
Duration: 12 mins
Problem Statement:
You are given a task to test for the Directory Traversal vulnerability.
Assisted Practice Guidelines
Steps to perform:
1. Launch DVWA in Kali Linux
2. Find the URL where the user can try a directory or path traversal attack
3. Try manipulating the URL
XSS (Cross-Site Scripting)
Cross-Site Scripting is an attack where a hacker tries to insert a malicious script in the input
fields or parameters, which gets stored in the database or gets reflected.
What is XSS?
[Cross-Site Scripting]
This way, the hacker can steal
XSS sensitive data and hack
websites or user accounts.
https://dltlabsweb-media.s3.amazonaws.com/images/Cross%20Site%20Scripting%20Latest%20%20by%20Shobhit%20Singhal-9ae66bd7-9836-4bd9-8161-
d637507d0989.png
Types of XSS Attacks
https://slideplayer.com/slide/697516/2/images/7/Types+of+XSS+vulnerabilities.jp
XSS Attack Scenario
1 Trusted website 2
3. Victim’s browser
executes the malicious
script and unknowing
forwards desired
information (session
token, cookie, etc.) to the
hacker
Hacker 3 Victim
https://spanning.com/wp-content/uploads/2019/05/cross-site-scripting-example.png
Countermeasures for the XSS Attacks
https://academy.hackthebox.com/storage/modules/103/logo.png
XSS Reflected Attack
Duration: 10 mins
Problem Statement:
Steps to follow:
1. Setup Proxy for Burp-Suite
2. Setup Burp Suite
3. Enter commands to host DVWA
4. Go to XSS (Reflected)
5. Perform an attack
LDAP Injection
LDAP (Lightweight Directory Access Protocol) is used mainly on the intranet to find other
users, files, and devices.
Normal
operation (Normal query)
https://miro.medium.com/max/1400/0*F7z_Bkq8UZjRDMdW
SOAP Injection
SOAP
• It uses XML to represent data.
SIMPLE
• When the user inputs data and changes the
OBJECT
request code, the vulnerability exists.
ACCESS
• If a hacker can embed <> or the request,
PROTOCOL the vulnerability exists.
https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSbfWOMv3-fS5X0WrqYGC6JE1g9oh-
WOyLEGg&usqp=CAU
HTML Injection
This is very similar to the XSS attacks. Like XSS uses JavaScript code to perform an attack,
HTML injection uses HTML tags to change the code and its response.
a
<extare
• HTML Injection is an attack similar
f
hre
<f
<a
<b
e as <i
m
g • In the XSS vulnerability, the
attacker can inject and execute
Javascript code.
https://cdn.acunetix.com/wp-content/uploads/2020/01/11111324/html-injection-featured.pn
IDOR Attack
Insecure Direct Object Reference is a vulnerability used by a hacker to gain privileged access or
another user’s account.
https://spanning.com/wp-content/uploads/2020/02/insecure-direct-object-reference-example.png
Hacking Tools
Web Application Hacking Tools Requirement
Hacking tools are necessary to automate an attack on the target website. Tools make
hacking targets easier and faster.
https://hakin9.org/wp-content/uploads/2020/07/A00-2.png
Tools Used in Web Application Hacking
Hacking tools generally crack or break computer and network security measures. Additionally,
hacking tools have multiple capabilities depending on the systems they have been designed to
penetrate. Some of the most used tools in web app hacking are as below:
https://play-lh.googleusercontent.com/xfEwmzQADrjODuFw94jDJpcUM2f15a9wKvzOExZ8hH7zvYaNpXUzH-
fcbAp3RTrPs18
Common Hacking Countermeasures
Some of the effective preventions and countermeasures which organizations take to defend
themselves from an attack are:
Use WAF
High-standard
user
encryption and
encoding
Sanitize user
input
Train employees
against social
engineering
Create DMZ
Patch
vulnerabilities
regularly
Countermeasures
OWASP Top 10 Vulnerabilities
OWASP is an organization that releases its top 10 vulnerabilities of websites in recent years.
Here is a comparative description for 2017 and 2021:
http://www.pentasecurity.com/wp-content/uploads/2021/09/All-You-Need-to-Know-About-the-OWASP-Top-10-Update-
Diagram.png
WAF (Web Application Firewall)
A web application firewall (WAF) protects web applications from various application layer attacks
such as cross-site scripting (XSS), SQL injection, and cookie poisoning.
https://www.cloudflare.com/img/learning/ddos/glossary/waf/waf.png
Periodic VA (Vulnerability Assessment)
Periodic VA (Vulnerability Assessment) is a security practice carried out by the security team to
find vulnerabilities in any website application.
https://lirp.cdn-website.com/64ff99e4/dms3rep/multi/opt/cloud+protect-640w.png
Knowledge Check
Knowledg
e Check
______________request web pages from the server.
1
Host
A.
Server
B.
Client
C.
Router
D.
Knowledg
e Check
______________request web pages from the server.
1
Host
A.
Server
B.
Client
C.
Router
D.
Firewall
A.
Proxy
B.
Web Server
C.
Antivirus
D.
Knowledg
e Check
Which of the following is not a component of web application architecture?
2
Firewall
A.
Proxy
B.
Web Server
C.
Antivirus
D.
WAF
A.
WAF
A.
Application
A.
Data
B.
Physical
C.
Presentation
D.
Knowledg
e Check
What is the second layer in the three-tier architecture model?
4
Application
A.
Data
B.
Physical
C.
Presentation
D.
LDAP
A.
SSH
B.
SOAP
C.
SQL
D.
Knowledg
e Check
Which of the following protocol is used to transmit the messages?
5
LDAP
A.
SSH
B.
SOAP
C.
SQL
D.
LDAP Injection
A.
SQL Injection
B.
IDOR
C.
XEE
D.
Knowledg
e Check
Which vulnerability can lead to database exploitation?
6
LDAP Injection
A.
SQL Injection
B.
IDOR
C.
XEE
D.
A. PHP Script
JavaScript
B.
Bash Script
C.
Shell Script
D.
Knowledg
e Check
XSS vulnerability mainly embed which of the following language script?
7
PHP Script
A.
JavaScript
B.
Bash Script
C.
Shell Script
D.
Problem statement:
Steps to follow:
1. Open the Kali Linux Machine in the Lab
2. Start the DVWA Lab
3. Login and Open File Inclusion tab
4. Try a web attack known as Directory Traversal to expose sensitive data