E
Eugeni Akmuradov
Hello! Recently found this game and it totally got me up. Thou the first
level is extremly straight-forward with C, but i do belive that it is
actually not so difficult with Ruby.
Here is the task:
Your goal is to connect to port 5842 on vortex.labs.overthewire.org and
read in 4 unsigned integers in host byte order. Add these integers
together and send back the results to get a username and password for
level 1.
And here is my code:
require 'socket'
socket = TCPSocket::new( "vortex.labs.overthewire.org", 5842 )
data=Array.new
s=0
4.times do
data = data + socket.recvfrom(4)
end
data.compact!
puts "complete string #{data.inspect}"
data.each { |x| s += x.unpack('L')[0] ; print x.unpack('L')[0], " " }
puts
socket.write s
puts socket.read
socket.close
And it do not solve the subject, please help me to understand where i's
my mistake.
level is extremly straight-forward with C, but i do belive that it is
actually not so difficult with Ruby.
Here is the task:
Your goal is to connect to port 5842 on vortex.labs.overthewire.org and
read in 4 unsigned integers in host byte order. Add these integers
together and send back the results to get a username and password for
level 1.
And here is my code:
require 'socket'
socket = TCPSocket::new( "vortex.labs.overthewire.org", 5842 )
data=Array.new
s=0
4.times do
data = data + socket.recvfrom(4)
end
data.compact!
puts "complete string #{data.inspect}"
data.each { |x| s += x.unpack('L')[0] ; print x.unpack('L')[0], " " }
puts
socket.write s
puts socket.read
socket.close
And it do not solve the subject, please help me to understand where i's
my mistake.