class ProcessRun
Public Class Methods
new(stdin, stdout)
click to toggle source
# File lib/pwnlib/process.rb, line 4 def initialize stdin, stdout @stdin = stdin @stdout = stdout @output_buf = [] @get_input = true @stdout_thr = Thread.new do while @get_input data = @stdout.readpartial(4096) if data lines = data.split("\n") @output_buf += lines end end end end
Public Instance Methods
close()
click to toggle source
# File lib/pwnlib/process.rb, line 69 def close @stdout.flush @stdin.flush @get_input = false output @stdin.close @stdout.close unless @stdin == @stdout end
interactive()
click to toggle source
# File lib/pwnlib/process.rb, line 53 def interactive while 1 print "\n$> " input = gets.chomp if input == "exit" or input == "quit" break end @stdin.puts(input) sleep 0.1 output end end
output()
click to toggle source
# File lib/pwnlib/process.rb, line 21 def output sleep 0.1 @output_buf.each {|l| puts l; } output_clear end
output_clear()
click to toggle source
# File lib/pwnlib/process.rb, line 32 def output_clear sleep 0.1 @output_buf = [] end
raw_buffer()
click to toggle source
# File lib/pwnlib/process.rb, line 27 def raw_buffer sleep 0.1 @output_buf end
recv()
click to toggle source
# File lib/pwnlib/process.rb, line 37 def recv sleep 0.1 @output_buf.shift end
send(msg)
click to toggle source
# File lib/pwnlib/process.rb, line 42 def send msg @stdin.write msg sleep 0.1 end
write(msg)
click to toggle source
# File lib/pwnlib/process.rb, line 47 def write msg File.open("sploit", "w") do |f| f.puts msg end end