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

sql字符型注入的基本步骤,当输入参数为字符串时,称为字符型。小小课堂网( www.xxkt.org )分享的是《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) + ‘ ‘)

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

所有文章均为小小课堂网原创。发布者:SEO免费培训教程,转转请注明出处:https://www.xxkt.org/15152

(0)
上一篇 2022年2月25日 下午1:42
下一篇 2022年2月25日 下午1:49

相关推荐

发表评论

您的电子邮箱地址不会被公开。

error: Content is protected !!