Skip to content

Commit 0d656a0

Browse files
authored
Merge pull request 0dayInc#409 from ninp0/master
PWN::Plugins::BurpSuite module - add #uri_in_scope method to compare …
2 parents 9ccd3b5 + ea19e4d commit 0d656a0

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $ rvm use ruby-3.2.2@pwn
3737
$ rvm list gemsets
3838
$ gem install --verbose pwn
3939
$ pwn
40-
pwn[v0.4.863]:001 >>> PWN.help
40+
pwn[v0.4.864]:001 >>> PWN.help
4141
```
4242

4343
[![Installing the pwn Security Automation Framework](https://raw.githubusercontent.com/0dayInc/pwn/master/documentation/pwn_install.png)](https://youtu.be/G7iLUY4FzsI)
@@ -52,7 +52,7 @@ $ rvm use ruby-3.2.2@pwn
5252
$ gem uninstall --all --executables pwn
5353
$ gem install --verbose pwn
5454
$ pwn
55-
pwn[v0.4.863]:001 >>> PWN.help
55+
pwn[v0.4.864]:001 >>> PWN.help
5656
```
5757

5858

lib/pwn/plugins/burp_suite.rb

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# frozen_string_literal: true
22

3-
require 'socket'
43
require 'base64'
4+
require 'json'
5+
require 'socket'
6+
require 'uri'
57

68
module PWN
79
module Plugins
@@ -76,6 +78,45 @@ module BurpSuite
7678
raise e
7779
end
7880

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+
79120
# Supported Method Parameters::
80121
# PWN::Plugins::BurpSuite.enable_proxy(
81122
# burp_obj: 'required - burp_obj returned by #start method'
@@ -311,6 +352,12 @@ module BurpSuite
311352
burp_jar_path: 'required - path of burp suite pro jar file',
312353
headless: 'optional - run headless if set to true',
313354
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'
314361
)
315362
316363
#{self}.enable_proxy(

lib/pwn/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module PWN
4-
VERSION = '0.4.863'
4+
VERSION = '0.4.864'
55
end

0 commit comments

Comments
 (0)