public void CrackFirewall() { TerminalCore.PauseTerminal(0.3f); NetworkDevice device = TerminalNetwork.GetCurrentDevice(); NetworkFirewall wall = device.networkNode.FireWall; NetworkFirewall.FirewallLevel level = wall.GetNextClosedFirewall(); if (!IsCracked(level.CurrentGuess)) { int r = GetRandomLetter(level.CurrentGuess); char[] guess = new char[level.CurrentGuess.Length]; for (int i = 0; i < level.CurrentGuess.Length; i++) { if (i == r) { guess[i] = level.Password[i]; } else { guess[i] = level.CurrentGuess[i]; } } level.CurrentGuess = new string(guess); } consoleLine.ConsoleLine = "\t- Guess: " + TerminalColourScheme.FormatText(level.CurrentGuess, TerminalStyle.INFO); consoleLine = null; }
public void ModifyLevel(int level, bool open) { NetworkDevice device = TerminalNetwork.GetCurrentDevice(); NetworkFirewall wall = device.networkNode.FireWall; wall.Level[level].Unlocked = open; }
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); } }
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 "); } }
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); }
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."); } }
void OpenPort() { NetworkDevice device = TerminalNetwork.GetCurrentDevice(); TerminalCore.AddMessage("\t" + portToOpen + " - Access Granted."); device.networkNode.OpenPort(portToOpen); }
void Update() { if (lastDevice != TerminalNetwork.GetCurrentDevice()) { UpdateNodes(); } lastDevice = TerminalNetwork.GetCurrentDevice(); }
public void PrintUsage() { TerminalCore.AddMessage("\t Shell <cmd>:"); NetworkDevice device = TerminalNetwork.GetCurrentDevice(); foreach (string cmd in device.GetCommands()) { TerminalCore.AddMessage("\t -" + cmd); } }
public FSFile FindFile(string fileName) { string[] directoryPath = fileName.Split('/'); var fs = TerminalNetwork.GetCurrentDevice().GetComponent <FileSystem>(); FSDirectory current = fs.CurrentDirectory; if (directoryPath.Length == 0) { directoryPath = new string[] { fileName } } ; bool found = false; for (int i = 0; i < directoryPath.Length; i++) { if (i == directoryPath.Length - 1) { if (current.Files != null && current.Files.Count > 0) { FSFile file = current.Files.Single(a => a.Name.ToUpper() == directoryPath[i].ToUpper()); return(file); } } else { 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; } } } return(null); } }
private void PortHackCommand(string[] args) { if (args.Length == 0) { return; } int port = int.Parse(args[0]); portToOpen = port; NetworkDevice device = TerminalNetwork.GetCurrentDevice(); TerminalCore.AddLoadingBar(2f, OpenPort, "\n\tPort:" + port + " -", "-", "-", "-", "-", "-", "-", "-", "Cracked."); }
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); }
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 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 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>"); } }
void UpdateNodes() { GameObject current; List <NodeViewButton> RemovedDevices = new List <NodeViewButton>(); foreach (KeyValuePair <NetworkDevice, GameObject> pair in Devices) { if (pair.Key != TerminalNetwork.GetCurrentDevice()) { RemovedDevices.Add(pair.Value.GetComponent <NodeViewButton>()); //GameObject.Destroy(pair.Value); } } for (int i = 0; i < RemovedDevices.Count; i++) { RemovedDevices[i].Destroy(); } StartCoroutine(DoTransition(TerminalNetwork.GetCurrentDevice())); }
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 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 + "\""); } }
void Shell(string args) { NetworkDevice device = TerminalNetwork.GetCurrentDevice(); device.ProcessCommand(args); }
void Connect(string name) { TerminalNetwork.ConnectTo(TerminalNetwork.GetCurrentDevice().networkNode._nodes.Single(a => a.networkDevice.GetDeviceName().ToUpper() == name).networkDevice); }
void Disconnect() { TerminalNetwork.Disconnect(); Connect(name); }
public void Login(string password) { TerminalNetwork.GetCurrentDevice().networkNode.AttemptLogin(password); }
void PopulateNodes() { NetworkDevice currentDevice = TerminalNetwork.GetCurrentDevice(); GameObject current = Instantiate(NetworkNodeView); current.transform.parent = Holder; current.GetComponent <RectTransform>().localScale = Vector2.one; current.GetComponent <RectTransform>().localPosition = Vector2.one; //current.GetComponent<RectTransform>().anchoredPosition = Vector2.zero; //current.GetComponent<RectTransform>().position = Vector2.zero; Devices.Add(currentDevice, current); current.GetComponentInChildren <UnityEngine.UI.Text>().text = currentDevice.GetDeviceName(); for (int i = 0; i < currentDevice.networkNode._nodes.Count; i++) { var node = currentDevice.networkNode._nodes[i]; float spacing = 360f / (float)currentDevice.networkNode._nodes.Count; float x = UnityEngine.Random.Range(-300f, 300f); float y = UnityEngine.Random.Range(-300f, 300f); Vector2 pos = new Vector2(x, y); if (pos.magnitude < 100) { pos = pos.normalized * 100f; } GameObject go = Instantiate(NetworkNodeView); go.transform.parent = Holder; go.transform.localPosition = Vector2.zero; go.GetComponent <RectTransform>().anchoredPosition = (pos); go.GetComponent <RectTransform>().localScale = Vector2.one; UnityEngine.UI.Text text = go.GetComponentInChildren <UnityEngine.UI.Text>(); go.GetComponent <Animator>().Play("Intro"); text.text = currentDevice.networkNode._nodes[i].networkDevice.GetDeviceName(); go.GetComponent <NodeViewButton>().Device = currentDevice.networkNode._nodes[i].networkDevice; GameObject line = Instantiate(NetworkNodeLine); Lines.Add(currentDevice.networkNode._nodes[i].networkDevice, line); line.transform.parent = Holder; line.GetComponent <RectTransform>().anchoredPosition = (pos).normalized * 150; var lPos = line.GetComponent <RectTransform>().localPosition; lPos.z = 0f; line.GetComponent <RectTransform>().localPosition = lPos; line.GetComponent <RectTransform>().localScale = new Vector3(3f, 1f, 1f); Vector2 dir = pos; line.GetComponent <RectTransform>().right = (pos).normalized * 300f; line.GetComponent <RectTransform>().SetAsFirstSibling(); Devices.Add(currentDevice.networkNode._nodes[i].networkDevice, go); } current.GetComponent <RectTransform>().localPosition = Vector2.zero; current.GetComponent <RectTransform>().anchoredPosition = Vector2.zero; }
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 Update() { text.text = ""; Device = TerminalNetwork.GetCurrentDevice(); if (Device == null) { return; } NetworkNode node = Device.networkNode; AddText("Name: " + Device.GetDeviceName()); if (node == null) { return; } if (node.PasswordProtected) { AddText(TerminalColourScheme.FormatText("Password: Protected", TerminalStyle.DANGER)); } if (node.Ports.Count > 0) { AddText(TerminalColourScheme.FormatText("Ports:", TerminalStyle.INFO)); for (int i = 0; i < node.Ports.Count; i++) { string color = node.Ports[i].Open ? "<color=green><u><b>" : "<color=red>"; AddText("\t -" + node.Ports[i].portNumber + " : " + color + node.Ports[i].Open.ToString() + "</color></u></b>"); } } if (node.FireWall != null) { string s = TerminalColourScheme.FormatText("Firewall Detected!", TerminalStyle.DANGER); AddText(s); } else { string s = TerminalColourScheme.FormatText("No Firewall Detected.", TerminalStyle.INFO); AddText(s); } if (Device.DeviceCommands.Count > 0) { AddText(TerminalColourScheme.FormatText("CMDS:", TerminalStyle.INFO)); if (node.IsPortOpen(3389)) { for (int i = 0; i < Device.DeviceCommands.Count; i++) { Debug.Log(i); AddText("\t -" + Device.DeviceCommands[i].KeyWord); if (Device.DeviceCommands[i].SubCommands != null) { for (int j = 0; j < Device.DeviceCommands[i].SubCommands.Length; j++) { AddText("\t\t -<" + Device.DeviceCommands[i].SubCommands[j] + ">"); } } } } else { AddText(TerminalPresetMessages.PortsRestricted); } } AddText("<b><u> Details: </b></u>"); AddText(Device.GetData()); }
void Start() { lastDevice = TerminalNetwork.GetCurrentDevice(); PopulateNodes(); //centerPos = Holder.GetComponent<RectTransform>(). }