示例#1
0
        private static string GetCommand()
        {
            var commands = new[] { "version", "connect", "keygen", "help", "clear", "exit", "upload", "pwd", "computehash" };
            var list     = commands.ToList();

            list.AddRange(Directory.GetDirectories(WorkingDirectory).Select(i => $"cd {new DirectoryInfo(i).Name.ToLower()}"));
            try {
                ReadLine.AutoCompletionHandler = (data, length) => {
                    var tList = new List <string>();
                    if (data.StartsWith("cd ") && (data.Contains("/") || data.Contains("\\")))
                    {
                        Directory.GetDirectories($"{WorkingDirectory}/{Path.GetDirectoryName(data.Remove(0, 3))}").ToList()
                        .Where(x => new DirectoryInfo(x)
                               .FullName.ToLower().Contains(data.ToLower().Split(' ')[1].Replace('/', '\\'))).ToList()
                        .ForEach(x => tList.Add(x.Remove(0, $"{WorkingDirectory}/{Path.GetDirectoryName(data.Remove(0, 3))}".Length + 1).ToLower()));
                    }
                    if (data.Trim() == "help")
                    {
                        commands.ToList().ForEach(x => tList.Add(x));
                    }
                    list.Where(x => x.Contains(data)).ToList().ForEach(y => tList.Add(y.Remove(0, length)));
                    return(tList.ToArray());
                };
            } catch (IndexOutOfRangeException) { }
            var read = ReadLine.Read();

            File.AppendAllText(History, $"[{DateTime.UtcNow} UTC]\t=>\t{read}\n");
            if (read.Contains("%appdata%"))
            {
                read = read.Replace("%appdata%", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).Replace('\\', '/'));
            }
            return(read.TrimEnd().TrimStart().Trim());
        }
示例#2
0
        private static string GetPassword(string prompt)
        {
            ReadLine.PasswordMode = true;
            var password = ReadLine.Read(prompt);

            ReadLine.GetHistory().Pop();
            ReadLine.PasswordMode = false;
            return(password);
        }