源码网,源码论坛,源码之家,商业源码,游戏源码下载,discuz插件,棋牌源码下载,精品源码论坛

 找回密码
 立即注册
楼主: ttx9n

[ASP编程] asp实现的查询某关键词在MSSQL数据库位置的代码

[复制链接]

7万

主题

861

回帖

32万

积分

论坛元老

Rank: 8Rank: 8

积分
329525
发表于 2010-4-22 21:57:20 | 显示全部楼层 |阅读模式
整体而言,这段SQL只适宜用在小型数据库上,ASP中的循环也没效率,大库还是别用了,小库可以考虑。如果是大库的话,请联系皇子要另外一份牛人写的SQL查询语句。 功能是:以一个关键字为索引,搜索整个数据库,然后返回那个关键字所在的表名和列名。(很赞...特别是入侵的时候找不到用户名与密码所在的表的时候,如果能直接通过输入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")
%>

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

使用道具 举报

0

主题

1万

回帖

55

积分

注册会员

Rank: 2

积分
55
发表于 2022-8-8 17:32:58 | 显示全部楼层
论坛有你更精彩!
回复 支持 反对

使用道具 举报

1

主题

1万

回帖

55

积分

注册会员

Rank: 2

积分
55
发表于 2022-8-15 13:53:25 | 显示全部楼层
呵呵呵呵呵呵
回复 支持 反对

使用道具 举报

1

主题

1万

回帖

176

积分

注册会员

Rank: 2

积分
176
发表于 2022-9-21 02:49:50 | 显示全部楼层
sdsadsadsadf
回复 支持 反对

使用道具 举报

1

主题

1万

回帖

319

积分

中级会员

Rank: 3Rank: 3

积分
319
发表于 2023-2-13 01:40:25 | 显示全部楼层
逛逛看看瞧瞧
回复 支持 反对

使用道具 举报

3

主题

1万

回帖

156

积分

注册会员

Rank: 2

积分
156
发表于 2023-6-25 01:22:32 | 显示全部楼层
建军节建军节建军节建军节
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2023-9-17 02:59:55 | 显示全部楼层
看看看看
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

66

积分

注册会员

Rank: 2

积分
66
发表于 2024-5-5 15:44:06 | 显示全部楼层
谢谢楼主分享
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

66

积分

注册会员

Rank: 2

积分
66
发表于 2024-5-6 07:42:02 | 显示全部楼层
数据库了多久撒快乐的健身卡啦
回复 支持 反对

使用道具 举报

3

主题

1万

回帖

50

积分

注册会员

Rank: 2

积分
50
发表于 2024-5-7 18:21:07 | 显示全部楼层
我要金豆金豆金豆
回复 支持 反对

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

手机版|小黑屋|网站地图|源码论坛 ( 海外版 )

GMT+8, 2024-5-20 10:58 , Processed in 0.077035 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表