Sunday, 8 September 2013

Exploit exercises - Protostar - Net 1

Next level requires to convert binary integer to its string representation. All we have to do is read 4 bytes, convert bytes to int then convert it into string. Ruby have unpack method of String class to do required transformation.



Code:
  1. #!/usr/bin/ruby1.9.1
  2. require "socket"
  3.  
  4. sock = TCPSocket.new('127.0.0.1','2998')
  5. string = sock.read(4)
  6. puts string
  7. i = string.unpack('l')
  8. puts i
  9. sock.puts i
  10. puts sock.gets
  11. sock.close

Proof:

No comments:

Post a Comment