iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 27
2
Security

資安這條路─以自建漏洞環境學習資訊安全系列 第 27

資安這條路 27 - [伺服器軟體]Web 應用伺服器-Tomcat、Weblogic、Websphere、Jboss

Tomcat

  • 開放原始碼,支援 JSP 和 servlets 的 Web 應用伺服器

  • 切勿使用 root 執行 Tomcat

    useradd -d /tomcat -u 501 tomcat
    passwd tomcat
    su - tomcat
    
  • 關閉目錄顯示

    • DefaultServlet False
  • 修改預設 port & 版本資訊

    • vim $TOMCAT_HOME/conf/server.xml
    • 預設 8080 port
    • <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" server="App service版本資訊"/>
    • 修改 port 儲存後重起伺服器
  • Tomcat 預設範例 /examples/servlets/servlet/SessionExample

    • 若寫入與管理員對應的 Session 有機會進入管理頁面
  • log

    • 將註解取消
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
    
  • CVE-2020-1938:Tomcat Ghostcat

    • 高危險漏洞
    • 影響:Tomcat 9/8/7/6 全版本
    • 可讀取 webapp 底下所有檔案
    • 開啟 AJP Connector 8009 port (使用 Apache Jserv Protocol)
  • 參考網址

Weblogic

  • Oracle 公司開發的 Web 應用伺服器

  • 基於 Java EE 架構

  • 用於開發、部署 Java 的應用程式

  • 啟動 Weblogic 權限

    • 使用帳號 weblogic
    • chown -R weblogic:weblogic "Weblogic資料夾"
    • Log 權限也要改成 weblogic
  • 修改預設 port

    • config/config.xml
    • 找到 AdminServer
    • <listen-port>7005</listen-port>
    • 修改 listen-port
  • 目錄列表

    • weblogic.xml
    • <index-directory-enabled>
    • 預設 false 不開啟目錄列表
  • 敏感路徑

    • config/config.xml
      • 網站路徑
      • 登入帳號密碼
      • port 設定
  • Weblogic SSRF

    • CVE-2014-4210
    • 影響版本 weblogic 10.0.2 – 10.3.6
    • 伺服器提供讓其他網站可以讀取資料的功能,但是沒有過濾導致 SSRF
    • https://github.com/vulhub/vulhub/tree/master/weblogic/ssrf
    • docker-compose up -d
    • 請求 http://漏洞ip:7001/uddiexplorer/
      • 不需要登入可以看到 uddiexplorer 內容
    • 弱點路徑:http://漏洞ip:7001/uddiexplorer/SearchPublicRegistries.jsp
    • POC:/uddiexplorer/SearchPublicRegistries.jsp?rdoSearch=name&txtSearchname=sdf&txtSearchkey=&txtSearchfor=&selfor=Business+location&btnSubmit=Search&operator=http://127.0.0.1:7001
  • Weblogic 反序列化

    • CVE-2019-2725
      • 影響版本 webLogic 10.3.6.0.0、12.1.3
      • 影響元件:bea_wls9_async_response.war、wsat.war
    • CVE-2019-2729
      • 影響版本 webLogic 10.3.6.0.0、12.1.3.0.0、12.2.1.3.0
  • log

    • access log
      • 版本 9 \user_projects\domains\<domain_name>\servers\<server_name>\logs\access.log
      • 版本 8 \user_projects\domains\<domain_name>\<server_name>\access.log
    • server log
      • 版本 9 \user_projects\domains\<domain_name>\servers\<server_name>\logs\<server_name>.log
      • 版本 8 \user_projects\domains\<domain_name>\<server_name>\<server_name>.log
    • domain log
      • 版本 9 \user_projects\domains\<domain_name>\servers\<adminserver_name>\logs\<domain_name>.log
      • 版本 8 \user_projects\domains\<domain_name>\<domain_name>.log
  • 參考網址

