防MSXML2.XMLHTTP采集方法
[ 2012-01-10 08:52:03 | 作者: admin ]
数据采集中的攻防策略-防止数据被采集的一种新方法
用Request.ServerVariables ("all_http")或Request.ServerVariables ("ALL_RAW")方法获取到的http请求报头
HTTP_ACCEPT:*/*
HTTP_ACCEPT_LANGUAGE:zh-cn
HTTP_CONNECTION:Keep-Alive
HTTP_HOST:192.168.1.54:81
HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
HTTP_COOKIE:ASPSESSIONIDASBBCRRQ=NDMJNFOCOEMAMJHEKDDEHKAP
HTTP_ACCEPT_ENCODING:gzip, deflate
被MSXML2.XMLHTTP采集时的http报头
HTTP_ACCEPT:*/*
HTTP_CONNECTION:Keep-Alive
HTTP_HOST:192.168.1.54:81
HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
被MSXML2.serverXMLHTTP采集时的http报头
HTTP_ACCEPT:*/*
HTTP_CONNECTION:Keep-Alive
HTTP_HOST:192.168.1.54:81
HTTP_USER_AGENT:Mozilla/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5)
这里有两个实验时候用的文件,以下是其详细信息!
AA.ASP
<%
response.write Request.ServerVariables("all_http")
%>
INDEX.ASP
<%'函数库
function getHTTPPage(url) '创建xmhhttp
dim Http
set Http=server.createobject("MSXML2.serverXMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
set http=nothing
if err.number<>0 then err.Clear
end function
Function BytesToBstr(body,Cset) '处理中文字符
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Dim Url,MovieHtml,a,a1,a2,a3,a4,a5,a6,a7,a8 '定义变量,加快系统运行速度
Url="http://192.168.1.54:81/aa.asp"
MovieHtml = getHTTPPage(Url)
response.write MovieHtml
%>
从上边两个文件可以得到最上边的数据!
如果我们在页面头部判断一下Request.ServerVariables("all_http")的内容,就能防止数据被采集。
注释:采集对象还有几个,限于篇幅,请有需要的朋友自己做一下实验
评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=1784
用Request.ServerVariables ("all_http")或Request.ServerVariables ("ALL_RAW")方法获取到的http请求报头
HTTP_ACCEPT:*/*
HTTP_ACCEPT_LANGUAGE:zh-cn
HTTP_CONNECTION:Keep-Alive
HTTP_HOST:192.168.1.54:81
HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
HTTP_COOKIE:ASPSESSIONIDASBBCRRQ=NDMJNFOCOEMAMJHEKDDEHKAP
HTTP_ACCEPT_ENCODING:gzip, deflate
被MSXML2.XMLHTTP采集时的http报头
HTTP_ACCEPT:*/*
HTTP_CONNECTION:Keep-Alive
HTTP_HOST:192.168.1.54:81
HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
被MSXML2.serverXMLHTTP采集时的http报头
HTTP_ACCEPT:*/*
HTTP_CONNECTION:Keep-Alive
HTTP_HOST:192.168.1.54:81
HTTP_USER_AGENT:Mozilla/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5)
这里有两个实验时候用的文件,以下是其详细信息!
AA.ASP
<%
response.write Request.ServerVariables("all_http")
%>
INDEX.ASP
<%'函数库
function getHTTPPage(url) '创建xmhhttp
dim Http
set Http=server.createobject("MSXML2.serverXMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
set http=nothing
if err.number<>0 then err.Clear
end function
Function BytesToBstr(body,Cset) '处理中文字符
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Dim Url,MovieHtml,a,a1,a2,a3,a4,a5,a6,a7,a8 '定义变量,加快系统运行速度
Url="http://192.168.1.54:81/aa.asp"
MovieHtml = getHTTPPage(Url)
response.write MovieHtml
%>
从上边两个文件可以得到最上边的数据!
如果我们在页面头部判断一下Request.ServerVariables("all_http")的内容,就能防止数据被采集。
注释:采集对象还有几个,限于篇幅,请有需要的朋友自己做一下实验

这篇日志没有评论。
此日志不可发表评论。