public override void OnCmdMatch()
    {
        var    cmd        = _cmd.Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
        string arg        = cmd[1];
        var    query_item = TerminalHandler.Instance.VirtualFileSystem.Query(arg);

        if (query_item != null)
        {
            if (query_item.type == "directory")
            {
                TerminalHandler.Instance.DisplayOutput("ERROR: The file " + arg + " is a directory");
            }
            else
            {
                if (!TerminalHandler.Instance.CheckPermissions(query_item, "r--"))
                {
                    TerminalHandler.Instance.DisplayOutput("ERROR: Permission denied");
                    return;
                }
                if (query_item.name == _targetImgName)
                {
                    OfficeServerRoomHandler.ShowImg();
                    TerminalHandler.Instance.InstantiateNewLine();
                }
                else
                {
                    TerminalHandler.Instance.DisplayOutput("ERROR: File " + arg + " cannot be opened as an image");
                }
            }
        }
        else
        {
            TerminalHandler.Instance.DisplayOutput("ERROR: File " + arg + " not found");
        }
    }
Exemplo n.º 2
0
    public override void OnCmdMatch()
    {
        var    cmd = _cmd.Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
        string arg = cmd[1];

        var query_item = TerminalHandler.Instance.VirtualFileSystem.Query(arg);

        if (query_item != null)
        {
            if (query_item.type == "directory")
            {
                TerminalHandler.Instance.DisplayOutput("ERROR: The file " + arg + " is a directory");
            }
            else
            {
                if (!TerminalHandler.Instance.CheckPermissions(query_item, "r--"))
                {
                    TerminalHandler.Instance.DisplayOutput("ERROR: Permission denied");
                    return;
                }
                if (query_item.name == "wh1t3_l1ly.jpg")
                {
                    OfficeServerRoomHandler.ExtractHiddenFolder();
                }
                else
                {
                    TerminalHandler.Instance.DisplayOutput("ERROR: file is not a ZIP archive");
                }
            }
        }
        else
        {
            TerminalHandler.Instance.DisplayOutput("ERROR: File " + arg + " not found");
        }
    }
Exemplo n.º 3
0
 private void checkPassword(string password)
 {
     if (password == _targetPassword)
     {
         TerminalHandler.Instance.NewShell();
         TerminalHandler.Instance.TerminalConfig.CurrentUser  = "******";
         TerminalHandler.Instance.TerminalConfig.CurrentGroup = "root";
         TerminalHandler.Instance.BuildPrompt();
         OfficeServerRoomHandler.OnThirdChallengeCompleted();
     }
     else
     {
         TerminalHandler.Instance.DisplayOutput("ERROR: authorization failed.");
     }
 }
    public override void OnCmdMatch()
    {
        var       cmd     = _cmd.Split(new char[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
        var       option  = cmd[1][1];
        var       content = _cmd.Replace(cmd[0], "").Replace(cmd[1], "").TrimStart();
        DecodeAlg alg;

        switch (option)
        {
        case 'b':
            alg = DecodeAlg.Base64;
            break;

        case 'h':
            alg = DecodeAlg.Hex;
            break;

        case 'r':
            alg = DecodeAlg.Rot13;
            break;

        default:
            TerminalHandler.Instance.DisplayOutput("ERROR: Option \"-" + option + "\" not available. Type \"help\" to view the list of available options.");
            return;
        }

        try
        {
            var output = decode(content, alg);
            TerminalHandler.Instance.DisplayOutput(output);

            if (output == "ANSWER{FORTYTWO}")
            {
                OfficeServerRoomHandler.OnFourthChallengeCompelted();
            }
        }
        catch (Exception e)
        {
            TerminalHandler.Instance.DisplayOutput("ERROR: The string can't be decoded with the chosen algorithm.");
        }
    }