We have to
- connect to port 5842 of vortex.labs.overthewire.org
- read 4 integer numbers (4 byte each) in host byte order (i.e. little endian)
- Sum this numbers
- send it back (in the same host byte order
- read the reply that contains username and password
I'm a bit ashamed publishing this code cause it's badly written, but it took me short time and it works.
#!/usr/bin/env python3 import socket HOST = '176.9.9.172' PORT = 5842 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT)) data = s.recv(16) print('Received', repr(data)) num1=data[0]+ data[1]*256 + data[2]*256*256 + data[3]*256*256*256 num2=data[4]+ data[5]*256 + data[6]*256*256 + data[7]*256*256*256 num3=data[8]+ data[9]*256 + data[10]*256*256 + data[11]*256*256*256 num4=data[12]+ data[13]*256 + data[14]*256*256 + data[15]*256*256*256 total=num1+num2+num3+num4 byte1= total // (256*256*256) reminder1= total % (256*256*256) byte2= reminder1 // (256*256) reminder2= reminder1 % (256*256) byte3= reminder2 // (256) byte4= reminder2 % (256) reply=[byte4,byte3,byte2,byte1] reply2=bytes(reply) s.sendall(reply2) data=s.recv(128) print('Received', data)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.