Web-SQL注入

#Sql注入

产生的原因

可控变量,代入数据库查询变量未过滤或过滤不严谨导致

注入点判断

1.老方法 :注入点and 1=1回显正常(页面未受影响),and 1=2 回显错误代表存在注入。

http://192.168.3.45/sqli-labs/Less-2/?id=1 and 1 = 1

http://192.168.3.45/sqli-labs/Less-2/?id=1 and 1=2

2.新方法 注入点添加其他字符,看页面是否代入数据库进行查询

http://192.168.3.45/sqli-labs/Less-2/?id=1dasjkldjalk

#注入流程

发现注入点,猜测注入点字段名从而进行sql注入。

使用关键字order by

http://192.168.3.45/sqli-labs/Less-2/?id=1 order by 3

页面回显正常

http://192.168.3.45/sqli-labs/Less-2/?id=1 order by 4

 页面返回错误,猜测字段为3

#常用数据库函数

数据库版本:version()
当前用户  :user()
当前数据库:database()

#注入点参数类型

数字型

select * from a where id = 1

字符型

select * from a where name='Lalisa'
$name=$_GET['a'];
$sql="select * from user where name='$name'";

 网站搜索栏搜索语句

?name=xiao
select * from user where name like '%xiao%'

其他类型

测试文件源码

Get型


Post型


Cookie型


 

Request型(所有类型都可以)

Get方法


POST方法


$_Server类型($_SERVER['xx']是php一个方法,它可以根据参数不同查询不同的结果)


Json注入(注入点)

posted @ 2022-12-17 21:50  Aikun7  阅读(47)  评论(0)    收藏  举报