boot767 notes · 24 posts

Every Shell Leaves a Trace

I keep what I learn about offensive security here: my notes from CTFs, certifications and university, plus the walkthroughs I write when a box is worth sharing. It's organized the way I work a box. Recon first, then a foothold, then privilege escalation, then the rest of the network.

latest transmission · 2026-11-19Collection of OSINT Tools and Resources
boot767 notes · 24 posts

Every Shell Leaves a Trace

I keep what I learn about offensive security here: my notes from CTFs, certifications and university, plus the walkthroughs I write when a box is worth sharing. It's organized the way I work a box. Recon first, then a foothold, then privilege escalation, then the rest of the network.

latest transmission · 2026-11-19Collection of OSINT Tools and Resources

SQLite

Flat-file SQLite databases left inside a web root can be downloaded and read in full. This note covers why that happens and the basic sqlite3 commands for querying one.

Databases and Flat Files

The most common way to store a large amount of data in a format that is easy to reach from many places is a database. That suits a web application well, since many users may be using the site at any time. Database engines usually follow Structured Query Language (SQL) syntax.

In production it is common to see databases on dedicated servers running a database service such as MySQL or MariaDB. Databases can also be stored as files, though. These are called "flat-file" databases because they are stored as a single file on the computer. This is much easier than setting up a whole database server and could show up in smaller web applications. Accessing a database server is outwith the scope of today's task, so the focus here is flat-file databases.

Why Flat Files Are a Risk

A flat-file database is just a file on the computer's disk. Usually that is not a problem for a web app. But if the database is stored underneath the root directory of the website (i.e. one of the files accessible to the user connecting to the website), it can be downloaded and queried on our own machine, with full access to everything in it. Sensitive Data Exposure, indeed!

That is a big hint for the challenge, so here is a short look at the syntax for querying a flat-file database.

SQLite and sqlite3

The most common (and simplest) flat-file database format is SQLite. SQLite databases can be used from most programming languages and have a dedicated command-line client for querying them. That client is sqlite3, and it is installed by default on many Linux distributions.

Check the Downloaded File

Suppose a database has been downloaded successfully:

user@linux$ ls -l 
-rw-r--r-- 1 user user 8192 Feb  2 20:33 example.db
                                                                                                                                                              
user@linux$ file example.db 
example.db: SQLite 3.x database, last written using SQLite version 3039002, file counter 1, database pages 2, cookie 0x1, schema 4, UTF-8, version-valid-for 1

There is an SQLite database in the current folder.

Open It

To open it, use sqlite3 <database-name>:

user@linux$ sqlite3 example.db                     
SQLite version 3.39.2 2022-07-21 15:24:47
Enter ".help" for usage hints.
sqlite> 

List the Tables

The .tables command lists the tables in the database:

user@linux$ sqlite3 example.db                     
SQLite version 3.39.2 2022-07-21 15:24:47
Enter ".help" for usage hints.
sqlite> .tables
customers

Read the Table Info and Dump the Data

All the data in the table could be dumped right away, but without the table information it is not clear what each column means. So first PRAGMA table_info(customers); shows the table information, then SELECT * FROM customers; dumps its contents:

sqlite> PRAGMA table_info(customers);
0|cudtID|INT|1||1
1|custName|TEXT|1||0
2|creditCard|TEXT|0||0
3|password|TEXT|1||0

sqlite> SELECT * FROM customers;
0|Joy Paulson|4916 9012 2231 7905|5f4dcc3b5aa765d61d8327deb882cf99
1|John Walters|4671 5376 3366 8125|fef08f333cc53594c8097eba1f35726a
2|Lena Abdul|4353 4722 6349 6685|b55ab2470f160c331a99b8d8a1946b19
3|Andrew Miller|4059 8824 0198 5596|bc7b657bd56e4386e3397ca86e378f70
4|Keith Wayman|4972 1604 3381 8885|12e7a36c0710571b3d827992f4cfe679
5|Annett Scholz|5400 1617 6508 1166|e2795fc96af3f4d6288906a90a52a47f

The table information shows four columns: custID, custName, creditCard and password, and they line up with the results. Take the first row:

0|Joy Paulson|4916 9012 2231 7905|5f4dcc3b5aa765d61d8327deb882cf99

That is the custID (0), the custName (Joy Paulson), the creditCard (4916 9012 2231 7905) and a password hash (5f4dcc3b5aa765d61d8327deb882cf99).

The next task looks at cracking this hash.