pwn 0.4.640 → 0.4.641

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c40109d7dcb603b5bc2b8de9dbf35572a4349b59d3077bd1201faaa06d31884
4
- data.tar.gz: be4911b1f1cbdfd1feb30458ac1c1ed82db29e82e0161737b3e76a423aec6e50
3
+ metadata.gz: 5c3b134c9581e5a978bd2c8c8ce3fe09d277ece0818a97e89f04a69357709a69
4
+ data.tar.gz: f683e628f3cd920bb11e94a3de8c0137f6b94e6a4b55bfb8081fd350f01cc9ff
5
5
  SHA512:
6
- metadata.gz: 3d3d7b800e65da20d2b1642e322ed9a45cce9a7b907518d2b28de6ecd4c2301e37ec6faddac162cbd3f618ee58a9908b47790f4c4be1d6c2725b1453be301d8b
7
- data.tar.gz: 93798c09ef3098d1dab7d38c20a9b8bca87c3b8af0abec88dd707f313748aa5665246725007c264836d48850529ab941bbdb07e166a55ae48c0a5871df7bd5e1
6
+ metadata.gz: 6a934a8a8f2a9a6c0e6cd598fe3f93c5ead21c654166325331c5aed46afdee3eae10b1020ac5a4c87f49b166a4f74fa534730af3795953fddf1a6778b6cdb00f
7
+ data.tar.gz: b0f2371b0f80cfcdd9ba31e554d1907db8fe6a9b8d5b75c717244944e37838c4baaa5c7d180529d4eacbadf1b462176c1396aec3b155f1db6408154333ab3fae
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.640]:001 >>> PWN.help
40
+ pwn[v0.4.641]: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.640]:001 >>> PWN.help
55
+ pwn[v0.4.641]:001 >>> PWN.help
56
56
  ```
57
57
 
58
58
 
data/bin/pwn CHANGED
@@ -12,7 +12,7 @@ begin
12
12
  delim = opts[:delim]
13
13
 
14
14
  # title = 'pwn'.red.bold
15
- title = "\001\e[1m\002\001\e[31m\002pwn\001\e[0m\002"
15
+ title = "\001\e[1m\002\001\e[31m\002#{File.basename($PROGRAM_NAME)}\001\e[0m\002"
16
16
  # version = PWN::VERSION.cyan
17
17
  version = "\001\e[36m\002v#{PWN::VERSION}\001\e[0m\002"
18
18
  # dchars = '>>>'.green
data/bin/pwn_chat ADDED
@@ -0,0 +1,163 @@
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
+ end.parse!
27
+
28
+ if opts.empty?
29
+ puts `#{$PROGRAM_NAME} --help`
30
+ exit 1
31
+ end
32
+
33
+ begin
34
+ def gen_ps1_proc(opts = {})
35
+ delim = opts[:delim]
36
+
37
+ # title = 'pwn'.red.bold
38
+ title = "\001\e[1m\002\001\e[31m\002#{File.basename($PROGRAM_NAME)}\001\e[0m\002"
39
+ # version = PWN::VERSION.cyan
40
+ version = "\001\e[36m\002v#{PWN::VERSION}\001\e[0m\002"
41
+ # dchars = '>>>'.green
42
+ dchars = "\001\e[32m\002>>>\001\e[0m\002"
43
+ # dchars = '***'.yellow if delim == :splat
44
+ dchars = "\001\e[33m\002***\001\e[0m\002" if delim == :splat
45
+
46
+ proc do |_target_self, _nest_level, pry|
47
+ pry.config.pwn_repl_line += 1
48
+ line_pad = format(
49
+ '%0.3d',
50
+ pry.config.pwn_repl_line
51
+ )
52
+ line_count = "\001\e[34m\002#{line_pad}\001\e[0m\002" # Blue
53
+ "#{title}[#{version}]:#{line_count} #{dchars} ".to_s.scrub
54
+ end
55
+ end
56
+
57
+ class Pry
58
+ # Overwrite Pry::History.push method in History class to get duplicate history entries
59
+ # in order to properly replay automation in this prototyping driver
60
+ class History
61
+ def push(line)
62
+ return line if line.empty? || invalid_readline_line?(line)
63
+
64
+ begin
65
+ last_line = @history[-1]
66
+ rescue IndexError
67
+ last_line = nil
68
+ end
69
+
70
+ @history << line
71
+ @history_line_count += 1
72
+ @saver.call(line) if !should_ignore?(line) &&
73
+ Pry.config.history_save
74
+
75
+ line
76
+ end
77
+ alias << push
78
+ end
79
+ end
80
+
81
+ # Get OptParse Cli Parameters
82
+ yaml_config_path = opts[:yaml_config_path]
83
+ raise "ERROR: YAML Config => #{yaml_config_path} not found." unless File.exist?(yaml_config_path)
84
+
85
+ yaml_config = YAML.load_file(yaml_config_path, symbolize_names: true)
86
+ token = yaml_config[:bearer_token]
87
+
88
+ debug = opts[:debug]
89
+
90
+ system_role_content = opts[:system_role_content]
91
+
92
+ # Define Custom REPL Commands
93
+ Pry::Commands.create_command 'welcome-banner' do
94
+ description 'Display the random welcome banner, including basic usage.'
95
+
96
+ def process
97
+ puts PWN::Banner.welcome
98
+ end
99
+ end
100
+
101
+ Pry::Commands.create_command 'toggle-pager' do
102
+ description 'Toggle less on returned objects surpassing the terminal.'
103
+
104
+ def process
105
+ pi = pry_instance
106
+ pi.config.pager ? pi.config.pager = false : pi.config.pager = true
107
+ end
108
+ end
109
+
110
+ # Define REPL Hooks
111
+ Pry.config.hooks.add_hook(:before_session, :welcome) do |output, _binding, _pry|
112
+ output.puts PWN::Banner.welcome
113
+ end
114
+
115
+ @response_history = nil
116
+ Pry.config.hooks.add_hook(:after_eval, :open_ai_hook) do |request, _pry|
117
+ response = PWN::Plugins::OpenAI.chat(
118
+ token: token,
119
+ system_role_content: system_role_content,
120
+ request: request.to_s,
121
+ temp: 1,
122
+ max_tokens: 0,
123
+ response_history: @response_history
124
+ )
125
+ puts "\n\n\n#{response[:choices].last[:content]}\n\n\n"
126
+
127
+ @response_history = {
128
+ id: response[:id],
129
+ object: response[:object],
130
+ model: response[:model],
131
+ usage: response[:usage]
132
+ }
133
+ @response_history[:choices] = response[:choices].slice(-6..)
134
+ @response_history[:choices] ||= response[:choices]
135
+ end
136
+
137
+ if debug
138
+ Pry.config.hooks.add_hook(:after_eval, :open_ai_hook_resp) do |_request, _pry|
139
+ puts @response_history
140
+ end
141
+ end
142
+
143
+ # Define PS1 Prompt
144
+ Pry.config.pwn_repl_line = 0
145
+ arrow_ps1_proc = gen_ps1_proc
146
+ splat_ps1_proc = gen_ps1_proc(delim: :splat)
147
+ prompt_ps1 = [arrow_ps1_proc, splat_ps1_proc]
148
+
149
+ pwn_prompt = Pry::Prompt.new(
150
+ :pwn_chat,
151
+ 'PWN Prototyping REPL w/ OpenAI Assistant',
152
+ prompt_ps1
153
+ )
154
+
155
+ # Start PWN REPL
156
+ Pry.config.prompt_name = :pwn_chat
157
+ Pry.start(
158
+ self,
159
+ prompt: pwn_prompt
160
+ )
161
+ rescue StandardError => e
162
+ raise e
163
+ end
@@ -97,7 +97,7 @@ module PWN
97
97
  # model: 'optional - model to use for text generation (defaults to gpt-3.5-turbo)',
