pwn 0.4.645 → 0.4.646
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 +4 -4
- data/README.md +2 -2
- data/bin/pwn +92 -1
- data/lib/pwn/version.rb +1 -1
- metadata +2 -4
- data/bin/pwn_chat +0 -173
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3c91157de7e5f636150debf731605340089f894541296f328201b94e5d02d79
|
4
|
+
data.tar.gz: 2f4c1d07bd0e1b56c03589cd500864e5b39fdd886ca67bc1302d47827047507b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8b51af5abbf70b01832ad5b88ea8981cc4224afbbfa823f21e1cdc02ad51891625cd57de522940c37e71b141b29cc8096419f4166ed56323187cc24e0f4188e
|
7
|
+
data.tar.gz: 2b0db372b007bbef8dd18c7acc273cf2595d47bd9f1285b22c2146d4a589fa54e1ac0fefcd75d44f0bcf2930ec2c770dffd0fe2dd2c21ebae6a4c1b403ebd684
|
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.646]:001 >>> PWN.help
|
41
41
|
```
|
42
42
|
|
43
43
|
[](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.646]:001 >>> PWN.help
|
56
56
|
```
|
57
57
|
|
58
58
|
|
data/bin/pwn
CHANGED
@@ -1,12 +1,25 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
require 'optparse'
|
4
5
|
require 'pwn'
|
5
6
|
require 'pry'
|
6
|
-
require '
|
7
|
+
require 'yaml'
|
8
|
+
# require 'colorize'
|
7
9
|
# require 'tty-prompt'
|
8
10
|
# require 'tty-reader'
|
9
11
|
|
12
|
+
opts = {}
|
13
|
+
OptionParser.new do |options|
|
14
|
+
options.banner = "USAGE:
|
15
|
+
#{$PROGRAM_NAME} [opts]
|
16
|
+
"
|
17
|
+
|
18
|
+
options.on('-cPATH', '--yaml-config=PATH', '<Optional - OpenAI YAML File>') do |p|
|
19
|
+
opts[:yaml_config_path] = p
|
20
|
+
end
|
21
|
+
end.parse!
|
22
|
+
|
10
23
|
begin
|
11
24
|
def gen_ps1_proc(opts = {})
|
12
25
|
delim = opts[:delim]
|
@@ -73,11 +86,89 @@ begin
|
|
73
86
|
end
|
74
87
|
end
|
75
88
|
|
89
|
+
Pry::Commands.create_command 'toggle-chatGPT-debug' do
|
90
|
+
description "Display the response_history object while using OpenAI's ChatGPT."
|
91
|
+
|
92
|
+
def process
|
93
|
+
pi = pry_instance
|
94
|
+
pi.config.chat_gpt_debug ? pi.config.chat_gpt_debug = false : pi.config.chat_gpt_debug = true
|
95
|
+
puts 'ChatGPT Debug Enabled.' if pi.config.chat_gpt_debug
|
96
|
+
puts 'ChatGPT Debug Disabled.' unless pi.config.chat_gpt_debug
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
Pry::Commands.create_command 'toggle-chatGPT-speaks' do
|
101
|
+
description 'Use speech capabilities within PWN to speak OpenAI ChatGPT answers.'
|
102
|
+
|
103
|
+
def process
|
104
|
+
pi = pry_instance
|
105
|
+
pi.config.chat_gpt_speak ? pi.config.chat_gpt_speak = false : pi.config.chat_gpt_speak = true
|
106
|
+
puts 'ChatGPT Speech Enabled.' if pi.config.chat_gpt_speak
|
107
|
+
puts 'ChatGPT Speech Disabled.' unless pi.config.chat_gpt_speak
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
Pry::Commands.create_command 'toggle-chatGPT' do
|
112
|
+
description "Interact w/ OpenAI's ChatGPT"
|
113
|
+
|
114
|
+
def process
|
115
|
+
pi = pry_instance
|
116
|
+
pi.config.chat_gpt ? pi.config.chat_gpt = false : pi.config.chat_gpt = true
|
117
|
+
puts 'ChatGPT Enabled.' if pi.config.chat_gpt
|
118
|
+
puts 'ChatGPT Disabled.' unless pi.config.chat_gpt
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
76
122
|
# Define REPL Hooks
|
123
|
+
# Welcome Banner Hook
|
77
124
|
Pry.config.hooks.add_hook(:before_session, :welcome) do |output, _binding, _pry|
|
78
125
|
output.puts PWN::Banner.welcome
|
79
126
|
end
|
80
127
|
|
128
|
+
# ChatGPT Hooks
|
129
|
+
Pry.config.hooks.add_hook(:before_session, :init_opts) do |_output, _binding, pi|
|
130
|
+
pi.config.chat_gpt_token = ''
|
131
|
+
if opts[:yaml_config_path] && File.exist?(opts[:yaml_config_path])
|
132
|
+
yaml_config_path = opts[:yaml_config_path]
|
133
|
+
yaml_config = YAML.load_file(yaml_config_path, symbolize_names: true)
|
134
|
+
pi.config.chat_gpt_token = yaml_config[:bearer_token]
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
Pry.config.hooks.add_hook(:after_eval, :open_ai_hook) do |request, pi|
|
139
|
+
if request.instance_of?(String) && pi.config.chat_gpt
|
140
|
+
debug = pi.config.chat_gpt_debug
|
141
|
+
token = pi.config.chat_gpt_token
|
142
|
+
token = PWN::Plugins::AuthenticationHelper.mask_password(prompt: 'OpenAI API Key') if token.empty?
|
143
|
+
response_history = pi.config.chat_gpt_response_history
|
144
|
+
speak_answer = pi.config.chat_gpt_speak
|
145
|
+
response = PWN::Plugins::OpenAI.chat(
|
146
|
+
token: token,
|
147
|
+
request: request.to_s,
|
148
|
+
temp: 1,
|
149
|
+
max_tokens: 0,
|
150
|
+
response_history: response_history,
|
151
|
+
speak_answer: speak_answer
|
152
|
+
)
|
153
|
+
puts "\n\n\n#{response[:choices].last[:content]}\n\n\n"
|
154
|
+
|
155
|
+
response_history = {
|
156
|
+
id: response[:id],
|
157
|
+
object: response[:object],
|
158
|
+
model: response[:model],
|
159
|
+
usage: response[:usage]
|
160
|
+
}
|
161
|
+
response_history[:choices] ||= response[:choices]
|
162
|
+
|
163
|
+
if debug
|
164
|
+
puts 'DEBUG: response_history = '
|
165
|
+
pp response_history
|
166
|
+
puts "response_history[:choices] Length: #{response_history[:choices].length}\n" unless response_history.nil?
|
167
|
+
end
|
168
|
+
pi.config.chat_gpt_response_history = response_history
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
81
172
|
# Define PS1 Prompt
|
82
173
|
Pry.config.pwn_repl_line = 0
|
83
174
|
arrow_ps1_proc = gen_ps1_proc
|
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.646
|
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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -1091,7 +1091,6 @@ executables:
|
|
1091
1091
|
- pwn_char_html_entity_encoding
|
1092
1092
|
- pwn_char_unicode_escaped_encoding
|
1093
1093
|
- pwn_char_url_encoding
|
1094
|
-
- pwn_chat
|
1095
1094
|
- pwn_defectdojo_engagement_create
|
1096
1095
|
- pwn_defectdojo_importscan
|
1097
1096
|
- pwn_defectdojo_reimportscan
|
@@ -1158,7 +1157,6 @@ files:
|
|
1158
1157
|
- bin/pwn_char_html_entity_encoding
|
1159
1158
|
- bin/pwn_char_unicode_escaped_encoding
|
1160
1159
|
- bin/pwn_char_url_encoding
|
1161
|
-
- bin/pwn_chat
|
1162
1160
|
- bin/pwn_defectdojo_engagement_create
|
1163
1161
|
- bin/pwn_defectdojo_importscan
|
1164
1162
|
- bin/pwn_defectdojo_reimportscan
|
data/bin/pwn_chat
DELETED
@@ -1,173 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'optparse'
|
5
|
-
require 'pwn'
|
6
|
-
require 'pry'
|
7
|
-
require 'yaml'
|
8
|
-
|
9
|
-
opts = {}
|
10
|
-
OptionParser.new do |options|
|
11
|
-
options.banner = "USAGE:
|
12
|
-
#{$PROGRAM_NAME} [opts]
|
13
|
-
"
|
14
|
-
|
15
|
-
options.on('-cPATH', '--yaml-config=PATH', '<Required - OpenAI YAML File>') do |p|
|
16
|
-
opts[:yaml_config_path] = p
|
17
|
-
end
|
18
|
-
|
19
|
-
options.on('-d', '--[no-]debug', '<Options - Display response_history Object During Session>') do |d|
|
20
|
-
opts[:debug] = d
|
21
|
-
end
|
22
|
-
|
23
|
-
options.on('-sSTAGE', '--system-role-content=STAGE', '<Optional - system Role Content Value to Define Behavior of assistant responses (Defaults to value in PWN::Plugins::OpenAI.chat method)>') do |s|
|
24
|
-
opts[:system_role_content] = s
|
25
|
-
end
|
26
|
-
|
27
|
-
options.on('-S', '--speak-answer', '<Options - Speak Answers (Defaults to false)>') do |v|
|
28
|
-
opts[:speak_answer] = v
|
29
|
-
end
|
30
|
-
end.parse!
|
31
|
-
|
32
|
-
if opts.empty?
|
33
|
-
puts `#{$PROGRAM_NAME} --help`
|
34
|
-
exit 1
|
35
|
-
end
|
36
|
-
|
37
|
-
begin
|
38
|
-
def gen_ps1_proc(opts = {})
|
39
|
-
delim = opts[:delim]
|
40
|
-
|
41
|
-
# title = 'pwn'.red.bold
|
42
|
-
title = "\001\e[1m\002\001\e[31m\002#{File.basename($PROGRAM_NAME)}\001\e[0m\002"
|
43
|
-
# version = PWN::VERSION.cyan
|
44
|
-
version = "\001\e[36m\002v#{PWN::VERSION}\001\e[0m\002"
|
45
|
-
# dchars = '>>>'.green
|
46
|
-
dchars = "\001\e[32m\002>>>\001\e[0m\002"
|
47
|
-
# dchars = '***'.yellow if delim == :splat
|
48
|
-
dchars = "\001\e[33m\002***\001\e[0m\002" if delim == :splat
|
49
|
-
|
50
|
-
proc do |_target_self, _nest_level, pry|
|
51
|
-
pry.config.pwn_repl_line += 1
|
52
|
-
line_pad = format(
|
53
|
-
'%0.3d',
|
54
|
-
pry.config.pwn_repl_line
|
55
|
-
)
|
56
|
-
line_count = "\001\e[34m\002#{line_pad}\001\e[0m\002" # Blue
|
57
|
-
"#{title}[#{version}]:#{line_count} #{dchars} ".to_s.scrub
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
class Pry
|
62
|
-
# Overwrite Pry::History.push method in History class to get duplicate history entries
|
63
|
-
# in order to properly replay automation in this prototyping driver
|
64
|
-
class History
|
65
|
-
def push(line)
|
66
|
-
return line if line.empty? || invalid_readline_line?(line)
|
67
|
-
|
68
|
-
begin
|
69
|
-
last_line = @history[-1]
|
70
|
-
rescue IndexError
|
71
|
-
last_line = nil
|
72
|
-
end
|
73
|
-
|
74
|
-
@history << line
|
75
|
-
@history_line_count += 1
|
76
|
-
@saver.call(line) if !should_ignore?(line) &&
|
77
|
-
Pry.config.history_save
|
78
|
-
|
79
|
-
line
|
80
|
-
end
|
81
|
-
alias << push
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
# Get OptParse Cli Parameters
|
86
|
-
yaml_config_path = opts[:yaml_config_path]
|
87
|
-
raise "ERROR: YAML Config => #{yaml_config_path} not found." unless File.exist?(yaml_config_path)
|
88
|
-
|
89
|
-
yaml_config = YAML.load_file(yaml_config_path, symbolize_names: true)
|
90
|
-
token = yaml_config[:bearer_token]
|
91
|
-
|
92
|
-
debug = opts[:debug]
|
93
|
-
|
94
|
-
system_role_content = opts[:system_role_content]
|
95
|
-
|
96
|
-
@speak_answer = true if opts[:speak_answer]
|
97
|
-
|
98
|
-
# Define Custom REPL Commands
|
99
|
-
Pry::Commands.create_command 'welcome-banner' do
|
100
|
-
description 'Display the random welcome banner, including basic usage.'
|
101
|
-
|
102
|
-
def process
|
103
|
-
puts PWN::Banner.welcome
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
Pry::Commands.create_command 'toggle-pager' do
|
108
|
-
description 'Toggle less on returned objects surpassing the terminal.'
|
109
|
-
|
110
|
-
def process
|
111
|
-
pi = pry_instance
|
112
|
-
pi.config.pager ? pi.config.pager = false : pi.config.pager = true
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
# Define REPL Hooks
|
117
|
-
Pry.config.hooks.add_hook(:before_session, :welcome) do |output, _binding, _pry|
|
118
|
-
output.puts PWN::Banner.welcome
|
119
|
-
end
|
120
|
-
|
121
|
-
@response_history = nil
|
122
|
-
Pry.config.hooks.add_hook(:after_eval, :open_ai_hook) do |request, _pry|
|
123
|
-
if request.instance_of?(String)
|
124
|
-
response = PWN::Plugins::OpenAI.chat(
|
125
|
-
token: token,
|
126
|
-
system_role_content: system_role_content,
|
127
|
-
request: request.to_s,
|
128
|
-
temp: 1,
|
129
|
-
max_tokens: 0,
|
130
|
-
response_history: @response_history,
|
131
|
-
speak_answer: @speak_answer
|
132
|
-
)
|
133
|
-
puts "\n\n\n#{response[:choices].last[:content]}\n\n\n"
|
134
|
-
|
135
|
-
@response_history = {
|
136
|
-
id: response[:id],
|
137
|
-
object: response[:object],
|
138
|
-
model: response[:model],
|
139
|
-
usage: response[:usage]
|
140
|
-
}
|
141
|
-
@response_history[:choices] ||= response[:choices]
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
if debug
|
146
|
-
Pry.config.hooks.add_hook(:after_eval, :open_ai_hook_resp) do |_request, _pry|
|
147
|
-
puts 'DEBUG: @response_history = '
|
148
|
-
pp @response_history
|
149
|
-
puts "@response_history[:choices] Length: #{@response_history[:choices].length}\n" unless @response_history.nil?
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
# Define PS1 Prompt
|
154
|
-
Pry.config.pwn_repl_line = 0
|
155
|
-
arrow_ps1_proc = gen_ps1_proc
|
156
|
-
splat_ps1_proc = gen_ps1_proc(delim: :splat)
|
157
|
-
prompt_ps1 = [arrow_ps1_proc, splat_ps1_proc]
|
158
|
-
|
159
|
-
pwn_prompt = Pry::Prompt.new(
|
160
|
-
:pwn_chat,
|
161
|
-
'PWN Prototyping REPL w/ OpenAI Assistant',
|
162
|
-
prompt_ps1
|
163
|
-
)
|
164
|
-
|
165
|
-
# Start PWN REPL
|
166
|
-
Pry.config.prompt_name = :pwn_chat
|
167
|
-
Pry.start(
|
168
|
-
self,
|
169
|
-
prompt: pwn_prompt
|
170
|
-
)
|
171
|
-
rescue StandardError => e
|
172
|
-
raise e
|
173
|
-
end
|