Method: Pwnlib::Tubes::Tube#puts

Defined in:
lib/pwnlib/tubes/tube.rb

#puts(*objs) ⇒ Integer

Sends the given object(s). The difference with IO#puts is using context.newline as default newline.

Examples:

s.puts
puts client.recv
#
#=> nil
s.puts('shik', "hao\n", 123)
puts client.recv
# shik
# hao
# 123
#=> nil
s.puts(["darkhh\n\n", 'wei shi', 360])
puts client.recv
# darkhh
#
# wei shi
# 360
#=> nil

Parameters:

  • The objects to be sent.

Returns:

  • Returns the number of bytes had been sent.



343
344
345
346
347
348
349
350
351
352
353
# File 'lib/pwnlib/tubes/tube.rb', line 343

def puts(*objs)
  return write(context.newline) if objs.empty?

  objs = *objs.flatten
  s = +''
  objs.map(&:to_s).each do |elem|
    s << elem
    s << context.newline unless elem.end_with?(context.newline)
  end
  write(s)
end