Class: Rex::IO::BidirectionalPipe
Constant Summary
Ui::Text::Color::AnsiAttributes
Instance Attribute Summary collapse
#config, #eof, #prompt_char
Instance Method Summary
collapse
#auto_color, #disable_color, #enable_color, #reset_color, #reset_tab_completion, #update_prompt
#ansi, #colorize, #do_colorize, #reset_color, #substitute_colors
Constructor Details
Returns a new instance of BidirectionalPipe.
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 11
def initialize
@subscribers_out = {}
@subscribers_ref = {}
@subscribers_idx = 0
@pipe_input = Rex::Ui::Text::Input::Buffer.new
self.output = self
self.input = self
end
|
Instance Attribute Details
Wrappers for shell methods
137
138
139
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 137
def input
@input
end
|
#output ⇒ Object
Wrappers for shell methods
137
138
139
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 137
def output
@output
end
|
#prompt ⇒ Object
Wrappers for shell methods
137
138
139
|
# File 'lib/rex/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/rex/io/bidirectional_pipe.rb', line 109
def close
@pipe_input.close
end
|
#create_subscriber(id = nil) ⇒ Object
34
35
36
37
38
|
# File 'lib/rex/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/rex/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/rex/io/bidirectional_pipe.rb', line 125
def eof?
@pipe_input.eof?
end
|
#fd ⇒ Object
129
130
131
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 129
def fd
@pipe_input.fd
end
|
#flush ⇒ Object
94
95
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 94
def flush
end
|
#gets ⇒ Object
121
122
123
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 121
def gets
@pipe_input.gets
end
|
#has_subscriber?(id) ⇒ Boolean
30
31
32
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 30
def has_subscriber?(id)
@subscribers_out.has_key?(id)
end
|
#intrinsic_shell? ⇒ Boolean
139
140
141
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 139
def intrinsic_shell?
true
end
|
#pgets ⇒ Object
151
152
153
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 151
def pgets
gets
end
|
22
23
24
|
# File 'lib/rex/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/rex/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
raise e
end
}
msg
end
|
#print_debug(msg = '') ⇒ Object
90
91
92
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 90
def print_debug(msg='')
print_line('[!] ' + msg)
end
|
#print_error(msg = '') ⇒ Object
78
79
80
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 78
def print_error(msg='')
print_line('[-] ' + msg)
end
|
#print_good(msg = '') ⇒ Object
86
87
88
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 86
def print_good(msg='')
print_line('[+] ' + msg)
end
|
#print_line(msg = '') ⇒ Object
82
83
84
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 82
def print_line(msg='')
print(msg + "\n")
end
|
#print_status(msg = '') ⇒ Object
97
98
99
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 97
def print_status(msg='')
print_line('[*] ' + msg)
end
|
#print_warning(msg = '') ⇒ Object
101
102
103
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 101
def print_warning(msg='')
print_line('[!] ' + msg)
end
|
#put(msg) ⇒ Object
117
118
119
|
# File 'lib/rex/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/rex/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/rex/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/rex/io/bidirectional_pipe.rb', line 147
def supports_color?
false
end
|
#supports_readline ⇒ Object
143
144
145
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 143
def supports_readline
false
end
|
#sysread(len = 1) ⇒ Object
113
114
115
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 113
def sysread(len = 1)
@pipe_input.sysread(len)
end
|
50
51
52
|
# File 'lib/rex/io/bidirectional_pipe.rb', line 50
def write_input(buf)
@pipe_input.put(buf)
end
|