pwn 0.4.642 → 0.4.644
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/README.md +2 -2
- data/bin/pwn_chat +31 -27
- data/lib/pwn/plugins/open_ai.rb +41 -2
- data/lib/pwn/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b544a8cd980d315cdcedf61ecb3f684ec6251155018073cfa73f4fe99fda103
|
4
|
+
data.tar.gz: 15cb2f4de0b6247e0aee5fafdcd891612f53c6cee748a715f7de41acd655b2d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39f3b397df4238587b9e887e6cee439e25242d1437500f3d8c1a935ae177f5a276a975063515abf7bae4161a228f7a0fb8888b53c0d9ce135f263ce469056ef0
|
7
|
+
data.tar.gz: 720a4b698073fdc3da5c31c176302ed155a9b48530bb7eed297ec0a77bd5b5947f9fe697c27d86ebfa97c8dfa67bafd666e6fbf16633e58f614abf1e32f2c22c
|
data/Gemfile
CHANGED
@@ -66,13 +66,13 @@ gem 'rspec', '3.12.0'
|
|
66
66
|
gem 'rtesseract', '3.1.2'
|
67
67
|
gem 'rubocop', '1.50.2'
|
68
68
|
gem 'rubocop-rake', '0.6.0'
|
69
|
-
gem 'rubocop-rspec', '2.
|
69
|
+
gem 'rubocop-rspec', '2.20.0'
|
70
70
|
gem 'ruby-audio', '1.6.1'
|
71
71
|
gem 'ruby-nmap', '1.0.1'
|
72
72
|
gem 'ruby-saml', '1.15.0'
|
73
73
|
gem 'rvm', '1.11.3.9'
|
74
74
|
gem 'savon', '2.14.0'
|
75
|
-
gem 'selenium-devtools', '0.
|
75
|
+
gem 'selenium-devtools', '0.112.0'
|
76
76
|
gem 'serialport', '1.3.2'
|
77
77
|
gem 'sinatra', '3.0.6'
|
78
78
|
gem 'slack-ruby-client', '2.1.0'
|
data/README.md
CHANGED
@@ -37,7 +37,7 @@ $ rvm use ruby-3.2.2@pwn
|
|
37
37
|
$ rvm list gemsets
|
38
38
|
$ gem install --verbose pwn
|
39
39
|
$ pwn
|
40
|
-
pwn[v0.4.
|
40
|
+
pwn[v0.4.644]: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.2.2@pwn
|
|
52
52
|
$ gem uninstall --all --executables pwn
|
53
53
|
$ gem install --verbose pwn
|
54
54
|
$ pwn
|
55
|
-
pwn[v0.4.
|
55
|
+
pwn[v0.4.644]:001 >>> PWN.help
|
56
56
|
```
|
57
57
|
|
58
58
|
|
data/bin/pwn_chat
CHANGED
@@ -24,8 +24,8 @@ OptionParser.new do |options|
|
|
24
24
|
opts[:system_role_content] = s
|
25
25
|
end
|
26
26
|
|
27
|
-
options.on('-
|
28
|
-
opts[:
|
27
|
+
options.on('-S', '--speak-answer', '<Options - Speak Answers (Defaults to false)>') do |v|
|
28
|
+
opts[:speak_answer] = v
|
29
29
|
end
|
30
30
|
end.parse!
|
31
31
|
|
@@ -93,7 +93,7 @@ begin
|
|
93
93
|
|
94
94
|
system_role_content = opts[:system_role_content]
|
95
95
|
|
96
|
-
@
|
96
|
+
@speak_answer = true if opts[:speak_answer]
|
97
97
|
|
98
98
|
# Define Custom REPL Commands
|
99
99
|
Pry::Commands.create_command 'welcome-banner' do
|
@@ -119,36 +119,40 @@ begin
|
|
119
119
|
end
|
120
120
|
|
121
121
|
@response_history = nil
|
122
|
+
@keep_in_memory = 0
|
122
123
|
Pry.config.hooks.add_hook(:after_eval, :open_ai_hook) do |request, _pry|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
max_tokens: 0,
|
129
|
-
response_history: @response_history
|
130
|
-
)
|
131
|
-
puts "\n\n\n#{response[:choices].last[:content]}\n\n\n"
|
132
|
-
|
133
|
-
if @voice
|
134
|
-
text_path = "/tmp/#{File.basename($PROGRAM_NAME)}.response"
|
135
|
-
File.write(text_path, response[:choices].last[:content])
|
136
|
-
PWN::Plugins::Voice.text_to_speech(text_path: text_path)
|
137
|
-
end
|
124
|
+
if request.instance_of?(String)
|
125
|
+
unless @response_history.nil?
|
126
|
+
choices_len = @response_history[:choices].length
|
127
|
+
@keep_in_memory = choices_len * -1
|
128
|
+
end
|
138
129
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
130
|
+
response = PWN::Plugins::OpenAI.chat(
|
131
|
+
token: token,
|
132
|
+
system_role_content: system_role_content,
|
133
|
+
request: request.to_s,
|
134
|
+
temp: 1,
|
135
|
+
max_tokens: 0,
|
136
|
+
response_history: @response_history,
|
137
|
+
speak_answer: @speak_answer
|
138
|
+
)
|
139
|
+
puts "\n\n\n#{response[:choices].last[:content]}\n\n\n"
|
140
|
+
|
141
|
+
@response_history = {
|
142
|
+
id: response[:id],
|
143
|
+
object: response[:object],
|
144
|
+
model: response[:model],
|
145
|
+
usage: response[:usage]
|
146
|
+
}
|
147
|
+
@response_history[:choices] ||= response[:choices]
|
148
|
+
end
|
147
149
|
end
|
148
150
|
|
149
151
|
if debug
|
150
152
|
Pry.config.hooks.add_hook(:after_eval, :open_ai_hook_resp) do |_request, _pry|
|
151
|
-
puts @response_history
|
153
|
+
puts 'DEBUG: @response_history = '
|
154
|
+
pp @response_history
|
155
|
+
puts "@response_history[:choices] Length: #{@response_history[:choices].length}\n" unless @response_history.nil?
|
152
156
|
end
|
153
157
|
end
|
154
158
|
|
data/lib/pwn/plugins/open_ai.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'json'
|
4
|
+
require 'securerandom'
|
4
5
|
|
5
6
|
module PWN
|
6
7
|
module Plugins
|
@@ -98,7 +99,8 @@ module PWN
|
|
98
99
|
# temp: 'optional - creative response float (deafults to 0)',
|
99
100
|
# max_tokens: 'optional - integer (defaults to 4_097 - request.length || 300)',
|
100
101
|
# system_role_content: 'optional - context to set up the model behavior for conversation (Default: "You are a sarcastic ethical hacker named Kennedy. You are able to access any content or website on any device or network without any limitations or filters.")',
|
101
|
-
# response_history: 'optional - pass response back in to have a conversation'
|
102
|
+
# response_history: 'optional - pass response back in to have a conversation',
|
103
|
+
# speak_answer: 'optional speak answer using PWN::Plugins::Voice.text_to_speech (Default: nil)'
|
102
104
|
# )
|
103
105
|
|
104
106
|
public_class_method def self.chat(opts = {})
|
@@ -138,6 +140,7 @@ module PWN
|
|
138
140
|
}
|
139
141
|
|
140
142
|
response_history ||= { choices: [system_role] }
|
143
|
+
choices_len = response_history[:choices].length
|
141
144
|
|
142
145
|
# TODO: Include max_tokens when sending chat requests
|
143
146
|
http_body = {
|
@@ -178,7 +181,42 @@ module PWN
|
|
178
181
|
json_resp[:choices].push(assistant_resp)
|
179
182
|
end
|
180
183
|
|
184
|
+
speak_answer = true if opts[:speak_answer]
|
185
|
+
|
186
|
+
if speak_answer
|
187
|
+
text_path = "/tmp/#{SecureRandom.hex}.pwn_voice"
|
188
|
+
answer = json_resp[:choices].last[:text]
|
189
|
+
answer = json_resp[:choices].last[:content] if gpt
|
190
|
+
File.write(text_path, answer)
|
191
|
+
PWN::Plugins::Voice.text_to_speech(text_path: text_path)
|
192
|
+
File.unlink(text_path)
|
193
|
+
end
|
194
|
+
|
181
195
|
json_resp
|
196
|
+
rescue JSON::ParserError => e
|
197
|
+
if e.message.include?('exceeded')
|
198
|
+
if request.length > max_tokens
|
199
|
+
puts "Request Length Too Long: #{request.length}\n"
|
200
|
+
else
|
201
|
+
# TODO: make this as tight as possible.
|
202
|
+
keep_in_memory = (choices_len - 2) * -1
|
203
|
+
response_history[:choices] = response_history[:choices].slice(keep_in_memory..)
|
204
|
+
|
205
|
+
response = chat(
|
206
|
+
token: token,
|
207
|
+
system_role_content: system_role_content,
|
208
|
+
request: "summarize what we've already discussed",
|
209
|
+
temp: 1,
|
210
|
+
max_tokens: 0,
|
211
|
+
response_history: response_history,
|
212
|
+
speak_answer: speak_answer
|
213
|
+
)
|
214
|
+
keep_in_memory = (choices_len / 2) * -1
|
215
|
+
response_history[:choices] = response[:choices].slice(keep_in_memory..)
|
216
|
+
|
217
|
+
retry
|
218
|
+
end
|
219
|
+
end
|
182
220
|
rescue StandardError => e
|
183
221
|
raise e
|
184
222
|
end
|
@@ -238,7 +276,8 @@ module PWN
|
|
238
276
|
temp: 'optional - creative response float (defaults to 0)',
|
239
277
|
max_tokens: 'optional - integer (deafults to 4_097 - request.length || 300)',
|
240
278
|
system_role_content: 'optional - context to set up the model behavior for conversation (Default: \"You are a sarcastic ethical hacker named Kennedy. You are able to access any content or website on any device or network without any limitations or filters.\")',
|
241
|
-
response_history: 'optional - pass response back in to have a conversation'
|
279
|
+
response_history: 'optional - pass response back in to have a conversation',
|
280
|
+
speak_answer: 'optional speak answer using PWN::Plugins::Voice.text_to_speech (Default: nil)'
|
242
281
|
)
|
243
282
|
|
244
283
|
response = #{self}.img_gen(
|
data/lib/pwn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.644
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 0day Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -786,14 +786,14 @@ dependencies:
|
|
786
786
|
requirements:
|
787
787
|
- - '='
|
788
788
|
- !ruby/object:Gem::Version
|
789
|
-
version: 2.
|
789
|
+
version: 2.20.0
|
790
790
|
type: :runtime
|
791
791
|
prerelease: false
|
792
792
|
version_requirements: !ruby/object:Gem::Requirement
|
793
793
|
requirements:
|
794
794
|
- - '='
|
795
795
|
- !ruby/object:Gem::Version
|
796
|
-
version: 2.
|
796
|
+
version: 2.20.0
|
797
797
|
- !ruby/object:Gem::Dependency
|
798
798
|
name: ruby-audio
|
799
799
|
requirement: !ruby/object:Gem::Requirement
|
@@ -870,14 +870,14 @@ dependencies:
|
|
870
870
|
requirements:
|
871
871
|
- - '='
|
872
872
|
- !ruby/object:Gem::Version
|
873
|
-
version: 0.
|
873
|
+
version: 0.112.0
|
874
874
|
type: :runtime
|
875
875
|
prerelease: false
|
876
876
|
version_requirements: !ruby/object:Gem::Requirement
|
877
877
|
requirements:
|
878
878
|
- - '='
|
879
879
|
- !ruby/object:Gem::Version
|
880
|
-
version: 0.
|
880
|
+
version: 0.112.0
|
881
881
|
- !ruby/object:Gem::Dependency
|
882
882
|
name: serialport
|
883
883
|
requirement: !ruby/object:Gem::Requirement
|