用正則和xmlHttp實現的asp小偷程序
2024-05-04 11:01:54
供稿:網友
復制代碼 代碼如下:
<%
'========================================
class EngineerSearch
'老龍:laolong9999@sina.com
':模擬XML獲取http標記資源(用過之后就知道為什么XML有用:))
'利用引擎搜索(顯示引擎信息或其超連接網站上的信息或直接一個指定頁面的相關信息,利用正則和xmlHttp,
'程序的使用需要會構造正則)
'---------------------------------------------------------------
private oReg,oxmlHttp'一個正則,一個微軟xmlhttp
'---------------------------------------------------------------
public sub class_initialize()'對象建立觸發
set oReg=new regExp
oReg.Global=true
oReg.IgnoreCase=true
set oXmlHttp=server.createobject("Microsoft.XmlHttp")
end sub
'---------------------------------------------------------------
public sub class_terminate()'對象銷毀觸發
set oReg=nothing'必須手動釋放class內的自建對象,asp只自動釋放由class定義的對象
set oXmlHttp=nothing
If typename(tempReg)<>"nothing" then'方法體內的對象釋放資源
set tempReg=nothing
end if
end sub
'---------------------------------------------------------------
'引擎級搜索
public function engineer(url,EngineerReg)
'功能介紹:獲得url的返回信息(通常用于引擎查找),提取其中的EngineerReg的特定信息,返回matches集合到
'函數名。獲得url查詢結果,搜尋出用engineerReg正則定義的結果,生成一個matches集合,
'由于無法建立集合及操作集合個數(vbscript),最好再自己遍歷集合,也可以考慮二維數組
dim strConent
strContent=oXmlHttp.open("get",url,false)
on error resume next
oXmlHttp.send()
if err.number<>0 then
exit function
end if
strContent=bytes2BSTR(oXmlHttp.responseBody)
if isnull(EngineerReg) then
engineer=AbsoluteURL(strContent,url)
else
oReg.Pattern=EngineerReg
set engineer=oReg.Execute(AbsoluteURL(strContent,url))
end if
end function
'---------------------------------------------------------------
'漢字編碼,(網人)
public Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))