Code:
using System; using System.Net; using System.Text.RegularExpressions; namespace reconnect { class MainClass { public static void Main (string[] args) { string address = null; Regex reg = new Regex (@"**External links are only visible to Support Staff**); if (reg.IsMatch (args[0])) { address = args[0]; } else { address = "**External links are only visible to Support Staff** + args[0]; } Router router = new Router (address); router.Terminate (); router.Reconnect (); } public class Router { private string address; private string data; private string reply; private WebClient client = new WebClient (); private Regex reg; private Match match; public Router (string address) { this.address = address; this.data = this.client.DownloadString (address); } public void Terminate () { this.reg = new Regex (@"<input type=\'hidden\' name=\'2\' value=\'(\d+)\'>"); this.match = reg.Match (data); string num = match.Groups[1].Value; string terminate = "0=13&1=INTERNET&2=" + num + "&5=2"; this.client.Headers.Add ("Content-Type", "application/x-www-form-urlencoded"); this.reply = client.UploadString (address, terminate); } public void Reconnect () { this.match = reg.Match (reply); string num = match.Groups[1].Value; string reconnect = "0=12&1=INTERNET&2=" + num + "&5=2"; this.client.Headers.Add ("Content-Type", "application/x-www-form-urlencoded"); this.reply = client.UploadString (address, reconnect); } } } }