コード例 #1
0
        public StatisticsGenerator(StatusContainer status, P2PQuickWatchPresentation quickWatch, KeySearcher keySearcher, KeySearcherSettings settings, DistributedBruteForceManager distributedBruteForceManager)
        {
            this.status      = status;
            this.quickWatch  = quickWatch;
            this.keySearcher = keySearcher;
            this.distributedBruteForceManager = distributedBruteForceManager;

            lastDateOfGlobalStatistics = DateTime.Now;
            HighestChunkCalculated     = -1;
            stopWatch = new Stopwatch();

            var keyPattern = new KeyPattern.KeyPattern(keySearcher.ControlMaster.GetKeyPattern())
            {
                WildcardKey = settings.Key
            };
            var keysPerChunk   = Math.Pow(2, settings.ChunkSize);
            var keyPatternPool = new KeyPatternPool(keyPattern, new BigInteger(keysPerChunk));

            TotalAmountOfChunks = keyPatternPool.Length;

            status.PropertyChanged += StatusPropertyChanged;

            elapsedTimeTimer          = new Timer(1000);
            elapsedTimeTimer.Elapsed += ElapsedTimeTimerTick;
            elapsedTimeTimer.Start();

            trafficUpdateTimer          = new Timer(10000);
            trafficUpdateTimer.Elapsed += TrafficUpdateTimerTick;
            trafficUpdateTimer.Start();
        }
コード例 #2
0
        public DistributedBruteForceManager(KeySearcher keySearcher, KeyPattern.KeyPattern keyPattern, KeySearcherSettings settings,
                                            KeyQualityHelper keyQualityHelper, P2PQuickWatchPresentation quickWatch, KeyPoolTreePresentation keyPoolTreePresentation)
        {
            this.keySearcher         = keySearcher;
            this.settings            = settings;
            this.keyQualityHelper    = keyQualityHelper;
            this.quickWatch          = quickWatch;
            _keyPoolTreePresentation = keyPoolTreePresentation;

            // TODO when setting is still default (21), it is only displayed as 21 - but the settings-instance contains 0 for that key!
            if (settings.ChunkSize == 0)
            {
                settings.ChunkSize = 21;
            }

            StopWatch = new Stopwatch();
            status    = new StatusContainer(keySearcher);
            status.IsCurrentProgressIndeterminate = true;

            keyGenerator        = new StorageKeyGenerator(keySearcher, settings);
            patternPool         = new KeyPatternPool(keyPattern, new BigInteger(Math.Pow(2, settings.ChunkSize)));
            StatisticsGenerator = new StatisticsGenerator(status, quickWatch, keySearcher, settings, this);
            quickWatch.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(UpdateStatusContainerInQuickWatch));

            _keyPoolTreePresentation.PatternPool      = patternPool;
            _keyPoolTreePresentation.KeyQualityHelper = keyQualityHelper;
            _keyPoolTreePresentation.KeyGenerator     = keyGenerator;
            _keyPoolTreePresentation.StatusContainer  = status;
        }
コード例 #3
0
        public void SetKeys(object keys)
        {
            if (!(keys is KeyPattern.KeyPattern) || (((KeyPattern.KeyPattern)keys).WildcardKey == null))
            {
                throw new Exception("Something went horribly wrong!");
            }

            pattern = (KeyPattern.KeyPattern)keys;

            keyMovements   = pattern.getKeyMovements();
            movementStatus = pattern.getWildcardProgress();
            if (movementStatus.Length != keyMovements.Length)
            {
                throw new Exception("Movements and Wildcards do not fit together!");
            }

            movementPointers = new int[movementStatus.Length];
            int mpc = 0;

            byte[] keya2       = new byte[256];
            int    kc          = 0;
            string wildcardKey = pattern.WildcardKey;
            int    i           = 0;

            bool first = true;

            while (i < wildcardKey.Length)
            {
                if (wildcardKey[i] == '[')
                {
                    i++;
                    while (wildcardKey[i++] != ']')
                    {
                        ;
                    }
                    i--;

                    movementPointers[mpc++] = kc++;

                    first = false;
                }
                else if (wildcardKey[i] == '-')
                {
                    first = true;
                }
                else
                {
                    byte val = Convert.ToByte("" + wildcardKey[i], 16);
                    if (first)
                    {
                        keya2[kc / 2] = (byte)((int)val << 4);
                    }
                    else
                    {
                        keya2[kc / 2] |= val;
                    }

                    kc++;

                    first = false;
                }

                i++;
            }

            keya = new byte[kc / 2];
            for (int c = 0; c < (kc / 2); c++)
            {
                keya[c] = keya2[c];
            }

            for (int x = 0; x < movementStatus.Length; x++)
            {
                SetWildcard(x);
            }
        }