当前位置:首页 > ASP教程 > ASP其他

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

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

代码如下:
代码如下:
<BR /><% <BR />'Confirm a keyword's position of a database(which table & which column) <BR />'By oldjun(http://www.51frw.cn) <BR />'Based on huangzi(http://www.51frw.cn)'s sql <BR />Server.ScriptTimeout=999999999 <BR />Response.Buffer =true <BR />On Error Resume Next <BR />keyword=request("keyword") <BR />if keyword="" then <BR />response.write "Need keyword!" <BR />response.End <BR />End if <BR />dim conn <BR />Set conn = Server.CreateObject("ADODB.Connection") <BR />Dim ConnStr <BR />'ConnectionString,Pls change! <BR />ConnStr="Driver={SQL SERVER};Server=localhost;UID=sa;PWD=sa;Database=master" <BR />Conn.open ConnStr <BR />conn.execute("CREATE TABLE huangzi_table(id int identity(1,1),biaoid int,biaoname nvarchar(1000))") <BR />conn.execute("insert huangzi_table select [id],[name] from sysobjects where xtype='U'") <BR />set rs =conn.execute("select count(id) as tnum from huangzi_table") <BR />tnum=rs("tnum") <BR />rs.close <BR />set rs=nothing <BR />for i=1 to tnum <BR />set rsbiao =conn.execute("select biaoid from huangzi_table where id="&i&"") <BR />biaoid=rsbiao("biaoid") <BR />set rst =conn.execute("select [biaoname] from huangzi_table where biaoid="&biaoid&"") <BR />tname=rst("biaoname") <BR />set rsl=conn.execute("select count([name]) as lnum from syscolumns where id="&biaoid&"") <BR />lnum=rsl("lnum") <BR />for j=1 to lnum <BR />topnum=j-1 <BR />set rslie=conn.execute("select top 1 [name] from syscolumns where id="&biaoid&" and [name] not in <BR />(select top "&topnum&" [name] from syscolumns where id="&biaoid&")") <BR />liename=rslie("name") <BR />set rsresult=conn.execute("select top 1 ["&liename&"] from ["&tname&"] where CAST(["&liename&"] AS NVARCHAR(1000))='"&keyword&"'") <BR />if rsresult.bof or rsresult.eof then <BR />'response.write "Nothing-"&tname&":"&liename <BR />'response.write "<br>" <BR />else <BR />result=rsresult(liename) <BR />response.write result&"("&tname&":"&liename&")" <BR />response.write "<br>" <BR />End if <BR />rslie.close <BR />set rslie=nothing <BR />rsresult.close <BR />set rsresult=nothing <BR />next <BR />rsbiao.close <BR />set rsbiao=nothing <BR />rst.close <BR />set rst=nothing <BR />rsl.close <BR />set rsl=nothing <BR />next <BR />conn.execute("DROP TABLE huangzi_table") <BR />%> <BR /> <BR />注:效率很差,使用时可能出现假死, 请耐心等待,大库还是别用了;代码简单,实现的简单功能,没技术含量,留着以后备用;换连接语句的时候有个缓存问题,建议重启下浏览器!
            
            


           
                
                                                

【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!