Created
July 13, 2015 21:15
-
-
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)…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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