private static void executeThreadedScript(string[] script, OS os) { var nullable = new KeyValuePair <string, string>?(); var flag1 = false; var target = os.thisComputer; Computer source = null; var timeout = TimeSpan.FromSeconds(0.5); for (var index = 0; index < script.Length; ++index) { if (source != null && source.disabled) { Multiplayer.parseInputMessage(getBasicNetworkCommand("cDisconnect", target, source), os); Console.WriteLine("Early Script Exit on Source Disable"); return; } var strArray = script[index].Split(Utils.spaceDelim, StringSplitOptions.RemoveEmptyEntries); var flag2 = true; switch (strArray[0]) { case "config": target = (Computer)ComputerLoader.findComputer(strArray[1]); source = (Computer)ComputerLoader.findComputer(strArray[2]); timeout = TimeSpan.FromSeconds(Convert.ToDouble(strArray[3])); flag2 = false; nullable = new KeyValuePair <string, string>(source.ip, target.ip); os.ActiveHackers.Add(nullable.Value); break; case "delay": Thread.Sleep(TimeSpan.FromSeconds(Convert.ToDouble(strArray[1]))); break; case "connect": Multiplayer.parseInputMessage(getBasicNetworkCommand("cConnection", target, source), os); break; case "openPort": Multiplayer.parseInputMessage( getBasicNetworkCommand("cPortOpen", target, source) + " " + strArray[1], os); break; case "delete": var pathString = getPathString(strArray[1], os, target.files.root); Multiplayer.parseInputMessage( "cDelete #" + target.ip + "#" + source.ip + "#" + strArray[2] + pathString, os); break; case "reboot": os.runCommand("reboot"); break; case "forkbomb": Multiplayer.parseInputMessage(getBasicNetworkCommand("eForkBomb", target, source), os); break; case "disconnect": Multiplayer.parseInputMessage(getBasicNetworkCommand("cDisconnect", target, source), os); break; } try { if (flag2) { if (!os.thisComputer.disabled) { os.beepSound.Play(); if (!flag1) { os.IncConnectionOverlay.Activate(); flag1 = true; } } } } catch { return; } Thread.Sleep(timeout); } if (!nullable.HasValue) { return; } os.ActiveHackers.Remove(nullable.Value); }
public static void parseInputMessage(string message, OS os) { if (message.Equals("")) { return; } string[] strArray1 = message.Split(Multiplayer.delims); if (strArray1.Length == 0) { return; } if (os.thisComputer != null && os.thisComputer.ip.Equals(strArray1[1])) { os.warningFlash(); } if (strArray1[0].Equals("init")) { int int32 = Convert.ToInt32(strArray1[1]); Utils.random = new Random(int32); os.canRunContent = true; os.LoadContent(); os.write("Seed Established :" + (object)int32); } else if (strArray1[0].Equals("chat")) { string s = ""; for (int index = 2; index < strArray1.Length; ++index) { s = s + strArray1[index] + " "; } os.write(strArray1[1] + ": " + DisplayModule.splitForWidth(s, 350)); } else if (strArray1[0].Equals("clientConnect")) { os.write("Connection Established"); } else if (strArray1[0].Equals("cConnection")) { Computer comp = Multiplayer.getComp(strArray1[1], os); if (comp == null) { os.write("Error in Message : " + message); } else { comp.silent = true; comp.connect(strArray1[2]); comp.silent = false; os.opponentLocation = strArray1[1]; } } else if (strArray1[0].Equals("cDisconnect")) { Computer comp = Multiplayer.getComp(strArray1[1], os); comp.silent = true; comp.disconnecting(strArray1[2], true); comp.silent = false; os.opponentLocation = ""; } else if (strArray1[0].Equals("cAdmin")) { Computer comp = Multiplayer.getComp(strArray1[1], os); comp.silent = true; comp.giveAdmin(strArray1[2]); comp.silent = false; } else if (strArray1[0].Equals("cPortOpen")) { Computer comp = Multiplayer.getComp(strArray1[1], os); comp.silent = true; comp.openPort(Convert.ToInt32(strArray1[3]), strArray1[2]); comp.silent = false; } else if (strArray1[0].Equals("cPortClose")) { Computer comp = Multiplayer.getComp(strArray1[1], os); comp.silent = true; comp.closePort(Convert.ToInt32(strArray1[3]), strArray1[2]); comp.silent = false; } else if (strArray1[0].Equals("cFile")) { Computer comp = Multiplayer.getComp(strArray1[1], os); comp.silent = true; FileEntry f = new FileEntry("", strArray1[3]); comp.canReadFile(strArray1[2], f, Convert.ToInt32(strArray1[4])); comp.silent = false; } else if (strArray1[0].Equals("newComp")) { string[] strArray2 = message.Split(Multiplayer.specSplitDelims); Vector2 compLocation = new Vector2((float)Convert.ToInt32(strArray2[2]), (float)Convert.ToInt32(strArray2[3])); Computer computer = new Computer(strArray2[5], strArray2[1], compLocation, Convert.ToInt32(strArray2[4]), (byte)1, os); computer.idName = "opponent#" + (object)Multiplayer.generatedComputerCount; ++Multiplayer.generatedComputerCount; computer.addMultiplayerTargetFile(); os.netMap.nodes.Add(computer); os.opponentComputer = computer; } else if (strArray1[0].Equals("cDelete")) { string[] strArray2 = message.Split(Multiplayer.specSplitDelims); Computer comp = Multiplayer.getComp(strArray2[1], os); List <int> folderPath = new List <int>(); for (int index = 4; index < strArray2.Length; ++index) { if (strArray2[index] != "") { folderPath.Add(Convert.ToInt32(strArray2[index])); } } comp.silent = true; comp.deleteFile(strArray2[2], strArray2[3], folderPath); comp.silent = false; } else if (strArray1[0].Equals("cMake")) { string[] strArray2 = message.Split(Multiplayer.specSplitDelims); Computer comp = Multiplayer.getComp(strArray2[1], os); List <int> folderPath = new List <int>(); for (int index = 4; index < strArray2.Length; ++index) { if (strArray2[index] != "") { folderPath.Add(Convert.ToInt32(strArray2[index])); } } comp.silent = true; comp.makeFile(strArray2[2], strArray2[3], strArray2[4], folderPath, false); comp.silent = false; } else if (strArray1[0].Equals("cMove")) { string[] strArray2 = message.Split(Multiplayer.specSplitDelims); Computer comp = Multiplayer.getComp(strArray2[1], os); char[] separator = new char[1] { '%' }; List <int> folderPath = new List <int>(); string[] strArray3 = strArray2[5].Split(separator, 500, StringSplitOptions.RemoveEmptyEntries); for (int index = 0; index < strArray3.Length; ++index) { if (strArray2[index] != "") { folderPath.Add(Convert.ToInt32(strArray2[index])); } } List <int> destFolderPath = new List <int>(); string[] strArray4 = strArray2[6].Split(separator, 500, StringSplitOptions.RemoveEmptyEntries); for (int index = 0; index < strArray4.Length; ++index) { if (strArray2[index] != "") { destFolderPath.Add(Convert.ToInt32(strArray2[index])); } } comp.silent = true; comp.moveFile(strArray2[2], strArray2[3], strArray2[4], folderPath, destFolderPath); comp.silent = false; } else if (strArray1[0].Equals("cMkDir")) { string[] strArray2 = message.Split(Multiplayer.specSplitDelims); Computer comp = Multiplayer.getComp(strArray2[1], os); List <int> folderPath = new List <int>(); for (int index = 4; index < strArray2.Length; ++index) { if (strArray2[index] != "") { folderPath.Add(Convert.ToInt32(strArray2[index])); } } comp.silent = true; comp.makeFolder(strArray2[2], strArray2[3], folderPath); comp.silent = false; } else if (strArray1[0].Equals("cAddUser")) { string[] strArray2 = message.Split(Multiplayer.specSplitDelims); Computer comp = Multiplayer.getComp(strArray2[1], os); string name = strArray2[3]; string pass = strArray2[4]; byte type = Convert.ToByte(strArray2[5]); comp.silent = true; comp.addNewUser(strArray2[2], name, pass, type); comp.silent = false; } else if (strArray1[0].Equals("cCopy")) { Computer comp = Multiplayer.getComp(strArray1[1], os); comp.silent = true; comp.canCopyFile(strArray1[2], strArray1[3]); comp.silent = false; FileEntry fileEntry1 = (FileEntry)null; for (int index = 0; index < comp.files.root.folders[2].files.Count; ++index) { if (comp.files.root.folders[2].files[index].name.Equals(strArray1[3])) { fileEntry1 = comp.files.root.folders[2].files[index]; } } FileEntry fileEntry2 = new FileEntry(fileEntry1.data, fileEntry1.name); Multiplayer.getComp(strArray1[2], os).files.root.folders[2].files.Add(fileEntry2); } else if (strArray1[0].Equals("cCDDrive")) { Computer comp = Multiplayer.getComp(strArray1[1], os); comp.silent = true; if (strArray1[2].Equals("open")) { comp.openCDTray(strArray1[1]); } else { comp.closeCDTray(strArray1[1]); } comp.silent = false; } else if (strArray1[0].Equals("cCrash")) { Computer comp = Multiplayer.getComp(strArray1[1], os); comp.silent = true; comp.crash(strArray1[2]); comp.silent = false; } else if (strArray1[0].Equals("cReboot")) { Computer comp = Multiplayer.getComp(strArray1[1], os); comp.silent = true; comp.reboot(strArray1[2]); comp.silent = false; } else if (strArray1[0].Equals("cFBClients")) { Computer comp = Multiplayer.getComp(strArray1[1], os); if (os.connectedComp != null && os.connectedComp.ip.Equals(strArray1[1])) { os.exes.Add((ExeModule) new ForkBombExe(os.getExeBounds(), os)); } comp.silent = true; comp.forkBombClients(strArray1[2]); comp.silent = false; } else if (strArray1[0].Equals("eForkBomb")) { if (!os.thisComputer.ip.Equals(strArray1[1])) { return; } ForkBombExe forkBombExe = new ForkBombExe(os.getExeBounds(), os); forkBombExe.LoadContent(); os.exes.Add((ExeModule)forkBombExe); } else if (strArray1[0].Equals("mpOpponentWin")) { os.endMultiplayerMatch(false); } else { if (strArray1[0].Equals("stayAlive")) { return; } os.write("MSG: " + message); } }
private static void executeThreadedScript(string[] script, OS os) { KeyValuePair <string, string>?nullable = new KeyValuePair <string, string>?(); bool flag1 = false; Computer target = os.thisComputer; Computer source = (Computer)null; TimeSpan timeout = TimeSpan.FromSeconds(0.5); for (int index1 = 0; index1 < script.Length; ++index1) { if (source != null && source.disabled) { Multiplayer.parseInputMessage(HackerScriptExecuter.getBasicNetworkCommand("cDisconnect", target, source), os); Console.WriteLine("Early Script Exit on Source Disable"); return; } if (!string.IsNullOrWhiteSpace(script[index1])) { string[] strArray = script[index1].Trim().Split(Utils.spaceDelim, StringSplitOptions.RemoveEmptyEntries); CultureInfo cultureInfo = new CultureInfo("en-au"); bool flag2 = target == os.thisComputer; try { switch (strArray[0]) { case "config": target = Programs.getComputer(os, strArray[1]); if (target == null) { if (!OS.DEBUG_COMMANDS) { return; } os.write(" "); os.write("Error: "); os.write("Hack Script target " + strArray[1] + " not found! Aborting."); os.write("This error will not show up if debug commands are disabled."); os.write(" "); return; } source = Programs.getComputer(os, strArray[2]); if (source == null) { if (!OS.DEBUG_COMMANDS) { return; } os.write(" "); os.write("Error: "); os.write("Hack Script source " + strArray[2] + " not found! Aborting."); os.write("This error will not show up if debug commands are disabled."); os.write(" "); return; } timeout = TimeSpan.FromSeconds(Convert.ToDouble(strArray[3], (IFormatProvider)cultureInfo)); flag2 = false; nullable = new KeyValuePair <string, string>?(new KeyValuePair <string, string>(source.ip, target.ip)); os.ActiveHackers.Add(nullable.Value); break; case "delay": if (!OS.TestingPassOnly) { Thread.Sleep(TimeSpan.FromSeconds(Convert.ToDouble(strArray[1], (IFormatProvider)cultureInfo))); } flag2 = false; break; case "connect": Multiplayer.parseInputMessage(HackerScriptExecuter.getBasicNetworkCommand("cConnection", target, source), os); if (!flag1 && target.ip == os.thisComputer.ip) { os.IncConnectionOverlay.Activate(); flag1 = true; break; } break; case "openPort": Multiplayer.parseInputMessage(HackerScriptExecuter.getBasicNetworkCommand("cPortOpen", target, source) + " " + strArray[1], os); break; case "delete": string pathString = HackerScriptExecuter.getPathString(strArray[1], os, target.files.root); Multiplayer.parseInputMessage("cDelete #" + target.ip + "#" + source.ip + "#" + strArray[2] + pathString, os); break; case "reboot": if (target == os.thisComputer) { if (os.connectedComp == null || os.connectedComp == os.thisComputer) { os.runCommand("reboot"); break; } os.rebootThisComputer(); break; } target.reboot(source.ip); break; case "forkbomb": Multiplayer.parseInputMessage(HackerScriptExecuter.getBasicNetworkCommand("eForkBomb", target, source), os); break; case "disconnect": target.disconnecting(source.ip, true); break; case "systakeover": HostileHackerBreakinSequence.Execute((object)os, source, target); break; case "clearTerminal": if (target == os.thisComputer) { os.terminal.reset(); break; } break; case "write": string str1 = ""; for (int index2 = 1; index2 < strArray.Length; ++index2) { str1 = str1 + strArray[index2] + " "; } string str2 = ComputerLoader.filter(str1.Trim()); if (target == os.thisComputer) { os.terminal.write(" " + str2); os.warningFlash(); break; } break; case "write_silent": string str3 = ""; for (int index2 = 1; index2 < strArray.Length; ++index2) { str3 = str3 + strArray[index2] + " "; } string str4 = ComputerLoader.filter(str3.Trim()); if (target == os.thisComputer) { os.terminal.write(" " + str4); } flag2 = false; break; case "writel": string str5 = ""; for (int index2 = 1; index2 < strArray.Length; ++index2) { str5 = str5 + strArray[index2] + " "; } string text1 = ComputerLoader.filter(str5.Trim()); if (string.IsNullOrWhiteSpace(text1)) { flag2 = false; } if (target == os.thisComputer) { os.terminal.writeLine(text1); os.warningFlash(); break; } break; case "writel_silent": string str6 = ""; for (int index2 = 1; index2 < strArray.Length; ++index2) { str6 = str6 + strArray[index2] + " "; } string text2 = ComputerLoader.filter(str6.Trim()); if (string.IsNullOrWhiteSpace(text2)) { flag2 = false; } if (target == os.thisComputer) { os.terminal.writeLine(text2); } flag2 = false; break; case "hideNetMap": if (target == os.thisComputer) { os.netMap.visible = false; break; } break; case "hideRam": if (target == os.thisComputer) { os.ram.visible = false; break; } break; case "hideDisplay": if (target == os.thisComputer) { os.display.visible = false; break; } break; case "hideTerminal": if (target == os.thisComputer) { os.terminal.visible = false; break; } break; case "showNetMap": if (target == os.thisComputer) { os.netMap.visible = true; break; } break; case "showRam": if (target == os.thisComputer) { os.ram.visible = true; break; } break; case "showTerminal": if (target == os.thisComputer) { os.terminal.visible = true; break; } break; case "showDisplay": if (target == os.thisComputer) { os.display.visible = true; break; } break; case "stopMusic": flag2 = false; if (target == os.thisComputer) { if (HackerScriptExecuter.MusicStopSFX == null) { HackerScriptExecuter.MusicStopSFX = !DLC1SessionUpgrader.HasDLC1Installed ? os.content.Load <SoundEffect>("SFX/MeltImpact") : os.content.Load <SoundEffect>("DLC/SFX/GlassBreak"); } MusicManager.stop(); if (HackerScriptExecuter.MusicStopSFX != null) { HackerScriptExecuter.MusicStopSFX.Play(); } break; } break; case "startMusic": flag2 = false; if (!OS.TestingPassOnly) { if (target == os.thisComputer) { MusicManager.playSong(); } break; } break; case "trackseq": try { if (target == os.thisComputer) { TrackerCompleteSequence.FlagNextForkbombCompletionToTrace(source != null ? source.ip : (string)null); break; } break; } catch (Exception ex) { os.write(Utils.GenerateReportFromExceptionCompact(ex)); break; } case "instanttrace": if (target == os.thisComputer) { TrackerCompleteSequence.TriggerETAS((object)os); break; } break; case "flash": if (!OS.TestingPassOnly) { if (target == os.thisComputer) { os.warningFlash(); } break; } break; case "openCDTray": if (!OS.TestingPassOnly) { if (target == os.thisComputer) { target.openCDTray(source.ip); } break; } break; case "closeCDTray": if (!OS.TestingPassOnly) { if (target == os.thisComputer) { target.closeCDTray(source.ip); } break; } break; case "setAdminPass": target.setAdminPassword(strArray[1]); break; case "makeFile": string folderName = strArray[1]; StringBuilder stringBuilder = new StringBuilder(); for (int index2 = 3; index2 < strArray.Length; ++index2) { stringBuilder.Append(strArray[index2]); if (index2 + 1 < strArray.Length) { stringBuilder.Append(" "); } } Folder folder = target.files.root.searchForFolder(folderName); List <int> folderPath = new List <int>(); if (folder == null) { folderPath.Add(0); } else { folderPath.Add(target.files.root.folders.IndexOf(folder)); } target.makeFile(source.ip, strArray[2], ComputerLoader.filter(stringBuilder.ToString()), folderPath, true); break; } } catch (Exception ex) { if (OS.TestingPassOnly) { throw new FormatException("Error Parsing command " + strArray[0] + " in HackerScript:", ex); } if (OS.DEBUG_COMMANDS) { os.terminal.write(Utils.GenerateReportFromException(ex)); os.write("HackScript error: " + strArray[0]); os.write("Report written to Warnings file"); Utils.AppendToWarningsFile(Utils.GenerateReportFromException(ex)); } } try { if (flag2 && !os.thisComputer.disabled) { if (!OS.TestingPassOnly) { os.beepSound.Play(); } } } catch (Exception ex) { os.terminal.write(Utils.GenerateReportFromException(ex)); Utils.AppendToErrorFile(Utils.GenerateReportFromException(ex)); return; } if (!OS.TestingPassOnly) { Thread.Sleep(timeout); } } } if (!nullable.HasValue) { return; } os.ActiveHackers.Remove(nullable.Value); }