Ejemplo n.º 1
0
        public void LoadParameters(params string[] args)
        {
            // parallel factor
            if (args.Length > 1)
            {
                if (!int.TryParse(args[2].Trim(), out ParallelFactor))
                {
                    ParallelFactor = -1;
                }
            }

            DoLongRunning = (args.Length > 2 && args[2].Trim() == "1");

            // grab the known listfile
            ListfileHandler = new ListfileHandler();
            if (!ListfileHandler.GetKnownListfile(out string listfile))
            {
                throw new Exception("No known listfile found.");
            }

            FileNames = new ConcurrentBag <string>(File.ReadAllLines(listfile).Select(x => Normalise(x)));

            // init variables
            ResultStrings = new ConcurrentQueue <string>();
            ParseHashes();
        }
Ejemplo n.º 2
0
        public void LoadTestParameters(string device, string mask)
        {
            // what device to use
            switch (device)
            {
            case "gpu":
                ComputeDevice = ComputeDeviceTypes.Gpu;
                break;

            case "cpu":
                ComputeDevice = ComputeDeviceTypes.Cpu;
                break;

            default:
                ComputeDevice = ComputeDeviceTypes.All;
                break;
            }

            Masks = new string[] { Normalise(mask) };

            ListfileHandler = new ListfileHandler();
            ResultQueue     = new Queue <ulong>();
            ResultStrings   = new HashSet <string>();
            IsBenchmark     = true;
        }
Ejemplo n.º 3
0
        public void LoadParameters(params string[] args)
        {
            if (args.Length < 2 || string.IsNullOrWhiteSpace(args[1]))
            {
                throw new ArgumentException("No filter provided.");
            }

            Directory = Normalise(args[1].Trim());

            if (args.Length < 3 || string.IsNullOrWhiteSpace(args[2]))
            {
                throw new ArgumentException("No extension provided.");
            }

            Extension = Normalise(args[2].Trim());

            if (!(args.Length > 3 && int.TryParse(args[3], out Limit)))
            {
                Limit = 100000;
            }

            ListfileHandler = new ListfileHandler();
            if (!ListfileHandler.GetKnownListfile(out string listfile))
            {
                throw new Exception("No known listfile found.");
            }

            FileNames = File.ReadAllLines(listfile).Select(x => Normalise(Path.GetFileNameWithoutExtension(x)).Split('_')).Distinct().ToArray();

            ResultStrings = new ConcurrentQueue <string>();
            ParseHashes();
        }
Ejemplo n.º 4
0
        public void LoadParameters(params string[] args)
        {
            if (args.Length < 3)
            {
                throw new ArgumentException("Incorrect number of arguments");
            }

            // what device to use
            switch (args[1].ToLower().Trim())
            {
            case "gpu":
                ComputeDevice = ComputeDeviceTypes.Gpu;
                break;

            case "cpu":
                ComputeDevice = ComputeDeviceTypes.Cpu;
                break;

            default:
                ComputeDevice = ComputeDeviceTypes.All;
                break;
            }

            // format + validate template masks
            if (File.Exists(args[2]))
            {
                Masks = File.ReadAllLines(args[2])
                        .Select(x => Normalise(x))
                        .Where(x => !string.IsNullOrWhiteSpace(x))
                        .OrderBy(x => Path.GetExtension(x))
                        .ToArray();
            }
            else if (!string.IsNullOrWhiteSpace(args[2]))
            {
                Masks = new string[] { Normalise(args[2]) };
            }

            if (Masks == null || Masks.Length == 0)
            {
                throw new ArgumentException("No valid masks");
            }

            // check for mirrored flag
            IsMirrored = (args.Length > 3 && args[3].Trim() == "1");

            // grab any listfile filters
            string product    = args.Length > 4 ? args[4] : "";
            string exclusions = args.Length > 5 ? args[5] : "";

            ListfileHandler = new ListfileHandler(product, exclusions);

            ResultQueue   = new Queue <ulong>();
            ResultStrings = new HashSet <string>();
            IsBenchmark   = false;
        }
