1. 程式人生 > 其它 >mysql sql注入

mysql sql注入

技術標籤:Mysql資料庫mysql

sql注入是指應用程式對使用者輸入資料的合法性沒有判斷、沒有過濾,攻擊者可以在應用程式中通過表單提交特殊的字串,該特殊字串會改變sql的執行結果,從而在管理員毫不知情的情況下實現非法操作,以此來實現欺騙資料庫執行非授權的任意查詢。

sql注入的特點
廣泛性:任何一個基於SQL語言的資料庫都可能受到SQL注入攻擊。很多開發人員都為了省事不對錶單引數進行校驗。
隱蔽性:SQL注入語句一般都嵌入在普通的HTTP請求中,很難與正常語句區分開,SQL注入也有很多變種。
危害大:攻擊者通過SQL注入能夠獲取到更多資料,如管理員密碼、整個系統的使用者資料、他人的隱私資料、完整的資料庫。

操作簡單:網際網路上有很多SQL注入工具,簡單易懂,攻擊過程簡單,不需要太多專業知識。

create table user(
id int not null auto_increment primary key,
username varchar(30) comment '使用者名稱',
password varchar(30) comment '密碼'
)default charset=utf8;


insert into user(username, password) values('admin', '123456');
insert into user(username, password)
values('test', '123456');
#正常查詢
select * from user where username='abc' and password='123456';

在這裡插入圖片描述

#sql注入
select * from user where username='abc' and password='123456' or '1'='1';

在這裡插入圖片描述
查詢到了所有的結果