lib/shaddox/target.rb in shaddox-0.0.12 vs lib/shaddox/target.rb in shaddox-0.0.13

- old
+ new

@@ -118,25 +118,20 @@ end end def exec(command) exit_code = nil @ssh.open_channel do |channel| - channel.exec(command) do |ch, success| - ch.request_pty :want_reply => true - #return nil if !success - ch.on_data do |ch, data| + channel.request_pty do |c, success| + raise "SSH could not obtain a pty." unless success + channel.exec(command) + channel.on_data do |c_, data| $stdout.print data if data =~ /^\[sudo\]|Password/i - channel.send_data(gets.strip) + warning "Target is asking for password: ", 1 + channel.send_data(gets.strip + "\n") end end - #ch.on_extended_data do |ch, data| - #$stderr.print data - #if data =~ /^\[sudo\] password for user:/ - #channel.send_data(gets.strip) - #end - #end - ch.on_request('exit-status') do |ch, data| + channel.on_request('exit-status') do |ch, data| exit_code = data.read_long end end end @ssh.loop