Beispiel #1
0
        public static void ExecuteOnFile(Pair <string, string> fileArg, Pair <string, string> hintArg)
        {
            var      filePath = fileArg.Value;
            HashFile file     = FileSystem.FindFileByPath(filePath);

            if (file == null)
            {
                var msg = string.Format("No file found at '{0}'.", filePath);
                msg = TextUtil.Error(msg);
                TerminalUtil.ShowText(msg);
            }
            else
            {
                var password = file.Password;
                LoopUtil.RunCoroutine(ExecuteOnPassword(password, hintArg.Value, (success) =>
                {
                    if (success)
                    {
                        var msg = string.Format("Password found!\nThe password of '{0}' is: {1}", filePath, file.Password);
                        msg     = TextUtil.Success(msg);
                        TerminalUtil.ShowText(msg);
                    }
                    else
                    {
                        var msg = "Unable to find the password of '{0}' with the given arguments. Please try another set of hints.";
                        msg     = string.Format(msg, filePath);
                        msg     = TextUtil.Error(msg);
                        TerminalUtil.ShowText(msg);
                    }
                }));
            }
        }
        /// <summary>
        /// Handles a player input.
        /// </summary>
        public static IEnumerator HandlePlayerInput(string rawInput)
        {
            var text = TextUtil.CleanInputText(rawInput);

            if (string.IsNullOrEmpty(text))
            {
                yield break;
            }

            DebugUtil.Log("[Terminal Util] PLAYER INPUT: " + text, Color.green, DebugUtil.DebugCondition.Verbose,
                          DebugUtil.LogType.Info);

            var deviceText = GetCurrentPathTextFormatted();

            deviceText = TextUtil.Success(deviceText);
            deviceText = TextUtil.ApplyNGUIModifiers(deviceText, TextModifiers.Italic);

            ShowDualText(deviceText, text);

            if (!Shell.RunCommandLine(text))
            {
                var msg = string.Format("'{0}' is not a valid command. If you need help, input 'help'", text);
                msg = TextUtil.Error(msg);
                ShowText(msg);
            }

            UpdateTableAndScroll();
            ClearInputText();
            FocusOnInput();
            CacheCommand(DataHolder.TerminalData, text);
            ResetCommandBufferIndex();
        }
        public static string GetCurrentPathTextFormatted()
        {
            var text = GetCurrentPathText();

            text = TextUtil.Success(text);
            text = TextUtil.ApplyNGUIModifiers(text, TextModifiers.Italic);
            return(text);
        }
Beispiel #4
0
        public static void ExecuteOnDevice(Pair <string, string> deviceArg, Pair <string, string> username, Pair <string, string> hintArg)
        {
            var deviceTarget = deviceArg.Value;
            var device       = DeviceUtil.FindDeviceByIpOrName(deviceTarget);

            if (device == null)
            {
                var msg = string.Format("No device found with IP or Name equal to '{0}'", deviceTarget);
                msg = TextUtil.Error(msg);
                TerminalUtil.ShowText(msg);
            }
            else
            {
                var hasSSH = DeviceUtil.HasProgram(device, ProgramType.SSH);
                if (hasSSH)
                {
                    var user = DeviceUtil.FindUserByName(device, username.Value);
                    if (user == null)
                    {
                        var msg = string.Format("The device '{0}' has no user with name '{1}'.", deviceTarget, username.Value);
                        msg = TextUtil.Error(msg);
                        TerminalUtil.ShowText(msg);
                    }
                    else
                    {
                        var password = user.Password;
                        LoopUtil.RunCoroutine(ExecuteOnPassword(password, hintArg.Value, success =>
                        {
                            if (success)
                            {
                                var msg = "Password found! The password for '{0}' is '{1}'.";
                                msg     = string.Format(msg, user.Username, user.Password);
                                msg     = TextUtil.Success(msg);
                                TerminalUtil.ShowText(msg);
                            }
                            else
                            {
                                var msg = string.Format(
                                    "Unable to find the password of user '{0}' with the given arguments.\nPlease try another set of hints.",
                                    user.Username);
                                msg = TextUtil.Error(msg);
                                TerminalUtil.ShowText(msg);
                            }
                        }));
                    }
                }
                else
                {
                    var msg = "The device '{0}' is not running a SSH instance. We have no way to validate password attempts.";
                    msg = string.Format(msg, deviceTarget);
                    msg = TextUtil.Error(msg);
                    TerminalUtil.ShowText(msg);
                }
            }
        }
Beispiel #5
0
        public static void Execute(ProgramExecutionOptions options)
        {
            var width        = Screen.currentResolution.width;
            var height       = Screen.currentResolution.height;
            var result       = new Texture2D(width, height, TextureFormat.RGB24, false);
            var targetRender = new RenderTexture(width, height, 24);

            Camera.main.targetTexture = targetRender;
            Camera.main.Render();

            RenderTexture.active = targetRender;

            result.ReadPixels(new Rect(0, 0, width, height), 0, 0);
            result.Apply();

            RenderTexture.active      = null;
            Camera.main.targetTexture = null;

            targetRender.Release();
            Object.Destroy(targetRender);

            var printsFolder = FileSystem.FindDirByPath(PrintFolderPath);

            if (printsFolder == null)
            {
                var rootFolder = FileSystem.GetRootDir();
                printsFolder = FileSystem.CreateDir(rootFolder, PrintFolderName);
            }

            var file = FileSystem.CreateImageFile(printsFolder, "print", result);

            var msg = string.Format("Printscreen saved to '{0}'.", file.FullPath);

            msg = TextUtil.Success(msg);
            TerminalUtil.ShowText(msg);

            OpenProgram.OpenImageFile(file, file.Content as ImageFile, false);
        }