Class: Rex::IO::BidirectionalPipe
- Inherits:
-
Ui::Text::Input
- Object
- Ui::Text::Input
- Rex::IO::BidirectionalPipe
- Defined in:
- lib/ssl_scan/io/bidirectional_pipe.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
Wrappers for shell methods.
-
#output ⇒ Object
Wrappers for shell methods.
-
#prompt ⇒ Object
Wrappers for shell methods.
Instance Method Summary collapse
-
#close ⇒ Object
Wrappers for the pipe_input methods.
- #create_subscriber(id = nil) ⇒ Object
- #create_subscriber_proc(id = nil, &block) ⇒ Object
- #eof? ⇒ Boolean
- #fd ⇒ Object
- #flush ⇒ Object
- #gets ⇒ Object
- #has_subscriber?(id) ⇒ Boolean
-
#initialize ⇒ BidirectionalPipe
constructor
A new instance of BidirectionalPipe.
- #intrinsic_shell? ⇒ Boolean
- #pgets ⇒ Object
- #pipe_input ⇒ Object
- #print(msg = '') ⇒ Object
- #print_debug(msg = '') ⇒ Object
- #print_error(msg = '') ⇒ Object
- #print_good(msg = '') ⇒ Object
- #print_line(msg = '') ⇒ Object
- #print_status(msg = '') ⇒ Object
- #print_warning(msg = '') ⇒ Object
- #put(msg) ⇒ Object
- #read_subscriber(id) ⇒ Object
- #remove_subscriber(id) ⇒ Object
- #supports_color? ⇒ Boolean
- #supports_readline ⇒ Object
- #sysread(len = 1) ⇒ Object
- #write_input(buf) ⇒ Object
Constructor Details
#initialize ⇒ BidirectionalPipe
Returns a new instance of BidirectionalPipe.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 11 def initialize @subscribers_out = {} @subscribers_ref = {} @subscribers_idx = 0 @pipe_input = Rex::Ui::Text::Input::Buffer.new # We are the shell, the input, and the output self.output = self self.input = self end |
Instance Attribute Details
#input ⇒ Object
Wrappers for shell methods
137 138 139 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 137 def input @input end |
#output ⇒ Object
Wrappers for shell methods
137 138 139 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 137 def output @output end |
#prompt ⇒ Object
Wrappers for shell methods
137 138 139 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 137 def prompt @prompt end |
Instance Method Details
#close ⇒ Object
Wrappers for the pipe_input methods
109 110 111 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 109 def close @pipe_input.close end |
#create_subscriber(id = nil) ⇒ Object
34 35 36 37 38 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 34 def create_subscriber(id=nil) id ||= (@subscribers_idx += 1).to_s @subscribers_out[id] = Rex::Ui::Text::Output::Buffer.new return id end |
#create_subscriber_proc(id = nil, &block) ⇒ Object
40 41 42 43 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 40 def create_subscriber_proc(id=nil, &block) id = create_subscriber(id) @subscribers_ref[id] = block end |
#eof? ⇒ Boolean
125 126 127 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 125 def eof? @pipe_input.eof? end |
#fd ⇒ Object
129 130 131 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 129 def fd @pipe_input.fd end |
#flush ⇒ Object
94 95 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 94 def flush end |
#gets ⇒ Object
121 122 123 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 121 def gets @pipe_input.gets end |
#has_subscriber?(id) ⇒ Boolean
30 31 32 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 30 def has_subscriber?(id) @subscribers_out.has_key?(id) end |
#intrinsic_shell? ⇒ Boolean
139 140 141 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 139 def intrinsic_shell? true end |
#pgets ⇒ Object
151 152 153 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 151 def pgets gets end |
#pipe_input ⇒ Object
22 23 24 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 22 def pipe_input @pipe_input end |
#print(msg = '') ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 66 def print(msg='') @subscribers_out.each_pair { |id, buf| begin @subscribers_ref[id] ? @subscribers_ref[id].call(msg) : buf.print(msg) rescue ::Exception => e # $stderr.puts "Error handling subscriber #{id}: #{e} #{e.backtrace.inspect}" raise e end } msg end |
#print_debug(msg = '') ⇒ Object
90 91 92 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 90 def print_debug(msg='') print_line('[!] ' + msg) end |
#print_error(msg = '') ⇒ Object
78 79 80 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 78 def print_error(msg='') print_line('[-] ' + msg) end |
#print_good(msg = '') ⇒ Object
86 87 88 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 86 def print_good(msg='') print_line('[+] ' + msg) end |
#print_line(msg = '') ⇒ Object
82 83 84 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 82 def print_line(msg='') print(msg + "\n") end |
#print_status(msg = '') ⇒ Object
97 98 99 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 97 def print_status(msg='') print_line('[*] ' + msg) end |
#print_warning(msg = '') ⇒ Object
101 102 103 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 101 def print_warning(msg='') print_line('[!] ' + msg) end |
#put(msg) ⇒ Object
117 118 119 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 117 def put(msg) @pipe_input.put(msg) end |
#read_subscriber(id) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 54 def read_subscriber(id) output = @subscribers_out[id] return '' if output.nil? buf = output.buf output.reset buf end |
#remove_subscriber(id) ⇒ Object
45 46 47 48 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 45 def remove_subscriber(id) @subscribers_out.delete(id) @subscribers_ref.delete(id) end |
#supports_color? ⇒ Boolean
147 148 149 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 147 def supports_color? false end |
#supports_readline ⇒ Object
143 144 145 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 143 def supports_readline false end |
#sysread(len = 1) ⇒ Object
113 114 115 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 113 def sysread(len = 1) @pipe_input.sysread(len) end |
#write_input(buf) ⇒ Object
50 51 52 |
# File 'lib/ssl_scan/io/bidirectional_pipe.rb', line 50 def write_input(buf) @pipe_input.put(buf) end |