pwn 0.5.498 → 0.5.499

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c41bc76760db0b513a3ad2e622d66299878abc0470557cf342afe18b5cee66e7
4
- data.tar.gz: 56af59b296710ca0a24819d7dcd122e8e058b65152a9e04202a53ff0e41c6473
3
+ metadata.gz: 4e56e54848ac7ff737e0c074dba6ec24cd7fcb3eb60012eadd218b41fc951302
4
+ data.tar.gz: 2d2221ff56638e8bb30b7ce9e907f390e1bc84c3c63dddccb6a34b6e83d8e920
5
5
  SHA512:
6
- metadata.gz: d1346423bc99955590ecd3eaa819b9af4bc584dee83e405557afc23e3a0819fb52a2a83952e09f72c37e648696fe58ad8abd6f20e91ef80821ff381728c160a0
7
- data.tar.gz: 91408051ad834f50b5665f9bc1bad7b1a87e83e57641e34995aa8f79eca42e8fc98e2be59e44209609e4f0ffe212b8f774ebd4100803006c194c059e9050e69d
6
+ metadata.gz: bfc2c1f2ffbf9447c7c2fa25de875d353f0ebc3a98158ea36a34459b7ae07c93aac81e98bf25657d2cde2ec640a09122724797563d24c3f57dc688246578e4fa
7
+ data.tar.gz: fbe74658bc1c81f3dd5e8da72a36edaa0ac58362ba8ee82d39089ade0e721924f49c8077afb6ae0775299fbbf03a5885ebc37ceea50fd6802885b962145ae382
data/README.md CHANGED
@@ -37,7 +37,7 @@ $ cd /opt/pwn
37
37
  $ ./install.sh
38
38
  $ ./install.sh ruby-gem
39
39
  $ pwn
40
- pwn[v0.5.498]:001 >>> PWN.help
40
+ pwn[v0.5.499]:001 >>> PWN.help
41
41
  ```
42
42
 
43
43
  [![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.4.4@pwn
52
52
  $ gem uninstall --all --executables pwn
53
53
  $ gem install --verbose pwn
54
54
  $ pwn
55
- pwn[v0.5.498]:001 >>> PWN.help
55
+ pwn[v0.5.499]:001 >>> PWN.help
56
56
  ```
57
57
 
58
58
  If you're using a multi-user install of RVM do:
@@ -62,7 +62,7 @@ $ rvm use ruby-3.4.4@pwn
62
62
  $ rvmsudo gem uninstall --all --executables pwn
63
63
  $ rvmsudo gem install --verbose pwn
64
64
  $ pwn
