CEH v12 Lesson 7 _ Web Application Exploitatio (1)
CEH v12 Lesson 7 _ Web Application Exploitatio (1)
Exploitation Attacks
Part 1
Learning Outcomes
In this module, you will complete the following exercises:
Lab Duration
It will take approximately 1 hour to complete this lab.
Predictable usernames
Cookie poisoning
Cookie sniffing
Password guessing
Brute-force attack
Dictionary attack
Session poisoning
An attacker needs to find just one of these design flaws and exploit them.
Learning Outcomes
After completing this exercise, you will be able to:
An attacker can use various methods to conduct an authorization attack, including the
following methods:
Parameter Tampering
In this exercise, you will learn about the authorization attack through URI usage.
Learning Outcomes
After completing this exercise, you will be able to:
PLABDC01Domain Controller192.168.0.1/24PLABWIN10Domain
MemberWorkstation192.168.0.3/24PLABKALI01Domain
MemberWorkstation192.168.0.5/24
PLABDC01
PLABWIN10
Windows 10 — Workstation192.168.0.3/24
PLABKALI01
In this task, you will learn to perform an authorization attack using URI.
Step 1
Connect to PLABWIN10. Click the Microsoft Edge icon in the taskbar.
Step 2
To access the bWAPP application in the Microsoft Edge window, type the following
URL in the address bar:
http://192.168.0.10/bWAPP
Press Enter.
Step 3
The login page of the bWAPP application is displayed.
In the Username box on the bWAPP login page, type the following username:
bee
bug
Click Login.
Step 4
From the Choose your bug drop-down, select Restrict Folder Access, and
click Hack.
Step 5
Notice that there are several files located in this directory.
Click OK.
Step 10
You are on the login page.
Step 11
http://192.168.0.10/bWAPP/restrict_folder_access.php
Press Enter.
Step 13
You are redirected to the login page, confirming that you have successfully logged out.
Step 14
Go back to the second tab on which you had opened the PDF and copy the complete
path.
Step 15
Overwrite the existing path with the one you copied from the second tab.
Step 17
Notice that the login page is no longer visible.
An attacker can exploit insecure access controls that are used within an application.
these insecure access control methods include:
Learning Outcomes
After completing this exercise, you will be able to:
In this exercise, you will view the cookie and use it to launch another session.
Learning Outcomes
After completing this exercise, you will be able to:
In this session, you will learn to view session ID and launch another session.
Step 1
Connect to PLABWIN10.
Ensure that the Microsoft Edge window is open. The Session Mgmt —
Administrative Portals page is displayed.
Step 2
From the Choose your bug drop-down, select Session Management — Session ID
in URL and click Hack.
Step 3
The Session Mgmt. — Session ID in the URL page is displayed.
Notice that the URL displays the PHPSESSID that contains the session ID.
Step 4
Typically, in most cases, if a web application is closed on one tab, the session should
close.
However, because you know the session ID, you can simply copy the entire URL to
launch it in another window.
Open a new tab by clicking the + sign and then close the bWAPP tab.
Step 6
In the address bar, paste the new URL and press Enter.
Learning Outcomes
In this module, you will complete the following exercises:
After completing this module, you will have further knowledge of:
Web API
Webhooks
Web Shell
Lab Duration
It will take approximately 30 minutes to complete this lab.
Learning Outcomes
After completing this exercise, you will have further knowledge of:
Similarly, cloud service providers host the applications in a shared environment. If one
application is compromised, other similar apps can be exploited for the same
vulnerabilities. Administrative interfaces are mostly targeted with these attacks.
To prevent such attacks, you need to ensure the implementation of a strict access control
mechanism. Also, a client should be separated with proper access implementation.
Another prevention method is to ensure that hosts are properly patched, as this will
reduce the attack surface for an attacker as there are fewer vulnerabilities.
Hash Stealing: This attack applies to Microsoft SQL Servers. When an application
attempts to connect to a database, an attacker sniffs Windows credentials, which are
in the form of hashes. An attacker then changes the DataSource and
IntegratedSecurity parameters in the connection string with the name of their own
Microsoft SQL server and sets the IntegratedSecurity parameter to No.
Port Scanning: In this attack, an attacker would change the TargetPort parameter
in the connection string and attempt to view generated messages. An attacker then
keeps changing the port number to view different error messages.
Hijacking Web Credentials: In this attack, an attacker connects directly with a
database rather than an application via a web application system account. Once they
have gained access, they modify the connection string and change the
IntegratedSecurity parameter to True.
Attackers probe for the WSDL documents containing information about the service
ports. Attackers use these documents to extract application information, such as
message types and entry points into the application. An attacker creates valid SOAP
requests containing malicious content and sends them to a web application. When errors
are generated, an attacker can extract important information that can reveal
vulnerabilities.
In this exercise, you will learn about Web API, Webhooks, and Web Shells.
Learning Outcomes
After completing this exercise, you will have further knowledge of:
Web API
Webhooks
Web Shell
Web API
A Web API is an online service that works with the client applications and pulls or
pushes the data from applications, and in most cases, Web APIs use the HTTP protocol
to fetch and update information. You can create a Web API using various technologies,
such as Java and .Net.
Figure 1.1: Diagram showing a Web API sitting between responses and requests to a web
server & database.
Consider an example where you want to pull information from a Twitter account. You
can design a Web API that will integrate into your application and pull the required
information directly from Twitter.
There are different types of Web APIs that you can use depending on your needs.
REST: REST is not a protocol or API but instead an architecture that can use SOAP
or HTTP protocols. REST supports data in different formats, such as HTML, JSON,
XML, and plain text. REST does not define its security like SOAP; instead, it uses the
security of the method used for transporting the information.
RESTful: The RESTful API is defined based on the REST architecture and uses
HTTP as the protocol. The differences from REST include support for various HTTP
methods, such as PUT, DELETE, GET, and GET. It has various features, such as
stateless, cacheable, layered system, and client/server architecture.
XML-RPC: XML-RPC is a protocol that uses XML to transfer data — same as SOAP.
However, it is faster and consumes less bandwidth than the REST API.
Webhooks
Webhooks are known as Push or Reverse APIs. They are intended to push information
based on certain events. For example, when someone sends a friend request on
Facebook, you get a notification or message on your mobile phone or email address.
ClientAPIWeb Server & DatabaseAPI RequestWebhook
Figure 1.2: Diagram showing a Webhook, sending data back to a client device after an
API request.
Webhooks are event dependent in that if an event is not triggered, webhooks are not
triggered either. With the immediate launch of a webhook, information is notified to a
user in real-time. The important point to note about webhooks is that it is one-way
communication. Another important point is the connectivity between the sending and
receiving systems.
Web Shell
An attacker uses a server-side programming language, such as PHP, Perl, and ASP, to
create a web shell; malicious code is deployed on a server remotely.” to “ A Web Shell is a
malicious piece of code created by server-side languages such as Perl, RUBY, PHP, or
Python that are installed on a web server and enable attackers remote access or remote
administration over the target system.
Figure 1.3: Diagram showing a Web Shell being utilized by an attacker alongside a
backdoor to a webserver.
An attacker uses various methods to deploy the web shell on the target server, including
the following:
SQL Injection
For example, if there is a SQL vulnerability, an attacker uses SQL Injection and exploits
it. They then deploy a web shell on the target server. Using the capabilities of the web
shell, they perform privilege escalation to get control over the data. Once an attacker has
gained administrative access, they can exploit the application in different ways, such as
modifying or exfiltrating data.
Some of the commonly used shells by attackers include:
C99
R57
b374k
Note: As of the time of writing, all of these tools are available on GitHub.
In this exercise, you will learn about various web application security methods.
Learning Outcomes
After completing this exercise, you will have further knowledge of:
Manual: Manual testing is performed to detect business logic flaws and threats. A
tester can use custom code to test pre-existing code. Some of the key tools for
manual testing include JMeter, Loadrunner, and Selenium.
Automated: Automatic testing is a method of testing code at every development
stage, allowing developers to perform fixes before moving ahead. Testing methods
are programmed to conduct tests without any manual intervention. Some of the key
tools for automated tests include TestComplete, Katalon Studio, and TestSigma.
An automated source code review is fast and can track hidden vulnerabilities that could
have been missed in a manual source code review. However, the downside of automated
source code review is that it depends on the reviewing application’s rules and parameters
to detect vulnerabilities. It can easily miss vulnerabilities that are not programmed for
detection within the application. It also requires a skilled tester to set up the automated
source code testing environment.
Unicode Encoding: Is of two types. In the 16-bit Unicode Encoding, the Unicode
character is replaced with %u suffixed with the character’s hexadecimal value. The
UTF-8 method uses a variable length where each byte is replaced with the
hexadecimal value prefixed with %. An example is %c2a8.
Hex Encoding: Converts the text into hex characters. An example of text PLAB is
converted to 504c4142.
SQL Injection
An attacker can use SQL queries to access a backend database. An attacker uses an SQL
Injection vulnerability within a web application and adds a malicious SQL script that
allows them to gain access to a database. To prevent SQL Injection attacks, you can use
some of the following countermeasures:
Keep a web server and database server on separate systems and preferably on
different segments — a web server in the DMZ and database server on a separate
segment on an internal network
Several applications suffer from broken authentication and poor session management
flaws, allowing attackers to access session information, secret keys, and passwords.
Some key countermeasures include:
Sensitive data can include various types of information, such as social security and credit
card numbers. Any application that is making use of sensitive information needs to
ensure that it is protected and secured by using key countermeasures, such as:
TLS with HTTP Strict Transport Security (HSTS) for traffic in motion
In a broken access control attack, an attacker can access resources that should not be
accessed. Such an attack leads to information disclosure, unwanted modification, or data
destruction. To prevent broken access control attacks, you can use some of the key
countermeasures:
Security Misconfigurations
Test web applications thoroughly and evaluate code using manual and automated
testing
You need to monitor your web application continuously. You also need to track the
events taking place with the application. In several cases, administrators do not do this
and realize its importance only after an attack has taken place. You should use the
following key countermeasures in logging and monitoring:
Enable user-specific logging to ensure that events can be traced back to users
Define the scope for monitoring and logging — you do not need to log the successful
logins, but failed ones should be tracked
Ensure all failed events, such as failed logins, are logged
Directory Traversal
Using a directory traversal attack, an attacker can gain access to directories on a web
server. An attacker may also gain access outside the root directory in this attack. To
prevent this attack, you can use the following key countermeasures:
Validate the user input strings — use whitelisting to allow specific characters
To prevent CSRF attacks, you can implement some of the following key
countermeasures:
Cookie Poisoning
Cookies can be used for various purposes, such as maintaining sessions or containing
sensitive information, such as passwords. An attacker can modify the cookie’s contents
and gain access to the session. To prevent such attacks, you can use some of the
following key countermeasures:
Use anti-malware applications to scan for malicious scripts, which hunt for cookies
Attackers exploit the improperly implemented password reset methods. For example, an
application does not set the timeout on the password reset URLs. If this URL falls into
an attacker’s hands, they can reset the password. Several methods can be employed to
prevent password reset attacks, such as: