asp实现的查询某关键词在MSSQL数据库位置的代码

来源:asp之家 时间:2011-02-28 11:18:00 

功能是:以一个关键字为索引,搜索整个数据库,然后返回那个关键字所在的表名和列名。(很赞...特别是入侵的时候找不到用户名与密码所在的表的时候,如果能直接通过输入admin这个关键词找出字段...省得一个表一个表的看了。)于是根据那段语句,写了个asp的脚本,方便大家以后搜寻数据库。

代码如下:

代码如下:


<%
'Confirm a keyword's position of a database(which table & which column)
'By oldjun(http://www.oldjun.com)
'Based on huangzi(http://www.2chuizi.com)'s sql
Server.ScriptTimeout=999999999
Response.Buffer =true
On Error Resume Next
keyword=request("keyword")
if keyword="" then
response.write "Need keyword!"
response.End
End if
dim conn
Set conn = Server.CreateObject("ADODB.Connection")
Dim ConnStr
'ConnectionString,Pls change!
ConnStr="Driver={SQL SERVER};Server=localhost;UID=sa;PWD=sa;Database=master"
Conn.open ConnStr
conn.execute("CREATE TABLE huangzi_table(id int identity(1,1),biaoid int,biaoname nvarchar(1000))")
conn.execute("insert huangzi_table select [id],[name] from sysobjects where xtype='U'")
set rs =conn.execute("select count(id) as tnum from huangzi_table")
tnum=rs("tnum")
rs.close
set rs=nothing
for i=1 to tnum
set rsbiao =conn.execute("select biaoid from huangzi_table where id="&i&"")
biaoid=rsbiao("biaoid")
set rst =conn.execute("select [biaoname] from huangzi_table where biaoid="&biaoid&"")
tname=rst("biaoname")
set rsl=conn.execute("select count([name]) as lnum from syscolumns where id="&biaoid&"")
lnum=rsl("lnum")
for j=1 to lnum
topnum=j-1
set rslie=conn.execute("select top 1 [name] from syscolumns where id="&biaoid&" and [name] not in
(select top "&topnum&" [name] from syscolumns where id="&biaoid&")")
liename=rslie("name")
set rsresult=conn.execute("select top 1 ["&liename&"] from ["&tname&"] where CAST(["&liename&"] AS NVARCHAR(1000))='"&keyword&"'")
if rsresult.bof or rsresult.eof then
'response.write "Nothing-"&tname&":"&liename
'response.write "<br>"
else
result=rsresult(liename)
response.write result&"("&tname&":"&liename&")"
response.write "<br>"
End if
rslie.close
set rslie=nothing
rsresult.close
set rsresult=nothing
next
rsbiao.close
set rsbiao=nothing
rst.close
set rst=nothing
rsl.close
set rsl=nothing
next
conn.execute("DROP TABLE huangzi_table")
%>


注:效率很差,使用时可能出现假死, 请耐心等待,大库还是别用了;代码简单,实现的简单功能,没技术含量,留着以后备用;换连接语句的时候有个缓存问题,建议重启下浏览器!

标签:关键词,MSSQL,数据库位置
0
投稿

猜你喜欢

  • Python图片检索之以图搜图

    2021-08-11 12:08:23
  • mysql性能的检查和调优方法

    2009-05-17 09:21:00
  • 在Python 3中实现类型检查器的简单方法

    2022-08-13 13:30:30
  • JS数组遍历中for,for in,for of,map,forEach各自的使用方法与优缺点

    2024-05-02 16:15:45
  • python包相关知识点之包的导入、相对路径以及绝对路径

    2023-08-11 11:09:46
  • Python使用dict.fromkeys()快速生成一个字典示例

    2022-05-10 08:13:23
  • Python关于__name__属性的含义和作用详解

    2021-10-28 09:29:51
  • Mysql的DQL查询操作全面分析讲解

    2024-01-18 02:07:27
  • Python3.4学习笔记之类型判断,异常处理,终止程序操作小结

    2022-06-03 10:45:54
  • Pycharm配置远程调试的方法步骤

    2021-03-13 00:45:38
  • python顺序的读取文件夹下名称有序的文件方法

    2021-03-10 08:23:37
  • 不要跳转或刷新 实现网页区域选择显示

    2010-07-02 16:25:00
  • centos7之Python3.74安装教程

    2023-10-27 15:15:24
  • Python IDE Pycharm中的快捷键列表用法

    2022-12-12 19:21:12
  • Highcharts+NodeJS搭建数据可视化平台示例

    2024-05-02 17:38:38
  • pip安装Python库时遇到的问题及解决方法

    2023-06-20 14:00:01
  • JS前端加密算法示例

    2024-04-22 22:18:28
  • 使用python爬取taptap网站游戏截图的步骤

    2021-09-17 07:44:34
  • 程序员开发项目是选择效率还是质量呢?

    2023-09-17 08:37:03
  • python os.listdir()乱码解决方案

    2021-09-20 02:52:42
  • asp之家 网络编程 m.aspxhome.com