Skip to content

Instantly share code, notes, and snippets.

@qubbit
Created July 13, 2015 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qubbit/f7acdc9f0beaff62cf71 to your computer and use it in GitHub Desktop.
Save qubbit/f7acdc9f0beaff62cf71 to your computer and use it in GitHub Desktop.
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 vortex1. This information can be used to log in using SSH. Note: vortex is on an 32bit x86 machine (meaning, a little endian architecture)…
using System;
using System.Text;
using System.Net.Sockets;
namespace WG
{
class Program
{
static void Main(string[] args)
{
TcpClient client = new TcpClient();
client.Connect("vortex.labs.overthewire.org", 5842);
NetworkStream stream = client.GetStream();
int i = 0;
uint sum = 0;
while (i++ < 4)
{
byte[] buff = new byte[sizeof(uint)];
stream.Read(buff, 0, buff.Length);
// data already comes in little endian, so don't
// need to check for that
uint num = BitConverter.ToUInt32(buff, 0);
sum += num;
}
byte[] snd = BitConverter.GetBytes(sum);
stream.Write(snd, 0, snd.Length);
byte[] authBytes = new byte[512];
stream.Read(authBytes, 0, authBytes.Length);
Console.WriteLine(Encoding.ASCII.GetString(authBytes));
stream.Close();
client.Close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment