用ASP做的DNS LOOKUP程序
2018-09-06 12:05
运行环境,NT(SERVER、WORKSTATION)、W2K
服务器上需要安装WSH2.0或者更高版本
如果您的系统目前没有安装WSH2.0,您可以从以下这个地址去下载它
里面包含了WSH2.0
下面是源代码
<%@Language=VBScript%>
<%OptionExplicit%>
<%
IfRequest.Form(frmHost)=Then
设置初始值
strIP=Request.ServerVariables(REMOTE_ADDR)
Else
strIP=Request.Form(frmHost)
EndIf
%>
<html>
<head>
<title>DNSLookup[v1.0]</title>
</head>
<bodybgcolor=#FFFFFF>
<formMethod=POSTName=frmRDNS>
<labelfor=frmHost><u>Host:</u></label>
<inputtype=textname=frmHostID=frmHost
value=<%=strIP%>>
<inputtype=buttonname=btnSubmitID=btnSubmit
value=LookuponClick=document.frmRDNS.submit()>
</form>
<fontface=arialsize=2color=#003366>
<%
rMethod=uCase(Request.ServerVariables(REQUEST_METHOD))
IfrMethod=POSTThen
LookupHost
strReturn=nsLookup(strIP)
IfstrReturn<>Then
Response.WritestrReturn
Else
ALameHostisanyValidHostthatDNSCannotResolve
SeeInterNicforDetails
Response.Write<b>LameHost-CouldNotResolveDNSFor_
&strIP&</b><br>
EndIf
EndIf
FunctionNSlookup(strHost)
CreateShellObject
SetoShell=Server.CreateObject(Wscript.Shell)
RunNSLookupviaCommandPrompt
DumpResultsintoatemptextfile
oShell.Run%ComSpec%/cnslookup&strHost_
&>C:\&strHost&.txt,0,True
OpenthetempTextFileandReadouttheData
SetoFS=Server.CreateObject(Scripting.FileSystemObject)
SetoTF=oFS.OpenTextFile(C:\&strHost&.txt)
tempData=Null
Data=Null
i=0
DoWhileNotoTF.AtEndOfStream
Data=Trim(oTF.Readline)
Ifi>2ThenDontwanttodisplaylocalDNSInfo.
tempData=tempData&Data&<BR>
EndIf
i=(i+1)
Loop
Closeit
oTF.Close
DeleteIt
oFS.DeleteFileC:\&strHost&.txt
SetoFS=Nothing
nsLookup=tempData
EndFunction
%>
</font>
</body>
</html>
代码很简单,我不多说了,如果您对WSH有什么疑问的话,请去下载WSH的电子文档中文版本的,CHINAASP下载区就有的吧
希望能对你有所帮助。