源码网,源码论坛,源码之家,商业源码,游戏源码下载,discuz插件,棋牌源码下载,精品源码论坛

 找回密码
 立即注册
查看: 490|回复: 8

[ASP编程] 用正则和xmlHttp实现的asp小偷程序

[复制链接]

7万

主题

861

回帖

32万

积分

论坛元老

Rank: 8Rank: 8

积分
329525
发表于 2007-3-5 00:00:00 | 显示全部楼层 |阅读模式
复制代码 代码如下:
<% 
'======================================== 
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))  
strReturn = strReturn & Chr (CLng(ThisCharCode) * &H100 + CInt(NextCharCode))  
i = i + 1  
End If  
Next  
bytes2BSTR = strReturn  
End Function 
'--------------------------------------------------------------- 
public Function SearchReplace(strContent,ReplaceReg,ResultReg) 
'替换,将strContent中的replaceReg描述的字符串用resultReg描述的替换,返回到searchReplace去 
'将正则的replace封装了。 
oReg.Pattern=ReplaceReg 
SearchReplace=oReg.replace(strContent,ResultReg) 
End Function 
'--------------------------------------------------------------- 
public Function AbsoluteURL(strContent,byval url) 
'将strContent中的相对URL变成oXmlHttp中指定的url的绝对地址(http/https/ftp/mailto:) 
'正则可以修改修改。 
dim tempReg 
set tempReg=new RegExp 
tempReg.IgnoreCase=true 
tempReg.Global=true 
tempReg.Pattern="(^.*\/).*$"'含文件名的标准路径http://www.wrclub.net/default.aspx 
Url=tempReg.replace(url,"$1") 
tempReg.Pattern="((?:src|href).*?=[\'\u0022](?!ftp|http|https|mailto))" 
AbsoluteURL=tempReg.replace(strContent,"$1"+Url) 
set tempReg=nothing 
end Function 
'--------------------------------------------------------------- 
end class 
'======================================== 
%> 
<%'例子 
Response.CharSet = "GB2312"  
dim mySearch  
set mySearch=new EngineerSearch 
'URL一定是包含文件扩展名的完整地址,结果是集合,集合中的每个项目是数组,应该这样引用子查询:myMatches(0).subMatches(0) 
set myMatches=mySearch.engineer("http://www.wrclub.net/default.aspx","<img.*?>") 
if myMatches.count=0 Then 
response.write "没有你正则的字符串" 
end if 
if myMatches.count>0 then 
response.write myMatches.count&"<br>" 
for each key in myMatches 
response.write key.firstindex&":"&cstr(key.value)&"<br>" 
next 
end if 
%> 

更诸多的应用,只要你会正则
回复

使用道具 举报

0

主题

1万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2022-8-12 18:27:46 | 显示全部楼层
女生看了弄丢了卡萨诺的卡洛斯
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2022-8-20 03:07:50 | 显示全部楼层
天天源码论坛
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2023-1-1 19:33:50 | 显示全部楼层
谢谢分享,先下来用用
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2023-11-13 06:36:25 | 显示全部楼层
还可以不错
回复 支持 反对

使用道具 举报

3

主题

1万

回帖

294

积分

中级会员

Rank: 3Rank: 3

积分
294
发表于 2024-3-22 12:27:05 | 显示全部楼层
66666666666
回复 支持 反对

使用道具 举报

27

主题

1万

回帖

331

积分

中级会员

Rank: 3Rank: 3

积分
331
发表于 2024-4-30 05:52:08 | 显示全部楼层
的谁vdvdsvdsvdsdsv
回复 支持 反对

使用道具 举报

6

主题

1万

回帖

425

积分

中级会员

Rank: 3Rank: 3

积分
425
发表于 2024-5-8 10:58:11 | 显示全部楼层
抽根烟,下来看看再说
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2024-5-13 07:39:07 | 显示全部楼层
儿飞飞微风DVD谁vdsvd
回复 支持 反对

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

手机版|小黑屋|网站地图|源码论坛 ( 海外版 )

GMT+8, 2024-9-21 01:46 , Processed in 0.077741 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表