65
- pwn[v0.5.498]:001 >>> PWN.help
65
+ pwn[v0.5.499]:001 >>> PWN.help
66
66
  ```
67
67
 
68
68
  PWN periodically upgrades to the latest version of Ruby which is reflected in `/opt/pwn/.ruby-version`. The easiest way to upgrade to the latest version of Ruby from a previous PWN installation is to run the following script:
@@ -50,7 +50,7 @@ module PWN
50
50
  # )
51
51
  private_class_method def self.init_introspection_thread(opts = {})
52
52
  # if PWN::Env[:ai][:introspection] is true,
53
- # spin up PWN::Plugins::ThreadPool to
53
+ # spin up Thread to:
54
54
  # 1. Periodically call get_proxy_history(burp_obj: burp_obj) method
55
55
  # 2. For each entry w/ empty comment,
56
56
  # generate AI analysis via PWN::AI::Introspection.reflect_on
@@ -98,13 +98,34 @@ module PWN
98
98
  Analyze provided HTTP request/response pairs methodically: Start with a high-level overview, then dive into specifics, flag potential issues with evidence from the traffic, and end with PoC if applicable. Be verbose in reasoning but concise in output. Prioritize high-severity findings. If data is incomplete, request clarifications.
99
99
  '
100
100
 
101
+ get_highlight_color = lambda do |opts = {}|
102
+ ai_analysis = opts[:ai_analysis]
103
+
104
+ highlight_color = 'GRAY'
105
+ if ai_analysis =~ /"risk_score":\s*"(\d{1,3})%"/
106
+ score = Regexp.last_match(1).to_i
107
+ highlight_color = case score
108
+ when 0..24
109
+ 'GREEN'
110
+ when 25..49
111
+ 'YELLOW'
112
+ when 50..74
113
+ 'ORANGE'
114
+ when 75..100
115
+ 'RED'
116
+ end
117
+ end
118
+
119
+ highlight_color
120
+ end
121
+
101
122
  loop do
102
123
  # TODO: Implement sitemap and repeater into the loop.
103
124
  # Sitemap should work the same as proxy history.
104
125
  # Repeater should analyze the reqesut/response pair and suggest
105
126
  # modifications to the request to further probe for vulnerabilities.
106
- proxy_history = get_proxy_history(burp_obj: burp_obj)
107
- proxy_history.each do |entry|
127
+ sitemap = get_sitemap(burp_obj: burp_obj)
128
+ sitemap.each do |entry|
108
129
  next unless entry.key?(:comment) && entry[:comment].to_s.strip.empty?
109
130
 
110
131
  request = entry[:request]
@@ -116,7 +137,6 @@ module PWN
116
137
 
117
138
  request = Base64.strict_decode64(request)
118
139
  response = Base64.strict_decode64(response)
119
-
120
140
  http_request_response = PWN::Plugins::Char.force_utf8("#{request}\r\n\r\n#{response}")
121
141
  ai_analysis = PWN::AI::Introspection.reflect_on(
122
142
  system_role_content: system_role_content,
@@ -127,33 +147,59 @@ module PWN
127
147
  next if ai_analysis.nil? || ai_analysis.strip.empty?
128
148
 
129
149
  entry[:comment] = ai_analysis
130
- # Extract score and assign color highlight based on severity
131
- if ai_analysis =~ /"risk_score":\s*"(\d{1,3})%"/
132
- score = Regexp.last_match(1).to_i
133
- highlight_color = case score
134
- when 0..24
135
- 'GREEN'
136
- when 25..49
137
- 'YELLOW'
138
- when 50..74
139
- 'ORANGE'
140
- when 75..100
141
- 'RED'
142
- end
150
+ entry[:highlight] = get_highlight_color.call(ai_analysis: ai_analysis)
151
+
152
+ update_sitemap(
153
+ burp_obj: burp_obj,
154
+ entry: entry
155
+ )
156
+ end
157
+
158
+ proxy_history = get_proxy_history(burp_obj: burp_obj)
159
+ proxy_history.each do |entry|
160
+ next unless entry.key?(:comment) && entry[:comment].to_s.strip.empty?
161
+
162
+ request = entry[:request]
163
+ response = entry[:response]
164
+ host = entry[:http_service][:host]
165
+ port = entry[:http_service][:port]
166
+ protocol = entry[:http_service][:protocol]
167
+ next if request.nil? || response.nil? || host.nil? || port.nil? || protocol.nil?
168
+
169
+ request = Base64.strict_decode64(request)
170
+ response = Base64.strict_decode64(response)
171
+
172
+ # If sitemap comment and highlight color exists, use that instead of re-analyzing
173
+ sitemap_entry = sitemap.find do |sitemap_item|
174
+ sitemap_item[:http_service][:host] == host &&
175
+ sitemap_item[:http_service][:port] == port &&
176
+ sitemap_item[:http_service][:protocol] == protocol &&
177
+ sitemap_item[:request] == entry[:request]
143
178
  end
144
- highlight_color ||= 'GRAY'
145
- entry[:highlight] = highlight_color
146
179
 
147
- entry.delete(:request)
148
- entry.delete(:response)
149
- entry.delete(:http_service)
180
+ if sitemap_entry.nil?
181
+ http_request_response = PWN::Plugins::Char.force_utf8("#{request}\r\n\r\n#{response}")
182
+ ai_analysis = PWN::AI::Introspection.reflect_on(
183
+ system_role_content: system_role_content,
184
+ request: http_request_response,
185
+ suppress_pii_warning: true
186
+ )
187
+
188
+ next if ai_analysis.nil? || ai_analysis.strip.empty?
189
+
190
+ entry[:comment] = ai_analysis
191
+ entry[:highlight] = get_highlight_color.call(ai_analysis: ai_analysis)
192
+ else
193
+ entry[:comment] = sitemap_entry[:comment]
194
+ entry[:highlight] = sitemap_entry[:highlight]
195
+ end
150
196
 
151
197
  update_proxy_history(
152
198
  burp_obj: burp_obj,
153
199
  entry: entry
154
200
  )
155
201
  end
156
- sleep 10
202
+ sleep 3
157
203
  end
158
204
  rescue Errno::ECONNREFUSED
159
205
  puts 'Thread Terminating...'
@@ -685,7 +731,7 @@ module PWN
685
731
  end
686
732
 
687
733
  # Supported Method Parameters::
688
- # repeater_obj = PWN::Plugins::BurpSuite.update_proxy_history(
734
+ # json_proxy_history = PWN::Plugins::BurpSuite.update_proxy_history(
689
735
  # burp_obj: 'required - burp_obj returned by #start method',
690
736
  # entry: 'required - hash of the proxy history entry to update'
691
737
  # )
@@ -703,6 +749,11 @@ module PWN
703
749
  rest_browser = burp_obj[:rest_browser]
704
750
  mitm_rest_api = burp_obj[:mitm_rest_api]
705
751
 
752
+ # Only allow updating of comment and highlight fields
753
+ entry.delete(:request)
754
+ entry.delete(:response)
755
+ entry.delete(:http_service)
756
+
706
757
  put_body = entry.to_json
707
758
 
708
759
  proxy_history_resp = rest_browser.put(
@@ -951,6 +1002,40 @@ module PWN
951
1002
  raise e
952
1003
  end
953
1004
 
1005
+ # Supported Method Parameters::
1006
+ # json_sitemap = PWN::Plugins::BurpSuite.update_sitemap(
1007
+ # burp_obj: 'required - burp_obj returned by #start method',
1008
+ # entry: 'required - hash of the sitemap entry to update'
1009
+ # )
1010
+
1011
+ public_class_method def self.update_sitemap(opts = {})
1012
+ burp_obj = opts[:burp_obj]
1013
+ raise 'ERROR: burp_obj parameter is required' unless burp_obj.is_a?(Hash)
1014
+
1015
+ entry = opts[:entry]
1016
+ raise 'ERROR: entry parameter is required and must be a hash' unless entry.is_a?(Hash)
1017
+
1018
+ rest_browser = burp_obj[:rest_browser]
1019
+ mitm_rest_api = burp_obj[:mitm_rest_api]
1020
+
1021
+ # Only allow updating of comment and highlight fields
1022
+ # NOTE we need the request as its used to identify the sitemap entry to update
1023
+ entry.delete(:response)
1024
+ entry.delete(:http_service)
1025
+
1026
+ put_body = entry.to_json
1027
+
1028
+ sitemap_resp = rest_browser.put(
1029
+ "http://#{mitm_rest_api}/sitemap",
1030
+ put_body,
1031
+ content_type: 'application/json; charset=UTF8'
1032
+ )
1033
+
1034
+ JSON.parse(sitemap_resp, symbolize_names: true)
1035
+ rescue StandardError => e
1036
+ raise e
1037
+ end
1038
+
954
1039
  # Supported Method Parameters:
955
1040
  # json_sitemap = PWN::Plugins::BurpSuite.import_openapi_to_sitemap(
956
1041
  # burp_obj: 'required - burp_obj returned by #start method',
@@ -1868,6 +1953,11 @@ module PWN
1868
1953
  return_as: 'optional - :base64 or :har (defaults to :base64)'
1869
1954
  )
1870
1955
 
1956
+ json_proxy_history = #{self}.update_proxy_history(
1957
+ burp_obj: 'required - burp_obj returned by #start method',
1958
+ entry: 'required - proxy history entry hash to update'
1959
+ )
1960
+
1871
1961
  json_sitemap = #{self}.get_sitemap(
1872
1962
  burp_obj: 'required - burp_obj returned by #start method',
1873
1963
  keyword: 'optional - keyword to filter sitemap results (default: nil)',
@@ -1896,6 +1986,11 @@ module PWN
1896
1986
  }
1897
1987
  )
1898
1988
 
1989
+ json_sitemap = #{self}.update_sitemap(
1990
+ burp_obj: 'required - burp_obj returned by #start method',
1991
+ entry: 'required - sitemap entry hash to update'
1992
+ )
1993
+
1899
1994
  json_sitemap = #{self}.import_openapi_to_sitemap(
1900
1995
  burp_obj: 'required - burp_obj returned by #start method',
1901
1996
  openapi_spec: 'required - path to OpenAPI JSON or YAML specification file',
data/lib/pwn/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PWN
4
- VERSION = '0.5.498'
4
+ VERSION = '0.5.499'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.498
4
+ version: 0.5.499
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.