Sunday, 8 September 2013

Exploit exercises - Protostar - Net 2

Third network level requires to sum 4 integers and send result. They are provided by the server. Nothing special just use of pack and unpack methods.



Code:
  1. #!/usr/bin/ruby1.9.1
  2. require "socket"
  3.  
  4. sock = TCPSocket.new('127.0.0.1','2997')
  5. result = 0
  6. 4.times do |ind|
  7. is = sock.read(4)
  8. puts is.unpack('l')[0]
  9. result += is.unpack('l')[0]
  10. end
  11. puts result
  12. sock.puts [result].pack('l')
  13. puts sock.gets
  14. sock.close
Proof:

No comments:

Post a Comment