sql字符型注入的基本步骤(SQL字符型注入教程)

- 作者:小小课堂网 - 阅 659   推荐

sql字符型注入的基本步骤,当输入参数为字符串时,称为字符型。小小课堂网( xxkt.org.cn )分享的是《sql字符型注入的基本步骤(SQL字符型注入教程)》。希望对大家有所帮助。

SQL注入是什么意思

数字型与字符型注入最大的区别在于:数字类型不需要单引号闭合,而字符串一般要使用单引号来闭合。

数字型例句如下:

select * from table where id =8

字符型例句如下:

select * from table where username=’admin’

字符型注入最关键的是如何闭合SQL语句以及注释多余的代码。

当查询内容为字符串时,SQL代码如下:

select * from table where username = ‘admin’

当攻击者进行SQL注入时,如果输入“admin and 1=1”,则无法进行注入。因为“admin and 1=1”会被数据库当做查询的字符串,SQL语句如下:

select * from table where username = ‘admin and 1=1′

这时想要进行注入,则必须注意字符串闭合问题。如果输入“admin’ and 1=1 –”就可以继续注入,SQL语句如下:

select * from table where username = ‘admin and 1=1 –‘

只要是字符型注入,都必须闭合单引号以及注释多余的代码。例如,update语句:

update Person set username = ‘username’ ,set password = ‘password’ where id =1

现在对该SQL语句进行注入,就需要闭合单引号,可以在username或password处插入语句为“’+(select@@version)+’”,最终执行SQL语句为:

update Person set username = ‘username’ ,set password =’ ‘+(select@@version)+’ ‘where id =1

利用两次单引号闭合才能完成SQL注入。

注:数据库不同,字符串连接符也不同,如SQL Server连接符号为“+”,Oracle连接符为“||”,MySQL连接符为空格。

例如Insert语句:

Insert into users(username,password,title) values(‘username’,’password’,’title’)

当注入title字段时,可以像update注入一样,直接使用以下SQL语句:

Insert into users(username,password,title) values(‘username’,’password’,’ ‘ + (select @@version) + ‘ ‘)

以上就是小小课堂网( xxkt.org.cn )分享的是《sql字符型注入的基本步骤(SQL字符型注入教程)》。感谢您的阅读。

本文最后一次更新时间:2022年2月28日

本文《sql字符型注入的基本步骤(SQL字符型注入教程)》由小小课堂网整理或原创,侵删,欢迎转载并保留版权:https://xxkt.org.cn/ 感谢您的阅读。

本站提供SEO培训、咨询、诊断,QQ:2216876660 微信:huowuyan 公众号:小小课堂网

标签:

相关文章!
error: Content is protected !!