using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Net.Sockets; using System.Net; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string test; int test2 = 0; try { StreamReader hosts = new StreamReader(@"C:\windows\system32\drivers\etc\hosts"); while ((test = hosts.ReadLine()) != null) { if (test.Contains("audio-surf")) { test2 = 1; } } hosts.Close(); } catch (Exception exx) { Console.WriteLine("Couldn't open hosts file. Open this file in notepad:\n\nC:\\windows\\system32\\drivers\\etc\\hosts\n\nand make sure this line is somewhere in it:\n\n127.0.0.1 204.13.11.27\n\n"); } if (test2 != 1) { StreamWriter hostss = new StreamWriter(@"C:\windows\system32\drivers\etc\hosts",true); hostss.WriteLine(); hostss.WriteLine("127.0.0.1 204.13.11.27"); hostss.WriteLine("127.0.0.1 audio-surf.com"); hostss.WriteLine("127.0.0.1 www.audio-surf.com"); hostss.Close(); } String requestMessageLine; byte[] ip = { 127, 0, 0, 1 }; try { TcpListener testt = new TcpListener(new IPAddress(ip),80); testt.Start(); testt.Stop(); } catch (Exception exx) { Console.WriteLine("Couldn't open socket on port 80. Close any other web servers you may be running and try again."); Console.ReadLine(); return; } TcpListener tcpListener = new TcpListener(new IPAddress(ip), 80); tcpListener.Start(); Console.WriteLine("mothball presents Audiosurfboard v1.1. Direct any feedback to lime148@gmail.com"); Console.WriteLine("Usage notes:\n\n1. Don't bother trying to create an account. It won't work. To log in just enter anything in the username and password boxes."); Console.WriteLine("\nReady for connections. Run Audiosurf now."); Socket connectionSocket; while (true) { connectionSocket = tcpListener.AcceptSocket(); NetworkStream networkStream = new NetworkStream(connectionSocket); StreamWriter outTo = new StreamWriter(networkStream); StreamReader inFrom = new StreamReader(networkStream); try { if (connectionSocket.Connected) { Console.WriteLine("Client connected"); requestMessageLine = inFrom.ReadLine(); if (requestMessageLine != null) { if (requestMessageLine.Contains("whichpatch")) { outTo.Write("[app]\nversion = 1\n\n[launcher]\nversion = 1\n\n[paths]\nupdatepath=http://updates.audio-surf.com/patch_1_2.zip\nchecksum=3ea60e4e63421deefe5bffa9d7edf6f6"); Console.WriteLine("Sent version packet."); } if (requestMessageLine.Contains("Weekend")) { outTo.Write("goodtogo"); Console.WriteLine("Sent beta weekend packet."); } if (requestMessageLine.Contains("AttemptLogin4")) { outTo.Write("491HoopiUshu43"); Console.WriteLine("Sent login packet."); } } outTo.Flush(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); outTo.Write("HTTP/1.0 500 Internal Server Error\r\n"); outTo.Flush(); } inFrom.Close(); outTo.Close(); connectionSocket.Close(); networkStream.Close(); } } } }