Skip to content

Commit 3133eb6

Browse files
committed
pwn REPL driver - implement welcome-banner command in REPL session to display example usage on demand
1 parent 831d253 commit 3133eb6

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
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.1.1@pwn
3737
$ rvm list gemsets
3838
$ gem install --verbose pwn
3939
$ pwn
40-
pwn[v0.4.403]:001 >>> PWN.help
40+
pwn[v0.4.404]: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.1.1@pwn
5252
$ gem uninstall --all --executables pwn
5353
$ gem install --verbose pwn
5454
$ pwn
55-
pwn[v0.4.403]:001 >>> PWN.help
55+
pwn[v0.4.404]:001 >>> PWN.help
5656
```
5757

5858

bin/pwn

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ begin
5656
end
5757

5858
# Define Custom REPL Commands
59+
Pry::Commands.create_command 'welcome-banner' do
60+
description 'Display the random welcome banner, including basic usage.'
61+
62+
def process
63+
puts PWN::Banner.welcome
64+
end
65+
end
66+
5967
Pry::Commands.create_command 'toggle-pager' do
6068
description 'Toggle less on returned objects surpassing the terminal.'
6169

@@ -67,12 +75,7 @@ begin
6775

6876
# Define REPL Hooks
6977
Pry.config.hooks.add_hook(:before_session, :welcome) do |output, _binding, _pry|
70-
output.puts PWN::Banner.get
71-
output.puts 'Use the #help command & methods for more options.'
72-
output.puts 'e.g help'
73-
output.puts 'e.g PWN.help'
74-
output.puts 'e.g PWN::Plugins.help'
75-
output.puts 'e.g PWN::Plugins::TransparentBrowser.help'
78+
output.puts PWN::Banner.welcome
7679
end
7780

7881
# Define PS1 Prompt

lib/pwn/banner.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@ module Banner
3939
banner
4040
end
4141

42+
# Supported Method Parameters::
43+
# PWN::Banner.get(
44+
# index: 'optional - defaults to random banner index'
45+
# )
46+
47+
public_class_method def self.welcome
48+
banner = PWN::Banner.get
49+
banner = "#{banner}\nUse the #help command & methods for more options.\n"
50+
banner = "#{banner}e.g help\n"
51+
banner = "#{banner}e.g PWN.help\n"
52+
banner = "#{banner}e.g PWN::Plugins.help\n"
53+
banner = "#{banner}e.g PWN::Plugins::TransparentBrowser.help\n"
54+
end
55+
4256
# Author(s):: 0day Inc. <[email protected]>
4357

4458
public_class_method def self.authors
@@ -55,6 +69,8 @@ module Banner
5569
index: 'optional - defaults to random banner index'
5670
)
5771
72+
banner = #{self}.welcome
73+
5874
#{self}.authors
5975
"
6076
end

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.403'
4+
VERSION = '0.4.404'
55
end

0 commit comments

Comments
 (0)