|
1 | 1 | # frozen_string_literal: true
|
2 | 2 |
|
3 |
| -require 'socket' |
4 | 3 | require 'base64'
|
| 4 | +require 'json' |
| 5 | +require 'socket' |
| 6 | +require 'uri' |
5 | 7 |
|
6 | 8 | module PWN
|
7 | 9 | module Plugins
|
@@ -76,6 +78,45 @@ module BurpSuite
|
76 | 78 | raise e
|
77 | 79 | end
|
78 | 80 |
|
| 81 | + # Supported Method Parameters:: |
| 82 | + # uri_in_scope_bool = PWN::Plugins::BurpSuite.uri_in_scope( |
| 83 | + # target_config: 'required - path to burp suite pro target config JSON file', |
| 84 | + # uri: 'required - URI to determine if in scope' |
| 85 | + # ) |
| 86 | + |
| 87 | + public_class_method def self.uri_in_scope(opts = {}) |
| 88 | + target_config = opts[:target_config] |
| 89 | + raise 'ERROR: target_config does not exist' unless File.exist?(target_config) |
| 90 | + |
| 91 | + uri = opts[:uri] |
| 92 | + raise 'ERROR: uri parameter is required' if uri.nil? |
| 93 | + |
| 94 | + target_config_json = JSON.parse( |
| 95 | + File.read(target_config), |
| 96 | + symbolize_names: true |
| 97 | + ) |
| 98 | + |
| 99 | + out_of_scope = target_config_json[:target][:scope][:exclude] |
| 100 | + out_of_scope_arr = out_of_scope.select do |os| |
| 101 | + URI.parse(uri).scheme =~ /#{os[:protocol]}/ && |
| 102 | + URI.parse(uri).host =~ /#{os[:host]}/ && |
| 103 | + URI.parse(uri).path =~ /#{os[:file]}/ |
| 104 | + end |
| 105 | + return false unless out_of_scope_arr.empty? |
| 106 | + |
| 107 | + in_scope = target_config_json[:target][:scope][:include] |
| 108 | + in_scope_arr = in_scope.select do |is| |
| 109 | + URI.parse(uri).scheme =~ /#{is[:protocol]}/ && |
| 110 | + URI.parse(uri).host =~ /#{is[:host]}/ && |
| 111 | + URI.parse(uri).path =~ /#{is[:file]}/ |
| 112 | + end |
| 113 | + return false if in_scope_arr.empty? |
| 114 | + |
| 115 | + true |
| 116 | + rescue StandardError => e |
| 117 | + raise e |
| 118 | + end |
| 119 | + |
79 | 120 | # Supported Method Parameters::
|
80 | 121 | # PWN::Plugins::BurpSuite.enable_proxy(
|
81 | 122 | # burp_obj: 'required - burp_obj returned by #start method'
|
@@ -311,6 +352,12 @@ module BurpSuite
|
311 | 352 | burp_jar_path: 'required - path of burp suite pro jar file',
|
312 | 353 | headless: 'optional - run headless if set to true',
|
313 | 354 | browser_type: 'optional - defaults to :firefox. See PWN::Plugins::TransparentBrowser.help for a list of types',
|
| 355 | + target_config: 'optional - path to burp suite pro target config JSON file' |
| 356 | + ) |
| 357 | +
|
| 358 | + uri_in_scope_bool = #{self}.uri_in_scope( |
| 359 | + target_config: 'required - path to burp suite pro target config JSON file', |
| 360 | + uri: 'required - URI to determine if in scope' |
314 | 361 | )
|
315 | 362 |
|
316 | 363 | #{self}.enable_proxy(
|
|
0 commit comments