---
# System prepended metadata

title: Write-up Practical Bug Bounty — TCM Academy

---

# Write-up Practical Bug Bounty — TCM Academy

## 1. Authentication and Authourization 
| Criterion | Authentication | Authorization |
| :--- | :---: | ---: |
| Meaning | Verification of user identity. Answers the question: "Who are you?" | Control over authenticated user access rights. Answers the question: "What are you allowed to do?" |
| Real-World Example | Logging in with a username and password| A user is allowed to view their own profile page, but denied access to the admin panel |
| Related Flaws| Brute force, weak password, session fixation, and 2FA bypass| IDOR (Insecure Direct Object Reference), BOLA (Broken Object Level Authorization), Broken Access Control, and Privilege Escalation|
### Auth0x01
![image](https://hackmd.io/_uploads/BJ3FnXDzZg.png)
Sent request to intruder
![image](https://hackmd.io/_uploads/HkW53mwMZx.png)
Use this wordlists `/usr/share//seclists/Passwords/xato-net-10-million-usernames.txt`
![image](https://hackmd.io/_uploads/BkZon7DzZl.png)
Brute-force and filter this string `Your username or password was incorrect!`
![image](https://hackmd.io/_uploads/HkNs3XPMWl.png)
![image](https://hackmd.io/_uploads/Skcs3Xvfbl.png)
Another way is to use ffuf:
![image](https://hackmd.io/_uploads/HkMh27wf-l.png)
![image](https://hackmd.io/_uploads/rJFh2XwM-e.png)
![image](https://hackmd.io/_uploads/B1kpnmwfWx.png)
![image](https://hackmd.io/_uploads/BJX63QPzbe.png)
Filter the results that return size 1814:
![image](https://hackmd.io/_uploads/HyuTnXwzbx.png)

### Auth0x02
This lab is two-factor authentication.
![image](https://hackmd.io/_uploads/SkL0tlhzWe.png)
![image](https://hackmd.io/_uploads/r13RFghfWl.png)
![image](https://hackmd.io/_uploads/BJQkql2fbe.png)
![image](https://hackmd.io/_uploads/BkGGcxnMbx.png)
![image](https://hackmd.io/_uploads/ByJmcl3MZl.png)
![image](https://hackmd.io/_uploads/rkg_5x3M-x.png)
Intercept and change the username jessmy to jeremy
![image](https://hackmd.io/_uploads/Sy8uqgnfZx.png)
![image](https://hackmd.io/_uploads/HkBYcghGZg.png)
![image](https://hackmd.io/_uploads/rktKce3Mbx.png)

### Auth0x03
![image](https://hackmd.io/_uploads/B1gY0clhzZl.png)

### Auth0x04
`Insecure Direct Object Reference (IDOR)` allows a user to access other accounts' details by simply modifying the direct object reference (the account ID) in the URL parameter `?account=`. The application fails to perform an authorization check to ensure the logged-in user owns the requested account ID.
![image](https://hackmd.io/_uploads/S1Ulje2fWl.png)
![image](https://hackmd.io/_uploads/B1nejenz-g.png)

### Auth0x05

Introducing the API through [cat facts API](https://catfact.ninja/).
![image](https://hackmd.io/_uploads/HkC92x3Gbg.png)
![image](https://hackmd.io/_uploads/BkVThlnfWg.png)
![image](https://hackmd.io/_uploads/HJtp2l2zZl.png)
`curl -X PUT -H "Content-Type: application/json" -d '{"token": "<token_Jeremy>", "username": "Jeremy", "bio": "New bio information."}' http://localhost/labs/api/account.php`
This endpoint, combined with a `weak JWT` or a lack of proper ID/token linking, is the attack vector used to demonstrate the `Broken Object Level Authorization (BOLA)` or `Insecure Direct Object Reference (IDOR)` on the `API`.
![image](https://hackmd.io/_uploads/rJ9C3x3zbx.png)
![image](https://hackmd.io/_uploads/Bka0nl3M-g.png)

### Auth0x06

This lab silimar Auth0x05 but use extension `Autorize` in BurpSuite.
![image](https://hackmd.io/_uploads/S1SoTg3fZe.png)
![image](https://hackmd.io/_uploads/H1sjag2M-e.png)
`Autorize` automatically repeats every single request made by a `high-privileged user session` using the cookies of a `low-privileged user session`.
![image](https://hackmd.io/_uploads/BJk26lnG-l.png)
![image](https://hackmd.io/_uploads/Byzh6lhM-l.png)
As shown in the tool's interface, the `PUT /labs/api/account.php` requests resulted in a `"Bypass..."` status in the `Autoriz is on` columns, confirming that the authorization checks could be easily bypassed.
![image](https://hackmd.io/_uploads/HJD3Tg2M-g.png)

## 2. Injection

### File inclusion
`Local File Inclusion (LFI)`: An attack where the attacker forces the web server to read a file that is located on the server itself. This vulnerability is typically caused by unvalidated input being passed to file-handling functions like `include()` or `require()`.

`Remote File Inclusion (RFI)`: An attack where the attacker forces the server to download and execute a file hosted on the attacker's own machine, usually via a URL.

### File inclusion 0x01

![image](https://hackmd.io/_uploads/Syh9ZWnM-l.png)
![image](https://hackmd.io/_uploads/S1Zs-bhz-e.png)
![image](https://hackmd.io/_uploads/B1BoW-2M-g.png)
![image](https://hackmd.io/_uploads/HyKib-nz-x.png)
![image](https://hackmd.io/_uploads/rJCoWb3zWe.png)

### File inclusion 0x02
![image](https://hackmd.io/_uploads/S1i_G-nzZe.png)
![image](https://hackmd.io/_uploads/HJkKGb2fWe.png)
Try to bypass filter.
![image](https://hackmd.io/_uploads/HyMKfW2zWg.png)
Use this payload`..././..././..././` to bypass filter.
![image](https://hackmd.io/_uploads/SyUtfZ2fZg.png)
![image](https://hackmd.io/_uploads/HkFYM-2GZe.png)
![image](https://hackmd.io/_uploads/rJeqGWhMWl.png)

### File inclusion 0x03

![image](https://hackmd.io/_uploads/B1JGmb2f-e.png)
![image](https://hackmd.io/_uploads/rJZGQb2fZg.png)
![image](https://hackmd.io/_uploads/HkPf7-nG-g.png)
![image](https://hackmd.io/_uploads/B15f7W2Mbg.png)
![image](https://hackmd.io/_uploads/S1RzmZnMZg.png)
Quite a lot of payloads return `words 19, 20`; now we just need to filter them out.
![image](https://hackmd.io/_uploads/S14QmZnf-e.png)
![image](https://hackmd.io/_uploads/HJ_Q7bhzbg.png)
![image](https://hackmd.io/_uploads/r1iX7W2zZl.png)

### SQL injection

Some queries in MySQL:
![image](https://hackmd.io/_uploads/ryzFEZ2z-l.png)
![image](https://hackmd.io/_uploads/HkrYNb2fWg.png)
![image](https://hackmd.io/_uploads/B1FF4-nM-g.png)
![image](https://hackmd.io/_uploads/S12KEWhzZl.png)
![image](https://hackmd.io/_uploads/rJxc4b3zbg.png)

### SQL injection 0x01
Some basic sqli payload:
![image](https://hackmd.io/_uploads/rJQa4bnM-x.png)
![image](https://hackmd.io/_uploads/HJLaEZ2zbx.png)
![image](https://hackmd.io/_uploads/Sys64-hMZx.png)
![image](https://hackmd.io/_uploads/H1ApNW3fZx.png)
![image](https://hackmd.io/_uploads/SJfC4-nGWl.png)
![image](https://hackmd.io/_uploads/BJLA4Z2MWx.png)
![image](https://hackmd.io/_uploads/SJtR4-hGWe.png)
![image](https://hackmd.io/_uploads/SJTRNW3GWg.png)

### SQL injection 0x02

![image](https://hackmd.io/_uploads/HkvtG-_V-e.png)
![image](https://hackmd.io/_uploads/BJ3YzWuVWl.png)

First, i'll test for SQL injection vulnerabilities by injecting payloads into the login form, where untrusted data is most likely to occur. 

![image](https://hackmd.io/_uploads/ryI7XbON-x.png)
![image](https://hackmd.io/_uploads/SJtm7WdVbe.png)
![image](https://hackmd.io/_uploads/Hypm7bdE-l.png)
![image](https://hackmd.io/_uploads/BkXEmZONZl.png)
![image](https://hackmd.io/_uploads/S1r47-OVZg.png)
It seems SQLI isn't happening here.

Try the payload in a different request that contains cookies.
![image](https://hackmd.io/_uploads/BJD1NWd4bx.png)
I used blind sqli to test and found that this one was sqlied.
![image](https://hackmd.io/_uploads/rJ7QNWd4Wg.png)
![image](https://hackmd.io/_uploads/B1UmNZuEbe.png)
Test with sqlmap:
![image](https://hackmd.io/_uploads/HkOVV-OVZl.png)
![image](https://hackmd.io/_uploads/SyhNVbONbg.png)
![image](https://hackmd.io/_uploads/r1HrV-uEWl.png)
![image](https://hackmd.io/_uploads/Sk_S4-dVZx.png)
![image](https://hackmd.io/_uploads/Bydv4-uNbe.png)
![image](https://hackmd.io/_uploads/HJjDEbO4Wl.png)

Use `substring` to test blind sqli to find database version.

![image](https://hackmd.io/_uploads/BJb2NW_V-x.png)
![image](https://hackmd.io/_uploads/BJmnNb_N-g.png)
![image](https://hackmd.io/_uploads/ry8nNb_4We.png)
![image](https://hackmd.io/_uploads/By524bONZe.png)

### SQL injection 0x03 

![image](https://hackmd.io/_uploads/SkokBb_VWe.png)
![image](https://hackmd.io/_uploads/HJMgSZuE-e.png)
![image](https://hackmd.io/_uploads/HkZ-r-_NZl.png)
This is `UNION-based SQLi`
![image](https://hackmd.io/_uploads/rJMSS-uV-x.png)
![image](https://hackmd.io/_uploads/rJLrr-_Ebe.png)
![image](https://hackmd.io/_uploads/SJiSHZ_4Zl.png)
![image](https://hackmd.io/_uploads/BJTrS-_EWx.png)

### SQL injection 0x04

![image](https://hackmd.io/_uploads/SyixIbuVWe.png)
Another very popular method is `SQLi Authentication Bypass`.
![image](https://hackmd.io/_uploads/Bkh_UWd4Ze.png)
![image](https://hackmd.io/_uploads/SykYIZu4We.png)
![image](https://hackmd.io/_uploads/SJftUbu4-e.png)

Signed up as `' or 1=1 --` and the database just gave me the keys to the db. Seeing my SQL payload being `welcome` on the dashboard.

### XSS

![image](https://hackmd.io/_uploads/S1TJuZ_NZg.png)
`Reflected`: The payload is bounced off the server and executed immediately in the response, usually via a malicious link.
![image](https://hackmd.io/_uploads/SkZld-_NWg.png)
`Stored`: The payload is saved permanently in the database and attacks anyone who views the infected page by far the most dangerous.
![image](https://hackmd.io/_uploads/Sy4gub_4-g.png)
`DOM-based`: The vulnerability exists entirely in the client-side code. The payload is processed by the browser without ever touching the server.

### XSS 0x01
![image](https://hackmd.io/_uploads/Hy5FObd4We.png)
![image](https://hackmd.io/_uploads/B1AY_W_NWx.png)
![image](https://hackmd.io/_uploads/ByzqO-uEWl.png)
Using `textContent` safely converts dangerous characters like `< >` into plain text, preventing HTML execution and script injection. Even if a user enters `<script>alert(1)</script>`, it is rendered as harmless string and never runs.

But then it immediately self-destructed: `newItem.innerHTML = newItem.textContent;`
=> This has rendered all security efforts of the previous line ineffective. When converted back to `innerHTML`, the browser will parse that text as HTML code.

![image](https://hackmd.io/_uploads/HJa_KWdEWl.png)
![image](https://hackmd.io/_uploads/HJNtKZuEWg.png)

### XSS 0x02
![image](https://hackmd.io/_uploads/Hy25tbuEbe.png)

### XSS 0x03
![image](https://hackmd.io/_uploads/SkZ2Yb_E-e.png)
![image](https://hackmd.io/_uploads/HyDnFbdEWx.png)
![image](https://hackmd.io/_uploads/B1hnFbOE-x.png)

### Command injection
![image](https://hackmd.io/_uploads/HJ0G9-_NWg.png)
![image](https://hackmd.io/_uploads/HJHQ5ZuEbe.png)
`eval()` is a high-risk function that executes strings as actual code. Using it with untrusted user input is a massive security hole, as it allows for immediate `Command Injection`.

### Command injection 0x01

![image](https://hackmd.io/_uploads/SkPsobdEbx.png)
![image](https://hackmd.io/_uploads/SJ9jib_VZl.png)
`; (Semicolon)`: Executes the first command, then the second, regardless of whether the first one succeeded or failed.
![image](https://hackmd.io/_uploads/Syzz2Z_4Zg.png)
`& (Background Operator)`: Runs the first command in the background and immediately starts the second one, often used to bypass certain execution flows.
![image](https://hackmd.io/_uploads/S1EQ2b_4-x.png)
![image](https://hackmd.io/_uploads/S1pNhWdNWx.png)
`# (Hash/Comment)`: Used to comment out the rest of the original command string, effectively neutralizing any legitimate code that follows your payload.

![image](https://hackmd.io/_uploads/S1682-OV-l.png)
![image](https://hackmd.io/_uploads/BkePhZON-g.png)
Try reverse shell =))

### Command injection 0x02
![image](https://hackmd.io/_uploads/HkWn2WO4be.png)
![image](https://hackmd.io/_uploads/H17jn-OEZl.png)
It still executes and returns `OK`, but the semicolon is changed to a space. Blind injection might need to be tried.

![image](https://hackmd.io/_uploads/S1lA3b_V-g.png)
![image](https://hackmd.io/_uploads/HJxuAn-uV-g.png)
![image](https://hackmd.io/_uploads/BkoC2buEbx.png)

### Command injection 0x03

![image](https://hackmd.io/_uploads/r1blpbu4-g.png)
![image](https://hackmd.io/_uploads/B1Gl6WdEbe.png)
![image](https://hackmd.io/_uploads/H1ol6WONbx.png)
![image](https://hackmd.io/_uploads/HkPf6ZOEbx.png)

### SSTI

SSTI (Server-Side Template Injection) is a vulnerability that occurs when user input is directly fed into the template engine on the server, allowing an attacker to execute code (RCE), read files, query the database, etc., depending on the capabilities of the template engine.

### SSTI 0x01
![image](https://hackmd.io/_uploads/HJHr6b_EZg.png)
=))
![image](https://hackmd.io/_uploads/BJ5STZu4bg.png)
![image](https://hackmd.io/_uploads/ryWLabONZe.png)
![image](https://hackmd.io/_uploads/HkB8TW_N-l.png)
![image](https://hackmd.io/_uploads/H1O8pZu4Zg.png)

### SSTI 0x02
![image](https://hackmd.io/_uploads/HJhD6WuEWe.png)
![image](https://hackmd.io/_uploads/HJ1_aZdN-l.png)
![image](https://hackmd.io/_uploads/Sk7uaWd4-l.png)
![image](https://hackmd.io/_uploads/BkUu6ZOE-g.png)
![image](https://hackmd.io/_uploads/SkKOp-uVbg.png)
![image](https://hackmd.io/_uploads/Bkhua-uVZe.png)
![image](https://hackmd.io/_uploads/SJkYT-OEWe.png)
![image](https://hackmd.io/_uploads/SkGKpWOEZe.png)

### XXE

`XXE` is a vulnerability where an application's `XML parser` is tricked into processing malicious external entities. This allows attackers to read local files on the server, perform internal port scanning, or even trigger `Remote Code Execution (RCE)`.
### XXE 0x01
![image](https://hackmd.io/_uploads/rJg36WdE-e.png)
![image](https://hackmd.io/_uploads/rk43TZOV-g.png)
![image](https://hackmd.io/_uploads/BkPnaZd4Zg.png)
![image](https://hackmd.io/_uploads/SJqnaWOE-x.png)
![image](https://hackmd.io/_uploads/SJ16TZONWe.png)

## 3. Other attack

### File upload

Unrestricted File Upload occurs when a server allows users to upload malicious files (like `.php` or `.jsp`) without proper validation. This can lead to a complete system takeover via a `Web Shell` or `Remote Code Execution (RCE)`.
If you encounter this bug, you can fix it as follows.
![image](https://hackmd.io/_uploads/SJcMJMONZg.png)
![image](https://hackmd.io/_uploads/By2G1zd4be.png)

### File upload 0x01

![image](https://hackmd.io/_uploads/ry5v1fONWe.png)
![image](https://hackmd.io/_uploads/HJhwyGd4Zl.png)
![image](https://hackmd.io/_uploads/Hky_1G_4Zx.png)
![image](https://hackmd.io/_uploads/HJN_yf_V-x.png)
![image](https://hackmd.io/_uploads/HJxqkzuN-g.png)
Change the `filename="..."` from `.png` to `.php` and remove the `magic bytes`.
![image](https://hackmd.io/_uploads/ryVqJzdVbe.png)
![image](https://hackmd.io/_uploads/HJlnyM_E-e.png)

### File upload 0x02

![image](https://hackmd.io/_uploads/By6FlfOVZx.png)
![image](https://hackmd.io/_uploads/H11qgMOVWx.png)
![image](https://hackmd.io/_uploads/S1X9lf_VWx.png)
![image](https://hackmd.io/_uploads/H1Lqezu4Wx.png)

### File upload 0x03
![image](https://hackmd.io/_uploads/SkpxbfuNbx.png)
![image](https://hackmd.io/_uploads/Hy-Z-f_V-e.png)
![image](https://hackmd.io/_uploads/Bk4bWzdV-e.png)
![image](https://hackmd.io/_uploads/rJcbWMOVbx.png)
Test some payload to bypass file upload filter.
![image](https://hackmd.io/_uploads/HJp-WfuNZg.png)
![image](https://hackmd.io/_uploads/r1bMZzOEbx.png)

### CSRF
`CSRF`: Tricking a `user` into performing unintended actions on a site where they're logged in.
### CSRF 0x01
![image](https://hackmd.io/_uploads/HJezGfuEZl.png)
![image](https://hackmd.io/_uploads/ry7GfzuNbx.png)
![image](https://hackmd.io/_uploads/HkuzMzuVbl.png)
![image](https://hackmd.io/_uploads/SyifGMu4Wx.png)
![image](https://hackmd.io/_uploads/Bkymff_VWe.png)

### CSRF 0x02
![image](https://hackmd.io/_uploads/BkQXMGONWe.png)
![image](https://hackmd.io/_uploads/rkDmGMuNbg.png)
![image](https://hackmd.io/_uploads/BJ5QfGO4Wx.png)
![image](https://hackmd.io/_uploads/HypQzfOEbl.png)

### SSRF 
`SSRF`: Tricking a `server` into making requests to internal or unintended locations.
### SSRF 0x01
![image](https://hackmd.io/_uploads/r1L4zGdE-x.png)
![image](https://hackmd.io/_uploads/SkOVzM_EZe.png)
![image](https://hackmd.io/_uploads/rkiNGGOV-l.png)
![image](https://hackmd.io/_uploads/rJxBGMuNbe.png)
![image](https://hackmd.io/_uploads/SJHSfM_NWe.png)

### SSRF 0x02
![image](https://hackmd.io/_uploads/SyRPMzuNWl.png)
![image](https://hackmd.io/_uploads/Sy-OfMuEWe.png)
![image](https://hackmd.io/_uploads/HkUufzdNWe.png)
![image](https://hackmd.io/_uploads/r1duffuEbl.png)
![image](https://hackmd.io/_uploads/HJ2_fzdVWl.png)

### Open redirect 0x01
![image](https://hackmd.io/_uploads/S1BJGzuNbx.png)
![image](https://hackmd.io/_uploads/HydJGf_EZl.png)
![image](https://hackmd.io/_uploads/ryskzfOEbx.png)
![image](https://hackmd.io/_uploads/HkR1GfON-x.png)

### Input Validation 0x01
![image](https://hackmd.io/_uploads/rycCbzOVZx.png)
![image](https://hackmd.io/_uploads/HJTAbfu4Wx.png)
