# WEB 05: Server-side request forgery (SSRF) ![](https://i.imgur.com/mjq1sIx.png) ## Lab: 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. ``` Access vào bài lab, khi thực hiện `Check stock` sẽ có một POST request đến /product/stock với data `stockApi` là backend api để kiểm tra tình trạng của product ![](https://i.imgur.com/JI9iWDz.png) Tuy nhiên ta có thể thay đổi giá trị này để khai thác ssrf ![](https://i.imgur.com/dtp1jzQ.png) Xóa user carlos với `stockApi=http://localhost/admin/delete?username=carlos` và solve bài lab ## Lab: 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. ``` Ở bài này khác bài trước đó là admin interface được đặt ở một internal server khác vì vậy ta sẽ cần phải scan dải IP đó để tìm ra đúng server và thực hiện xóa user carlos tương tự như bài trước Đưa request vào intruder: ![](https://i.imgur.com/yOy33mU.png) Payload options như sau: ![](https://i.imgur.com/dZJ0kIa.png) Start attack và solve bài lab ![](https://i.imgur.com/aXDQcX3.png) ## Lab: 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. The developer has deployed two weak anti-SSRF defenses that you will need to bypass. ``` ![](https://i.imgur.com/D6FzSBB.png) Và delete user carlos để solve bài lab ![](https://i.imgur.com/XsTIbzZ.png) ## Lab: SSRF with whitelist-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. The developer has deployed an anti-SSRF defense you will need to bypass. ``` Bài lab này lợi dụng khai thác sự khác nhau giữa hai url parser. Từ lỗi có thể đoán được url từ `stockApi` sẽ được parse thông qua thư viện của ngôn ngữa java ![](https://i.imgur.com/3uL1103.png) Ý tưởng ở đây sẽ là chèn vào kí tự `#` (đóng vai trò là fragment trong thành phần của url) để "kết thúc" url. Payload cuối cùng ![](https://i.imgur.com/68t9MbA.png) Có thể thấy khi được parse thông qua lib của java, url sẽ trở thành `http://localhost%23@stock.weliketoshop.net/admin` => vẫn thỏa whitelist và khi được url decode lần thứ hai sẽ trở thành `http://localhost#@stock.weliketoshop.net/admin` => vào được admin interface Tiếp theo chỉ cần delete user carlos và solve bài lab. ## Lab: SSRF with filter bypass via open redirection vulnerability ```! 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 affecting the application first. ``` Ta có thể phát hiện lỗi Open redirect ngay tại request sau ![](https://i.imgur.com/n4TnLKh.png) Để Bypass filter và access vào admin interface ta chỉ cần thay giá trị `path`: ![](https://i.imgur.com/hTjYEMB.png) Delete user carlos và solve bài lab ![](https://i.imgur.com/tlDaja3.png) ## Lab: Blind SSRF with out-of-band detection ```! 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. ``` Từ mô ta bài lab, ta biết rằng server sẽ fetch đến url được chỉ định trong header `Referer` vì vậy ta chỉ cần chỉnh giá trị của trường này thành một burp collaborator domain ![](https://i.imgur.com/jRdDJvX.png) ## Lab: Blind SSRF with Shellshock exploitation ```! 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. ``` Sử dụng extension collaborator everywhere để automatic scan blind ssrf, ta có được kết quả như sau ![](https://i.imgur.com/uZqzYTL.png) Từ hình trên có thể thấy ngoài trường `Referer` được đề cập trong mô tả của bài lab còn có một trường nữa là `User-Agent` cũng dính lỗi blind ssrf. Search google với keyword "shellsock user agent" sẽ dẫn đến link [này](https://blog.cloudflare.com/inside-shellshock/), nói về việc khai thác shell shock thông qua User-Agent header. Cuối cùng, chèn payload để exiftrate tên của OS vào user-agent sau đó brute force dải IP để exploit internal server với Intruder ![](https://i.imgur.com/6av9oGp.png) Kết quả: ![](https://i.imgur.com/eNGjSPi.png) Submit `peter-klFtCQ` và solve bài lab. ###### tags: `portswigger`