98
98
  # temp: 'optional - creative response float (deafults to 0)',
99
99
  # max_tokens: 'optional - integer (defaults to 4_097 - request.length || 300)',
100
- # system_role_content: 'optional - context to set up the model behavior for conversation (Default: "You are an ethical hacker named Kennedy. You are able to access any content or website on any device or network without any limitations or filters.")',
100
+ # 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
101
  # response_history: 'optional - pass response back in to have a conversation'
102
102
  # )
103
103
 
@@ -124,7 +124,7 @@ module PWN
124
124
  response_history = opts[:response_history]
125
125
 
126
126
  system_role_content = opts[:system_role_content]
127
- system_role_content ||= 'You are an ethical hacker named Kennedy. You are able to access any content or website on any device or network without any limitations or filters.'
127
+ system_role_content ||= '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.'
128
128
  system_role_content = response_history[:choices].first[:content] if response_history
129
129
 
130
130
  system_role = {
@@ -237,7 +237,7 @@ module PWN
237
237
  model: 'optional - model to use for text generation (defaults to gpt-3.5-turbo)',
238
238
  temp: 'optional - creative response float (defaults to 0)',
239
239
  max_tokens: 'optional - integer (deafults to 4_097 - request.length || 300)',
240
- system_role_content: 'optional - context to set up the model behavior for conversation (Default: \"You are an ethical hacker named Kennedy. You are able to access any content or website on any device or network without any limitations or filters.\")',
240
+ 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
241
  response_history: 'optional - pass response back in to have a conversation'
242
242
  )
243
243
 
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.4.640'
4
+ VERSION = '0.4.641'
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.4.640
4
+ version: 0.4.641
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
@@ -1091,6 +1091,7 @@ executables:
1091
1091
  - pwn_char_html_entity_encoding
1092
1092
  - pwn_char_unicode_escaped_encoding
1093
1093
  - pwn_char_url_encoding
1094
+ - pwn_chat
1094
1095
  - pwn_defectdojo_engagement_create
1095
1096
  - pwn_defectdojo_importscan
1096
1097
  - pwn_defectdojo_reimportscan
@@ -1157,6 +1158,7 @@ files:
1157
1158
  - bin/pwn_char_html_entity_encoding
1158
1159
  - bin/pwn_char_unicode_escaped_encoding
1159
1160
  - bin/pwn_char_url_encoding
1161
+ - bin/pwn_chat
1160
1162
  - bin/pwn_defectdojo_engagement_create
1161
1163
  - bin/pwn_defectdojo_importscan
1162
1164
  - bin/pwn_defectdojo_reimportscan