Ejemplo n.º 5
0
        public void LoadParameters(params string[] args)
        {
            if (args.Length < 2)
            {
                throw new ArgumentException("Incorrect number of arguments");
            }

            // format + validate template masks
            if (File.Exists(args[1]))
            {
                Masks = File.ReadAllLines(args[1]).Select(x => Normalise(x)).Where(x => !string.IsNullOrWhiteSpace(x)).Distinct().ToArray();
            }
            else if (!string.IsNullOrWhiteSpace(args[1]))
            {
                Masks = new string[] { Normalise(args[1]) };
            }

            if (Masks == null || Masks.Length == 0)
            {
                throw new ArgumentException("No valid masks.");
            }

            // parallel factor
            if (args.Length > 2)
            {
                uint.TryParse(args[2].Trim(), out ParallelFactor);
            }

            // grab the listfile, either the one from Marla or use the supplied argument
            Console.WriteLine($"Starting Wordlist ");
            Console.WriteLine("Loading Dictionary...");

            ListfileHandler = new ListfileHandler();
            if (ListfileHandler.GetKnownListfile(out string listfile, args.Length > 3 ? args[3] : ""))
            {
                Regex capitalisedsplit = new Regex(@"(?<!^)(?=[A-Z.-\/_\s])", RegexOptions.Compiled);    // splits by capitals and the standard stuff
                Regex isCapitalised    = new Regex(@"([A-Z][a-z])", RegexOptions.Compiled);              // find upper next to lower

                var lines = File.ReadAllLines(listfile);

                var words = lines.SelectMany(x => x.Split(new char[] { '_', '/', ' ', '-', '.' })).Concat(new[] { "_", "/", " ", "-", "." });
                if (lines.Any(x => isCapitalised.IsMatch(x)))                 // check we need to run the capitalised split
                {
                    words = words.Concat(lines.SelectMany(x => capitalisedsplit.Split(x)).Except(words));
                }

                Words = words.Distinct().ToArray();
                Array.Resize(ref lines, 0);                 // delete the old strings
            }
Ejemplo n.º 6
0
        public void LoadParameters(params string[] args)
        {
            if (args.Length == 1 || string.IsNullOrWhiteSpace(args[1]) || args[1].Trim() == "%")
            {
                throw new ArgumentException("No filter provided.");
            }
            if (args[1].Count(x => x == '%') > 1)
            {
                throw new ArgumentException("Filter can't have more than one wildcard character.");
            }

            FileFilter = new List <string[]>();

            if (File.Exists(args[1]))
            {
                var lines = File.ReadAllLines(args[1]);
                foreach (var l in lines)
                {
                    if (string.IsNullOrWhiteSpace(l))
                    {
                        continue;
                    }

                    // attempt to remove extensions
                    string filter = Normalise(l.Trim());
                    if (filter.LastIndexOf('.') >= filter.Length - 5)
                    {
                        Extension = Normalise(filter.Substring(filter.LastIndexOf('.')));
                        filter    = filter.Substring(0, filter.LastIndexOf('.'));
                    }

                    FileFilter.Add(filter.Split(new[] { "%" }, StringSplitOptions.RemoveEmptyEntries));
                }
            }
            else
            {
                // attempt to remove extensions
                string filter = Normalise(args[1].Trim());
                if (filter.LastIndexOf('.') >= filter.Length - 5)
                {
                    Extension = Normalise(filter.Substring(filter.LastIndexOf('.')));
                    filter    = filter.Substring(0, filter.LastIndexOf('.'));
                }

                FileFilter.Add(filter.Split(new[] { "%" }, StringSplitOptions.RemoveEmptyEntries));
            }

            if (args.Length > 2 && !string.IsNullOrWhiteSpace(args[2]))
            {
                Extension = Normalise("." + args[2].Trim().TrimStart('.'));
            }

            if (args.Length < 4 || !int.TryParse(args[3], out MaxDepth))
            {
                MaxDepth = 5;
            }
            if (MaxDepth < 1)
            {
                MaxDepth = 1;
            }

            ListfileHandler = new ListfileHandler();
            if (!ListfileHandler.GetKnownListfile(out string listfile))
            {
                throw new Exception("No known listfile found.");
            }

            FileNames = File.ReadAllLines(listfile).Select(x => Normalise(x)).Distinct().ToArray();

            ResultStrings = new ConcurrentQueue <string>();
            ParseHashes();
        }