public IEnumerator DisplayMessage() { char[] split = bootingText.text.ToCharArray(); TerminalCore.PauseTerminal(5f); string[] sSplit = new string[split.Length]; for (int i = 0; i < split.Length; i++) { sSplit[i] = split[i].ToString(); } TerminalCore.AddLoadingBar(3f, null, sSplit); yield return(new WaitForSeconds(10f)); // TerminalCore.AddMessage("Clearing Terminal..."); // yield return new WaitForSeconds(0.1f); // TerminalCore.AddMessage("."); // yield return new WaitForSeconds(0.1f); // TerminalCore.AddMessage("."); // yield return new WaitForSeconds(0.1f); // TerminalCore.AddMessage("."); // yield return new WaitForSeconds(1f); // TerminalCore.ClearTerminal(); TerminalCore.AddMessage("System Ready"); }
public void AttemptSolve() { NetworkDevice device = TerminalNetwork.GetCurrentDevice(); NetworkFirewall wall = device.networkNode.FireWall; NetworkFirewall.FirewallLevel level = wall.GetNextClosedFirewall(); int levelIndex = wall.GetNextClosedFirewallIndex(); if (level.CurrentGuess == level.Password) { level.Unlocked = true; ModifyLevel(levelIndex, true); TerminalCore.AddMessage( string.Format("\t- Firewall Cracked:" + TerminalColourScheme.FormatText("{0}/{1}", TerminalStyle.INFO), wall.GetSolvedLevels(), wall.GetTotalLevels() )); if (wall.GetSolvedLevels() == wall.GetTotalLevels()) { TerminalCore.AddMessage(TerminalColourScheme.FormatText("\n\t- Firewall Broken.", TerminalStyle.WARNING) + TerminalColourScheme.FormatText("\n\tAccess Granted.", TerminalStyle.INFO)); } } else { TerminalUI.ForceInput("solve "); } }
public void SolveCommand(string[] args) { NetworkDevice device = TerminalNetwork.GetCurrentDevice(); NetworkFirewall wall = device.networkNode.FireWall; NetworkFirewall.FirewallLevel level = wall.GetNextClosedFirewall(); int levelIndex = wall.GetNextClosedFirewallIndex(); if (args.Length > 0) { if (args[0].ToUpper() == level.Password.ToUpper()) { TerminalCore.AddLoadingBar(0.5f, AttemptSolve, "\n\tAttempting Solution: " + level.Password, "\n\tSolution Accepted."); level.CurrentGuess = level.Password; return; } char guess = args[0].ToUpper()[0]; char[] CurrentGuess = level.CurrentGuess.ToCharArray(); for (int i = 0; i < level.Password.Length; i++) { if (level.Password.ToUpper()[i] == guess) { CurrentGuess[i] = level.Password[i]; } } level.CurrentGuess = new string(CurrentGuess); TerminalCore.AddMessage(""); string[] array = level.CurrentGuess.ToCharArray().Select(a => a.ToString()).ToArray(); array[0] = "\t - Guess: " + array[0]; TerminalCore.AddLoadingBar(0.5f, AttemptSolve, array); } }
private void CompleteConnection() { TerminalNetwork.ConnectTo(TerminalNetwork.GetCurrentDevice().networkNode._nodes.Single(a => a.networkDevice.GetDeviceName().ToUpper() == deviceName.ToUpper()).networkDevice); TerminalCore.AddMessage("<color=orange>Connected Established: " + TerminalNetwork.GetCurrentDevice().GetDeviceName() + "</color>"); Connect(deviceName); }
void OpenPort() { NetworkDevice device = TerminalNetwork.GetCurrentDevice(); TerminalCore.AddMessage("\t" + portToOpen + " - Access Granted."); device.networkNode.OpenPort(portToOpen); }
public void ListFiles(string[] args) { TerminalCore.AddMessage("LS"); string reason; if (!TerminalNetwork.GetCurrentDevice().networkNode.HasAccess(out reason)) { TerminalCore.AddMessage(TerminalColourScheme.FormatText(reason, TerminalStyle.DANGER)); return; } FileSystem fs = TerminalNetwork.GetCurrentDevice().GetComponent <FileSystem>(); bool hasFileSystem = fs != null; print("Has File System: " + hasFileSystem); if (hasFileSystem) { if (fs.HasPermission()) { PrintDirectory(fs.CurrentDirectory); } else { NotifyBlocked(); } } else { TerminalCore.AddLoadingBar(1.5f, null, "\nFile System: ", "Not Found."); } }
public void PrintUsage() { TerminalCore.AddMessage("\t Shell <cmd>:"); NetworkDevice device = TerminalNetwork.GetCurrentDevice(); foreach (string cmd in device.GetCommands()) { TerminalCore.AddMessage("\t -" + cmd); } }
public void PrintCommand(string[] args) { Debug.Log(args); for (int i = 0; i < args.Length; i++) { bool newLine = i == 0; TerminalCore.AddMessage(args[i] + " ", newLine); } }
public void AnalyzeCommand(string[] args) { NetworkDevice device = TerminalNetwork.GetCurrentDevice(); NetworkFirewall wall = device.networkNode.FireWall; if (wall == null) { TerminalCore.AddMessage("\t- " + TerminalColourScheme.FormatText("No Firewall Detected.", TerminalStyle.TEXT)); return; } NetworkFirewall.FirewallLevel level = wall.GetNextClosedFirewall(); consoleLine = TerminalCore.AddCachedMessage("\t- Guess: " + level.CurrentGuess); }
internal bool AttemptLogin(string v) { if (GetOpenPortCount() < RequiredPorts) { TerminalCore.AddMessage(TerminalColourScheme.FormatText("\t- Access Denied. Ports Blocked", TerminalStyle.DANGER)); return(false); } if (PasswordProtected && Password == v) { passwordLocked = false; return(true); } return(false); }
public void PrintDirectory(FSDirectory directory) //c/user/documents { string message = directory.Name; string preUnused = FileSystem.GetDirectoryPath(directory); int fileCount = directory.Files.Count; int dirCount = directory.Directories.Count; int totalCount = fileCount + dirCount; int totalFileCount = GetFilesInDirectory(directory).Count; int parentCount = FileSystem.GetParentCount(directory); if (totalFileCount > 0) { foreach (FSFile file in directory.Files) { string line = ""; for (int i = 0; i < parentCount; i++) { line += separator; } line += TerminalUI.ColorText(file.Name, fileColor); TerminalCore.AddMessage(line); } foreach (FSDirectory dir in directory.Directories) { if (GetFilesInDirectory(dir).Count > 0) { string line = ""; for (int i = 0; i < parentCount; i++) { line += separator; } line += TerminalUI.ColorText(dir.Name, folderColor); TerminalCore.AddMessage(line); PrintDirectory(dir); } } } /* * 0 - * 1 file - samel line * 1 folder - same line * file + folder - list */ return; }
public void PortQuery(string[] args) { var device = TerminalNetwork.GetCurrentDevice(); List <string> ports = new List <string>(); for (int j = 0; j < device.networkNode.Ports.Count; j++) { int portNumber = device.networkNode.Ports[j].portNumber; bool open = device.networkNode.Ports[j].Open; ports.Add(TerminalColourScheme.FormatText(portNumber.ToString().PadRight(3), TerminalStyle.INFO) + " - " + TerminalColourScheme.FormatText(open.ToString(), TerminalStyle.WARNING)); } for (int i = 0; i < ports.Count; i++) { string formatted = string.Format("\tPort: {0}", ports[i]); TerminalCore.AddMessage(formatted); } }
public void LoginCommand(string[] args) { if (args.Length == 0) { TerminalCore.AddMessage("\t- No password input."); return; } if (TerminalNetwork.GetCurrentDevice().networkNode.AttemptLogin(args[0])) { TerminalCore.AddMessage("\t- Login Successful."); Login(args[0]); } else { TerminalCore.AddMessage("\t- Login Failed."); } }
public void ConnectNetwork(string[] args) { if (TerminalNetwork.GetCurrentDevice().networkNode.FireWall != null) { if (!TerminalNetwork.GetCurrentDevice().networkNode.FireWall.IsOpen()) { TerminalCore.AddLoadingBar(0.1f, null, "\n \t - Attempting Connection...", "\n \t - Connection lost", TerminalColourScheme.FormatText("\n \t - Access Restricted - Firewall Detected", TerminalStyle.DANGER)); //TerminalCore.AddMessage("\t-Access Restricted - Firewall Detected"); return; } } TerminalCore.AddMessage("\n \t Connecting"); if (args.Length < 1) { TerminalCore.AddLoadingBar(0.2f, null, ".", ".", ".", " \t <color=orange>Device not found</color>"); return; } //Find Closest Match if (args[0].Contains("*")) { NetworkNode currentNode = TerminalNetwork.GetCurrentDevice().networkNode; List <NetworkNode> possibilities = currentNode._nodes.Where(a => a.networkDevice.GetDeviceName().ToUpper().StartsWith(args[0].ToUpper().Replace("*", ""))).ToList(); possibilities.Sort(); args[0] = possibilities[0].networkDevice.GetDeviceName(); } bool deviceFound = TerminalNetwork.GetCurrentDevice().networkNode._nodes.Any(a => a.networkDevice.GetDeviceName().ToUpper() == args[0].ToUpper()); if (deviceFound) { TerminalCore.AddLoadingBar(0.1f, AttemptConnection, ".", ".", "."); deviceName = args[0].ToUpper(); } else { TerminalCore.AddLoadingBar(1.5f, null, ".", ".", ".", " <color=orange>Device not found</color>"); } }
private void ContinueScanning() { if (TerminalNetwork.GetCurrentDevice().networkNode.FireWall != null) { if (!TerminalNetwork.GetCurrentDevice().networkNode.FireWall.IsOpen()) { TerminalCore.AddMessage(TerminalColourScheme.FormatText("\t-Access Restricted -Firewall Detected", TerminalStyle.DANGER)); return; } } for (int i = 0; i < TerminalNetwork.GetCurrentDevice().networkNode._nodes.Count; i++) { NetworkNode node = TerminalNetwork.GetCurrentDevice().networkNode._nodes[i]; string name = node.networkDevice.GetDeviceName(); string requiredPorts = node.RequiredPorts.ToString(); string unlocked = node.HasAccess().ToString().ToLowerInvariant(); string firewall = node.FireWall != null ? "\n\t\t- " + TerminalColourScheme.FormatText("Firewall detected", TerminalStyle.DANGER) : ""; unlocked = unlocked.ToLower(); TextInfo cultInfo = new CultureInfo("en-US", false).TextInfo; unlocked = cultInfo.ToTitleCase(unlocked); string password = node.PasswordProtected.ToString(); if (i != 0) { TerminalCore.AddMessage("\n"); } TerminalCore.AddMessage( string.Format("\t<color=#0087ff>{0}</color>\n\t\t- Ports Detected: {1}\n\t\t- Open: <b>{2}</b>\n\t\t{3}{4}", name, requiredPorts, unlocked, node.PasswordProtected ? "- <color=orange>Password Protected</color>" : "- <color=#0087ff>No Password</color>", firewall )); } }
public void Shell(string[] args) { NetworkDevice device = TerminalNetwork.GetCurrentDevice(); if (device == null) { return; } if (args.Length == 0) { TerminalCore.AddMessage("<color=#0087ff> Shell <cmd>:</color>"); foreach (string cmd in device.GetCommands()) { TerminalCore.AddMessage("\t-" + cmd); } } else { string inputString = args[0]; for (int i = 1; i < args.Length; i++) { inputString += " " + args[i]; } Command command = device.GetCommand(TerminalLogic.FindKeyword(inputString)); if (command != null) { TerminalCore.AddLoadingBar(0.4f, null, "\n\tSending Command.", "\n\tCommand Recieved"); Shell(inputString); } else { PrintUsage(); } } }
public void UnlockDoor(string[] args) { if (!HasPower && powerGrid != null) { return; } if (!networkNode.IsPortOpen(3389)) { TerminalCore.AddMessage(TerminalPresetMessages.PortsRestricted); return; } NotifySuccessful(); if (PanelIndicator != null) { PanelIndicator.material.color = Color.red; } IndicatorText.text = "HACK"; }
public void PrintCommand(string[] args) { string reason; if (!TerminalNetwork.GetCurrentDevice().networkNode.HasAccess(out reason)) { TerminalCore.AddMessage(TerminalColourScheme.FormatText(reason, TerminalStyle.DANGER)); return; } var fs = TerminalNetwork.GetCurrentDevice().GetComponent <FileSystem>(); if (fs != null && !fs.HasPermission()) { NotifyBlocked(); return; } string fileName = ""; for (int i = 0; i < args.Length; i++) { fileName += args[i]; if (i != args.Length - 1) { fileName += " "; } } FSFile file = FindFile(fileName); if (file != null) { string fileType = file.fileType.ToString(); TerminalCore.AddMessage("File:" + "\t" + file.Name + ": \n\tType: " + fileType + "\n\t\"" + file.Data + "\""); } }
public void ScanNetwork(string[] args) { TerminalCore.AddMessage("Scanning"); TerminalCore.AddLoadingBar(0.5f, ContinueScanning, ".", ".", "."); }
public void ChangeDirectory(string[] args) { string reason; if (!TerminalNetwork.GetCurrentDevice().networkNode.HasAccess(out reason)) { TerminalCore.AddMessage(TerminalColourScheme.FormatText(reason, TerminalStyle.DANGER)); return; } FileSystem deviceFileSystem = TerminalNetwork.GetCurrentDevice().GetComponent <FileSystem>(); if (deviceFileSystem != null && !deviceFileSystem.HasPermission()) { NotifyBlocked(); return; } TerminalCore.AddMessage("Changing Directory: \t" + args[0]); FSDirectory current = deviceFileSystem.CurrentDirectory; if (args[0] == "..") { if (deviceFileSystem.CurrentDirectory.Parent == null) { return; } deviceFileSystem.CurrentDirectory = deviceFileSystem.CurrentDirectory.Parent; TerminalCore.AddMessage("\tCD " + deviceFileSystem.CurrentDirectory.Name); return; } string[] directoryPath = args[0].Split('/'); if (directoryPath.Length == 0) { directoryPath = new string[] { args[0] } } ; bool found = false; for (int i = 0; i < directoryPath.Length; i++) { bool f = false; directoryPath[i] = directoryPath[i].Replace("/", ""); foreach (FSDirectory dir in current.Directories) { if (dir.Name.ToUpper() == directoryPath[i].ToUpper()) { current = dir; if (i == directoryPath.Length) { found = true; } f = true; break; } } if (!f) { break; } } deviceFileSystem.CurrentDirectory = current; if (!found) { TerminalCore.AddMessage("\tCD <color=orange>" + deviceFileSystem.CurrentDirectory.Name.ToUpper() + "</color>"); } else { TerminalCore.AddMessage("\t<color=orange>Directory not found.</color>"); } }
public void NotifyBlocked() { TerminalCore.AddMessage(TerminalColourScheme.FormatText("Access Blocked. Port 255 locked", TerminalStyle.DANGER)); }