■ ■ ■ ■ ■ ■
CyberSecurity/Web/BountyStory/RemoteCodeExecution/20230317 - Remote Command Execution in a Bank Server.md
| 1 | + | # Remote Command Execution in a Bank Server 👽 |
| 2 | + | |
| 3 | + | ### Discovery 🔍 |
| 4 | + | 1. There was a functionality that user could download a PDF file<br> |
| 5 | + | 2. Observe the filename and folder parameters in the request<br> |
| 6 | + | 3. It was straightforward, send passwd and /etc<br> |
| 7 | + | It's WORKED 🥳<br> |
| 8 | + | ![20230317-1.png](../images/20230317-1.png)<br> |
| 9 | + | <br> |
| 10 | + | |
| 11 | + | ### Deep Dive 🔬 |
| 12 | + | 1. The app does not allow us to pass directory traversal payloads (‘../’, ‘%2e%2e%2f’)<br> |
| 13 | + | 2. tried to get some default internal OS configuration files, but most of the files give an error.<br> |
| 14 | + | 3. Looked at the passwd file again and saw an interesting 'grcdm' user.<br> |
| 15 | + | ![20230317-2.png](../images/20230317-2.png)<br> |
| 16 | + | <br> |
| 17 | + | |
| 18 | + | ### Further exploration 🔦 |
| 19 | + | 1. I tried with ~/.bash_history payload (/home/grcdm and .bash_history) |
| 20 | + | 2. I got the complete command history of user 'grcdm' |
| 21 | + | 3. After analyzing all the commands, I found the web host’s root path. |
| 22 | + | ![20230317-3.png](../images/20230317-3.png)<br> |
| 23 | + | <br> |
| 24 | + | |
| 25 | + | ### Analysis 🧩 |
| 26 | + | 1. I copied the names of all JSP pages using the Target Analyzer of the Burp Suite (Engagement Tools) |
| 27 | + | 2. Configured the intruder and set the attack point to the filename parameter. |
| 28 | + | 3. I found a Directory Listing. vulnerability in cr_master_invoice.jsp. |
| 29 | + | ![20230317-4.png](../images/20230317-4.png)<br> |
| 30 | + | <br> |
| 31 | + | |
| 32 | + | ### Analysis 🧩 |
| 33 | + | 1. I passed ../../../../../../etc and saw that it listed all contents of etc directory. |
| 34 | + | 2. Crawled all folders with the help of internal directory listing. |
| 35 | + | 3. I saw an unlinked JSP file that was vulnerable to Unrestricted File Upload. |
| 36 | + | ![20230317-5.png](../images/20230317-5.png)<br> |
| 37 | + | <br> |
| 38 | + | |
| 39 | + | ### Exploitation 💣 |
| 40 | + | 1. I quickly created an HTML file upload page and specified a vulnerable endpoint in the action attribute of the form tag. |
| 41 | + | 2. Opened the created HTML page in the browser and selected the JSP web shell to upload. |
| 42 | + | ![20230317-6.png](../images/20230317-6.png)<br> |
| 43 | + | <br> |
| 44 | + | |
| 45 | + | ## Credit |
| 46 | + | Based on [Bipin Jitiya](https://medium.com/@win3zz/remote-command-execution-in-a-bank-server-b213f9f42afe)'s writeup. |
| 47 | + | <br> |
| 48 | + | |
| 49 | + | ## Support |
| 50 | + | You can Follow [me](https://twitter.com/MeAsHacker_HNA) on twitter or |
| 51 | + | <br><br><a href="https://www.buymeacoffee.com/NafisiAslH" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a> |
| 52 | + | |