新做了个asp的数据库修复工具

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>修复sql2000数据库的ntext字段</title>
</head>

<body><%
txt= percoletionword (request.Form("txt"))
zd= percoletionword (request.Form("zd"))
bm= percoletionword (request.Form("bm"))
sy= percoletionword (request.Form("sy"))
function percoletionword (word)
percoletionword=replace(word,"<","&lt;")
percoletionword=replace(percoletionword,">","&gt;")
end function %>
<form action="#" method="post"><input name="bm" type="text" value="表名" />
<input name="zd" type="text" value="字段名" />
<input name="sy" type="text" value="索引" /><input name="txt" type="text" value="要过滤的字段" />
<input name="" type="submit" value="提交" /></form>
declare @ptr varbinary(16)<br />
declare @artId int<br />
declare @Position int,@len int<br />
set @len = datalength('')<br />
declare wux_Cursor scroll Cursor<br />
for<br />
select textptr(<%=zd%>),<%=sy%> from <%=bm%><br />
for read only<br />
open wux_Cursor<br />
fetch next from wux_Cursor into @ptr,@artId<br />
while @@fetch_status=0<br />
begin<br />
select @Position=patindex('<%=txt%>',<%=zd%>) from <%=bm%> where <%=sy%>=@artId<br />
while @Position&gt;0<br />
begin<br />
set @Position=@Position-1<br />
updatetext <%=bm%>.<%=zd%> @ptr @Position @len ''<br />
select @Position=patindex('<%=txt%>',<%=zd%>) from <%=bm%> where <%=sy%>=@artId<br />
end<br />
fetch next from wux_Cursor into @ptr,@artId<br />
end<br />
close wux_cursor<br />
deallocate wux_cursor<br />
go
</body>
</html>

 

将文件保存为sql1.asp 运行之,填写好字段名和要过滤的字符串。即刻生成sql代码。粘贴到查询分析器中执行即可。

此工具用于过滤被注入代码后的sql2000型数据库。。谁都会写的东西就是没有人写的东西。。。。。

对于非ntext型字段。则有如下工具

 

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
'数据库连接
connstr="Provider=SQLOLEDB.1;User ID=sa;Password=101010;Persist Security Info=True;Initial Catalog=test;Data Source=(local)"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>数据库替换</title>
</head>
<%
if request.Form("string")<>"" then
xx= percoletionword (request.Form("string"))

function percoletionword (word)
percoletionword=replace(word,"<","&lt;")
percoletionword=replace(percoletionword,">","&gt;")
end function
SQL = "select * from sysobjects where type = 'U'"
set rs=conn.execute(sql)
do while not rs.eof
%>

<%
SQL = "select * from syscolumns where id=object_id('"&rs("name")&"')"
'SQL = "select name from syscolumns where id=object_id('"&rs("name")&"')"
set rs1=conn.execute(sql)
do while not rs1.eof
if InStr(rs1("name"),"id") or InStr(rs1("name"),"time") then
else%>
<% n=n+1%>
<div style="width:1000px; height:22px; >
Update <%=rs("name")%> SET <%=rs1("name")%> = REPLACE(<%=rs1("name")%>,'<% = xx%>','')---<% =n/2%><br></div>

<%
end if
rs1.movenext
loop
   rs1.close
 Set rs1 = Nothing
rs.movenext
loop
   rs.close
 Set rs = Nothing
end if
%>
<body>
<form action="#" method="post"><input name="string" type="text"  value="要过滤的字段"/>
<input name="" type="submit" value="提交" /></form>
</body>
</html>

引用通告: 我要引用此文章
Tags: 代码  
相关日志:
  • 下拉列表时创建文本框或其他  (2008-2-3 22:39:42)
  • RSA算法原理与数据模型  (2007-6-8 10:48:15)
  • asp怎样实现前台实时监控用户操作.流式日志?  (2007-1-22 9:38:36)
  • 关于DOS延时处理命令  (2007-1-10 9:58:18)
  • 关闭/开启本地连接的vbs代码  (2006-9-7 9:28:27)
  • 宽屏壁纸收集  (2006-7-16 19:12:50)
  • 按键妖怪  (2006-4-14 13:5:19)
  • 流氓软件清除器  (2006-3-13 15:7:14)
  • 申请了vpp 号码是185841174  (2006-3-2 22:45:39)
  • 增强型 cmd 命令行.支持列表  (2006-2-10 14:30:44)
  • 评论: 3 | 引用: 0 | 查看次数:
    回复 w2 [2008-8-26 22:40:08 [Report Spam] ]
    哦 - -
    回复 紫冰 [2009-4-2 22:51:22 [Report Spam] ]
    前辈,我想问一下,索引,是指什么部分
    回复 紫冰 [2009-4-3 18:53:44 [Report Spam] ]
    期待回复
    ts 于 2009-4-4 0:17:51 回复
    索引 就是数据库中常用的,唯一顺序数。保证数据不重复的那个项,通常我们用id字段。
    发表评论
    昵 称:
    邮 箱:
    主 页:
    内 容: