
Firewall per database scritto in Go
Protegge i tuoi dati ispezionando le query in arrivo dal tuo server applicativo e rifiutando quelle anomale.
Ad esempio, ecco come un web server interagisce normalmente con il database server:

Aggiungendo DBShield davanti al server del database possiamo proteggerlo da query anomale. Per rilevare query anomale eseguiamo prima DBShield in modalità apprendimento. La modalità apprendimento lascia passare qualsiasi query ma registra informazioni su di essa (pattern, username, ora e sorgente) nel database interno.

Dopo aver raccolto abbastanza pattern possiamo eseguire DBShield in modalità protezione. La modalità protezione può distinguere pattern di query anomali, utente e sorgente e agire in base alle configurazioni.

Per la dimostrazione, usiamo sqlmap (strumento automatico di SQL injection e takeover del database) per sfruttare la vulnerabilità di SQL injection in user.php
Nel primo scenario, sqlmap sfrutta con successo la SQL injection quando l'applicazione web è connessa direttamente al database (MySQL). Nel secondo scenario, modifichiamo user.php in modo che DBShield si frapponga tra l'applicazione web e il database, interrompendo il tentativo di injection e facendo fallire sqlmap.

CLI
$ go run main.go
2016/10/15 16:25:31 [INFO] Config file: /etc/dbshield.yml
2016/10/15 16:25:31 [INFO] Internal DB: /tmp/model/10.0.0.21_postgres.db
2016/10/15 16:25:31 [INFO] Listening: 0.0.0.0:5000
2016/10/15 16:25:31 [INFO] Backend: postgres (10.0.0.21:5432)
2016/10/15 16:25:31 [INFO] Protect: true
2016/10/15 16:25:31 [INFO] Web interface on https://127.0.0.1:8070/
2016/10/15 16:25:33 [INFO] Connected from: 10.0.0.20:35910
2016/10/15 16:25:33 [INFO] Connected to: 10.0.0.21:5432
2016/10/15 16:25:33 [INFO] SSL connection
2016/10/15 16:25:34 [DEBUG] Client handshake done
2016/10/15 16:25:34 [DEBUG] Server handshake done
2016/10/15 16:25:34 [INFO] User: postgres
2016/10/15 16:25:34 [INFO] Database: test
2016/10/15 16:25:34 [INFO] Query: SELECT * FROM stocks where id=-1 or 1=1
2016/10/15 16:25:34 [WARN] Pattern not found: [53 55 51 52 55 52 50 53 55 51 53 49 115 116 111 99 107 115 53 55 51 53 50 105 100 54 49 52 53 53 55 51 55 57 53 55 52 48 52 53 55 51 55 57 54 49 53 55 51 55 57] (SELECT * FROM stocks where id=-1 or 1=1)
2016/10/15 16:25:34 [WARN] Dropping connection
Interfaccia Web

Ottienilo
$ go get -u github.com/nim4/DBShield
Puoi quindi vedere l'aiuto usando l'argomento "-h":
$ $GOPATH/bin/DBShield -h
DBShield 1.0.0-beta3
Usage of DBShield:
-a get list of abnormal queries
-c file
config file (default "/etc/dbshield.yml")
-h show help
-k show parsed config and exit
-l get list of captured patterns
-version
show version
ed eseguilo con la tua configurazione, ad esempio:
$ $GOPATH/bin/DBShield -c config.yml
vedi il file di configurazione di esempio
⚠️ ATTENZIONE: Non utilizzare i certificati predefiniti in ambienti di produzione!
(Ordinato per priorità)
| Database | Protezione | SSL |
|---|
| DB2 | ![]() | ![]() |
| MariaDB | ![]() | ![]() |
| MySQL | ![]() | ![]() |
| Oracle | ![]() | ![]() |
| Postgres | ![]() | ![]() |