Websphere

  • IBM 開發的 Web 應用伺服器
  • 設定檔
    • Windows was_install_dir\bin\manageprofiles.bat –listProfiles
    • Linux was_install_dir/bin/manageprofiles.sh –listProfiles
  • 漏洞
    • CVE-2020-4448
      • WebSphere Application Server ND 8.5/9.0,WebSphere Virtual Enterprise 7.0/8.0
      • BroadcastMessageManager 元件對使用者傳入的資料參數未做過濾,導致惡意資料進行反序列化漏洞,可造成以管理員身分執行任意指令
    • CVE-2020-4449
      • WebSphere Application Server 7.0/8.0/8.5/9.0
      • IIOP 協定未驗證完全,導致可反序列化,洩漏敏感資訊
    • CVE-2020-4450
      • WebSphere Application Server 8.5/9.0
      • IIOP 協定未驗證完全,導致可反序列化,利用 root 權限執行指令
  • log
    • http://localhost:9060/ibm/console
      • 以下圖片來源:https://www.ibm.com/support/pages/how-view-logging-information-inside-websphere-application-server
      • Servers
      • Server Types
      • Websphere application server
      • Troubleshooting
      • Logging and tracing
      • General Propertie
      • JVM Logs
      • JVM Logs
      • Runtime
      • Log 路徑
  • 參考文章

Jboss

  • 開源的 Web 應用伺服器
    • 基於 J2EE
    • 核心不支援 servlet/JSP
  • jmx-console 安全性
    • 參考來源
    • /jboss/server/default/deploy/jmx-console.war/WEB-INF/jboss-web.xml
      • 取消註解<security-domain>java:/jaas/jmx-console</security-domain>
    • /jboss/server/default/deploy/jmx-console.war/WEB-INF/web.xml
      • 取消註解
      <security-constraint>
      <web-resource-collection>
      <web-resource-name>HtmlAdaptor</web-resource-name>
      <description>An example security config that only allows users with the
      role JBossAdmin to access the HTML JMX console web application
      </description>
      <url-pattern>/*</url-pattern>
      <http-method>GET</http-method>
      <http-method>POST</http-method>
      </web-resource-collection>
      <auth-constraint>
      <role-name>JBossAdmin</role-name>
      </auth-constraint>
      </security-constraint>
      
    • /jboss/server/default/conf/props/jmx-console-users.properties
      • 編輯 admin 帳號密碼
  • web-console 安全性
    • /jboss/server/default/deploy/management/console-mgr.sar/web-console.war/WEB-INF/jboss-web.xml
      • 取消註解
      • <security-domain>java:/jaas/web-console</security-domain>
    • /jboss/server/defualt/deploy/management/console-mgr.sar/web-console.war/WEB-INF/web.xml
      • 取消註解
      <security-constraint>
      <web-resource-collection>
      <web-resource-name>HtmlAdaptor</web-resource-name>
      <description>An example security config that only allows users with the
      role JBossAdmin to access the HTML JMX console web application
      </description>
      <url-pattern>/*</url-pattern>
      <http-method>GET</http-method>
      <http-method>POST</http-method>
      </web-resource-collection>
      <auth-constraint>
      <role-name>JBossAdmin</role-name>
      </auth-constraint>
      </security-constraint>
      
    • /jboss/server/default/deploy/management/console-mgr.sar/web-console.war/WEB-INF/classes/web-console-users.properties
      • 編輯 admin 帳號密碼
  • 漏洞
    • JBosSAS 5.x,6.X 反序列化漏洞(CVE-2017-12149)
      • 影響版本:JbossAS 5.x , JbossAS 6.x
  • 參考文章

上一篇
資安這條路 26- [Web 伺服器軟體] IIS (Internet Information Services)
下一篇
資安這條路 28 - [作業系統] Windows、Linux
系列文
資安這條路─以自建漏洞環境學習資訊安全31
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言