Skip to content

Instantly share code, notes, and snippets.

@plvhx
Last active December 22, 2016 12:53
Show Gist options
  • Save plvhx/4bb3c8fe184d90530fc855720f3dffc3 to your computer and use it in GitHub Desktop.
Save plvhx/4bb3c8fe184d90530fc855720f3dffc3 to your computer and use it in GitHub Desktop.
overthewire vortex level0
#! /usr/bin/python -W ignore::DeprecationWarning

# tesla_ ([email protected])

import sys
import struct
import socket
import telnetlib

try:
    s = socket.create_connection(("vortex.labs.overthewire.org", 5842))
except socket.gaierror as e:
    (n, q) = e
    
    sys.exit(-1)
    
tuple = []

try:
    for i in range(0, 4):
        tuple.append(struct.unpack("<I", s.recv(4))[0])
except socket.error as e:
    (n, q) = e
    
    sys.exit(-1)
    
try:
    s.send(struct.pack("<I", reduce(lambda x,y: x + y, tuple)))
except socket.error as e:
    (n, q) = e
    
    sys.exit(-1)
    
t = telnetlib.Telnet()
t.sock = s
t.interact()

s.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment