Ejemplo n.º 1
0
    void OpenPort()
    {
        NetworkDevice device = TerminalNetwork.GetCurrentDevice();

        TerminalCore.AddMessage("\t" + portToOpen + " - Access Granted.");
        device.networkNode.OpenPort(portToOpen);
    }
Ejemplo n.º 2
0
    public void Start()
    {
        Command shell = new Command("Shell");

        shell.OnProcessCommand += Shell;
        TerminalCore.RegisterCommand(shell);
    }
Ejemplo n.º 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.");
        }
    }
Ejemplo n.º 4
0
    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);
        }
    }
Ejemplo n.º 5
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 ");
        }
    }
Ejemplo n.º 6
0
    public string AttemptAutoComplete(string input)
    {
        string[] matches = TerminalCore.GetClosestMatches(input, AutoCompleteList.ToArray());

        if (matches.Length == 1)
        {
            return(matches[0]);
        }
        else
        {
            int printPerLine = 5;
            for (int i = 0; i < matches.Length; i += printPerLine)
            {
                string message = matches[i];
                for (int j = 1; j < printPerLine; j++)
                {
                    if (i + j < matches.Length)
                    {
                        message += "          |        " + matches[i + j];
                    }
                }


                //TerminalCore.AddMessage(message);
            }

            return(matches[0]);
        }

        return(null);
    }
Ejemplo n.º 7
0
    public void OnInputRecieved(string input)
    {
        //inputQueue.Enqueue(input);

        if (input != null && input != "")
        {
            Command command = TerminalCore.GetCommand(FindKeyword(input));
            if (command != null)
            {
                TerminalUI.usedCommandIndex = -1;
                TerminalUI.usedCommands.Push(input);
            }
        }

        if (pauseTimer > 0)
        {
            inputQueue.Enqueue(input);
            return;
        }

        if (inputQueue.Count > 0)
        {
            inputQueue.Enqueue(input);
            return;
        }

        ProcessCommand(input);
    }
Ejemplo n.º 8
0
    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");
    }
Ejemplo n.º 9
0
    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);
    }
Ejemplo n.º 10
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;
    }
Ejemplo n.º 11
0
    public void PrintUsage()
    {
        TerminalCore.AddMessage("\t Shell <cmd>:");
        NetworkDevice device = TerminalNetwork.GetCurrentDevice();

        foreach (string cmd in device.GetCommands())
        {
            TerminalCore.AddMessage("\t -" + cmd);
        }
    }
Ejemplo n.º 12
0
    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);
        }
    }
Ejemplo n.º 13
0
    public void Start()
    {
        Command analzye = new Command("analyze");

        analzye.OnProcessCommand += AnalyzeCommand;
        TerminalCore.RegisterCommand(analzye);

        Command solve = new Command("solve");

        solve.OnProcessCommand += SolveCommand;
        TerminalCore.RegisterCommand(solve);
    }
Ejemplo n.º 14
0
    private void Start()
    {
        Command echoCommand = new Command("Echo");

        echoCommand.OnProcessCommand += PrintCommand;
        TerminalCore.RegisterCommand(echoCommand);

        Command clearCommand = new Command("Clear");

        clearCommand.OnProcessCommand += ClearConsole;
        TerminalCore.RegisterCommand(clearCommand);
    }
Ejemplo n.º 15
0
    public void Start()
    {
        Command portQuery = new Command("PortQuery");

        portQuery.OnProcessCommand += PortQuery;
        TerminalCore.RegisterCommand(portQuery);

        Command porthack = new Command("porthack");

        porthack.OnProcessCommand += PortHackCommand;
        TerminalCore.RegisterCommand(porthack);
    }
Ejemplo n.º 16
0
    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.");
    }
Ejemplo n.º 17
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);
    }
Ejemplo n.º 18
0
    private IEnumerator DisconnectAnim()
    {
        CachedConsoleLine line = TerminalCore.AddCachedMessage("DC");

        yield return(new WaitForSeconds(0.3f));

        line.ConsoleLine = "<color=orange>Disconnecting...</color >";
        Disconnect();
        yield return(new WaitForSeconds(0.3f));

        line.ConsoleLine = "Establishing Connection...";
        yield return(new WaitForSeconds(0.3f));

        line.ConsoleLine = "Connected To Host.";
    }
Ejemplo n.º 19
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);
    }
Ejemplo n.º 20
0
    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;
    }
Ejemplo n.º 21
0
    public void Start()
    {
        Command ls = new Command("ls");

        ls.OnProcessCommand += ListFiles;
        TerminalCore.RegisterCommand(ls);

        Command cd = new Command("cd");

        cd.OnProcessCommand += ChangeDirectory;
        TerminalCore.RegisterCommand(cd);

        Command print = new Command("print");

        print.OnProcessCommand += PrintCommand;
        TerminalCore.RegisterCommand(print);
    }
Ejemplo n.º 22
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);
        }
    }
Ejemplo n.º 23
0
    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.");
        }
    }
Ejemplo n.º 24
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>");
        }
    }
Ejemplo n.º 25
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
                              ));
        }
    }
Ejemplo n.º 26
0
    public void Start()
    {
        Command command = new Command("Scan");

        command.OnProcessCommand += ScanNetwork;
        TerminalCore.RegisterCommand(command);

        Command connect = new Command("Connect");

        connect.OnProcessCommand += ConnectNetwork;
        TerminalCore.RegisterCommand(connect);

        Command disconnect = new Command("dc");

        disconnect.OnProcessCommand += Disconnect;
        TerminalCore.RegisterCommand(disconnect);

        Command login = new Command("login");

        login.OnProcessCommand += LoginCommand;
        TerminalCore.RegisterCommand(login);
    }
Ejemplo n.º 27
0
    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();
            }
        }
    }
Ejemplo n.º 28
0
    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";
    }
Ejemplo n.º 29
0
    void ProcessCommand(string input)
    {
        //storing commands, for up/down recall


        Command command = TerminalCore.GetCommand(FindKeyword(input));

        string[]      args = GetArgs(input);
        List <string> lst  = args.ToList();

        lst.RemoveAt(0);
        args = lst.ToArray();

        Debug.Log(input);
        if (command != null)
        {
            if (command.OnProcessCommand != null)
            {
                command.OnProcessCommand(args);
            }
        }
    }
Ejemplo n.º 30
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 + "\"");
        }
    }
Ejemplo n.º 31
0
 public TerminalHub(TerminalCore terminalCore)
 {
     _terminalCore = terminalCore;
 }