File tree Expand file tree Collapse file tree 9 files changed +79
-1
lines changed Expand file tree Collapse file tree 9 files changed +79
-1
lines changed Original file line number Diff line number Diff line change 1
1
sudo : false
2
2
language : ruby
3
3
rvm :
4
- - 2.0 .0
4
+ - 2.3 .0
5
5
before_install : gem install bundler -v 1.12.5
Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ Gem::Specification.new do |spec|
28
28
spec . require_paths = [ "lib" ]
29
29
30
30
spec . add_dependency 'http' , '~> 2.0'
31
+ spec . add_dependency 'activesupport'
32
+ spec . add_dependency 'rails' , '>= 4.2'
31
33
spec . add_development_dependency "bundler" , "~> 1.12"
32
34
spec . add_development_dependency "rake" , "~> 10.0"
33
35
spec . add_development_dependency "minitest" , "~> 5.0"
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ source 'https://rubygems.org'
3
3
# Specify your gem's dependencies in API_Fuzzer.gemspec
4
4
5
5
gem 'http'
6
+ gem 'builder'
6
7
7
8
group :development do
8
9
gem 'byebug'
Original file line number Diff line number Diff line change
1
+ class PingController < ActionController ::Base
2
+ def index
3
+ @scan = Scan . find ( params [ :id ] )
4
+ @scan . vulnerabilities . create! (
5
+ status : 'HIGH' ,
6
+ class_type : 'Vulnerability' ,
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;<' )
17
+ end
18
+ end
Original file line number Diff line number Diff line change
1
+ API_Fuzzer ::Engine . routes . draw do
2
+ get '/ping/:id' => 'ping#index'
3
+ end
Original file line number Diff line number Diff line change 5
5
require 'API_Fuzzer/sql_blind_check'
6
6
require 'API_Fuzzer/xss_check'
7
7
require 'API_Fuzzer/request'
8
+ require 'API_Fuzzer/engine'
9
+ require 'API_Fuzzer/xxe_check'
8
10
9
11
module API_Fuzzer
10
12
# Scans all the checks
@@ -16,6 +18,7 @@ def self.scan(options = {})
16
18
vulnerabilities << API_Fuzzer ::XssCheck . scan ( options )
17
19
vulnerabilities << API_Fuzzer ::SqlCheck . scan ( options )
18
20
vulnerabilities << API_Fuzzer ::SqlBlindCheck . scan ( options )
21
+ API_Fuzzer ::XxeCheck . scan ( options )
19
22
vulnerabilities . uniq . flatten
20
23
end
21
24
Original file line number Diff line number Diff line change
1
+ require 'rails'
2
+
3
+ module API_Fuzzer
4
+ class Engine < ::Rails ::Engine ; end
5
+ end
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ def send_api_request(options = {})
10
10
@params = options . delete ( :params ) || { }
11
11
@method = options . delete ( :method ) || :get
12
12
@json = options . delete ( :json ) ? true : false
13
+ @body = options . delete ( :body ) ? true : false
13
14
@request = set_cookies ( options )
14
15
send_request
15
16
end
@@ -56,6 +57,8 @@ def self.set_params
56
57
{ 'json' => @params }
57
58
elsif method_get?
58
59
{ 'params' => @params }
60
+ elsif @body
61
+ { 'body' => @params }
59
62
else
60
63
{ 'form' => @params }
61
64
end
Original file line number Diff line number Diff line change
1
+ require 'API_Fuzzer/vulnerability'
2
+ require 'API_Fuzzer/error'
3
+ require 'API_Fuzzer/request'
4
+
5
+ module API_Fuzzer
6
+ class XxeCheck
7
+
8
+ def self . scan ( options = { } )
9
+ @url = options [ :url ] || nil
10
+ @params = options [ :params ]
11
+ @scan_hash = options [ :scan ]
12
+ fuzz_xml_params
13
+ end
14
+
15
+ private
16
+
17
+ def self . fuzz_xml_params
18
+ return unless @params
19
+ body = params_serialize . gsub ( /\> \s *[a-zA-Z0-9]*\s *\< \/ / , '>&xxe;<' )
20
+ payload = <<-XXEPAYLOAD
21
+ <?xml version="1.0" encoding="ISO-8859-1"?>
22
+ <!DOCTYPE foo [
23
+ <!ELEMENT foo ANY >
24
+ <!ENTITY xxe SYSTEM "http://127.0.0.1:3000/ping/#{ @scan_hash } " >]>
25
+ XXEPAYLOAD
26
+ payload << body
27
+ API_Fuzzer ::Request . send_api_request (
28
+ url : @url ,
29
+ params : payload ,
30
+ body : true ,
31
+ method : :post
32
+ )
33
+ 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
42
+ end
43
+ end
You can’t perform that action at this time.
0 commit comments