Пример #1
0
    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 ");
        }
    }
Пример #2
0
    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;
    }
Пример #3
0
    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.");
        }
    }
Пример #4
0
    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);
    }
Пример #5
0
    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);
    }
Пример #6
0
    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);
        }
    }
Пример #7
0
    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>");
        }
    }
Пример #8
0
    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
                              ));
        }
    }
Пример #9
0
    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 + "\"");
        }
    }
Пример #10
0
    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());
    }
Пример #11
0
 public void NotifyBlocked()
 {
     TerminalCore.AddMessage(TerminalColourScheme.FormatText("Access Blocked. Port 255 locked", TerminalStyle.DANGER));
 }
Пример #12
0
    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>");
        }
    }