# 1433, 3306 - SQL

## MariaDB / MySQL

```bash
lexi@moderators:/opt/site.new$ mysql -u wordpressuser -p
Enter password: wordpresspassword123!!
MariaDB [(none)]> show databases;
MariaDB [(none)]> use wordpress;
MariaDB [wordpress]> show tables;
MariaDB [wordpress]> select * from wp_users;

```

### Change password

The site [useotools.com](https://www.useotools.com/wordpress-password-hash-generator/output) can be used to encode passwords and will return both the hash and also the SQL Query needed to update the table.

<figure><img src="/files/x4pVuB7JQ8j3TJMdiVN4" alt=""><figcaption></figcaption></figure>

```sql
MariaDB [wordpress]> UPDATE `wp_users` SET `user_pass` = '$P$Butw21NZp/bVFKSgE6gbBKtLjkl3tQ/' WHERE user_login = 'admin';
Query OK, 1 row affected (0.002 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [wordpress]> select * from wp_users;
[... snip ...]
|  1 | admin      | $P$Butw21NZp/bVFKSgE6gbBKtLjkl3tQ/ 
```

***

## MSSQL

```bash
lab ➜ sqsh -S 10.0.50.46 -U sa -P Passw0rd! -D Voting
## List databases
1> SELECT name FROM master..sysdatabases
2> go
...
[*] flag 

## Change to db "flag" and list tables
1> use flag
2> go
1> SELECT name from sys.tables
2> go
...
 flags

## Dump content from table "flag"
1> SELECT * from flags
2> go
```

***

## PostgreSQL

```sql
$ PGPASSWORD=firmadyne psql -h localhost -p 5432 -U firmadyne -d firmware

## List databases
\l
SELECT datname FROM pg_database;

## Connect to database
\c <db_name>

## List tables
\dt

## Dump all content from table
SELECT * FROM <table_name>;

## Dump table content to file (postgres Docker container)
sudo docker exec -it -e PGPASSWORD='s3cretp@ssw0rd' vcsa_recovery_db psql -h localhost -U vc -d VCDB -c "SELECT username FROM vpx_event_$i;" -o /storage/out/event_$i.txt

## Search for keywords in column
SELECT name FROM vpxv_vms WHERE name LIKE '%dc01%';
```


---

# 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://0xpthree.gitbook.io/notes/network-services/ports/1433-3306-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.
