コード例 #1
0
        public void test_signature_separated_by_dashes_2()
        {
            var msgBody = @"Hey!
-roman";

            Bruteforce.ExtractSignature(msgBody).ShouldBe(new Tuple <string, string>("Hey!", "-roman"));
        }
コード例 #2
0
        public void test_get_signature_candidate_2()
        {
            // first line never included
            var lines = new[] { "text", "signature" };

            Bruteforce.GetSignatureCandidate(lines).ShouldBe(new[] { "signature" });
        }
コード例 #3
0
        public void test_get_signature_candidate_6()
        {
            // test list (with dashes as bullet points) not included
            var lines = new[] { "List:,", "- item 1", "- item 2", "--", "Bob" };

            Bruteforce.GetSignatureCandidate(lines).ShouldBe(new[] { "--", "Bob" });
        }
コード例 #4
0
        private void DecryptionBruteforce(BitArray[] plainTextArray, BitArray[] cipherTextArray)
        {
            //Decryption bruteforce is faster than encryption
            var DecKeyList = new List <string>();

            for (int x = 0; x < cipherTextArray.Length; x++)
            {
                var key = Bruteforce.DecryptionAttack(plainTextArray[x], cipherTextArray[x], DecKeyList);
                if (!DecKeyList.Contains(key))
                {
                    DecKeyList.Add(key);
                }
            }
            StringBuilder sB = new StringBuilder("Keys found: ");

            foreach (var key in DecKeyList)
            {
                sB.Append(key);
                sB.Append(", ");
            }
            sB.Remove(sB.Length - 2, 2);
            Console.WriteLine(sB.ToString());
            var goodKeys = Bruteforce.KeysForAll(DecKeyList, plainTextArray, cipherTextArray);

            sB.Clear();
            sB.Append("Keys that work for all the pairs: ");
            foreach (var key in goodKeys)
            {
                sB.Append(key);
                sB.Append(", ");
            }
            sB.Remove(sB.Length - 2, 2);
            Console.WriteLine(sB.ToString());
        }
コード例 #5
0
        public void test_blackberry_signature_2()
        {
            var msgBody = @"Blah
Enviado desde mi oficina móvil BlackBerry® de Telcel";

            Bruteforce.ExtractSignature(msgBody)
            .ShouldBe(new Tuple <string, string>("Blah", "Enviado desde mi oficina móvil BlackBerry® de Telcel"));
        }
コード例 #6
0
        public void test_signature_separated_by_dashes_4()
        {
            var msgBody = @"Wow. Awesome!
--
Bob Smith";

            Bruteforce.ExtractSignature(msgBody).ShouldBe(new Tuple <string, string>("Wow. Awesome!", "--\r\nBob Smith"));
        }
コード例 #7
0
        public void test_mailbox_for_iphone_signature()
        {
            var msgBody = @"Blah
Sent from Mailbox for iPhone";

            Bruteforce.ExtractSignature(msgBody)
            .ShouldBe(new Tuple <string, string>("Blah", "Sent from Mailbox for iPhone"));
        }
コード例 #8
0
        public void test_iphone_signature()
        {
            var msgBody = @"Hey!

Sent from my iPhone!";

            Bruteforce.ExtractSignature(msgBody).ShouldBe(new Tuple <string, string>("Hey!", "Sent from my iPhone!"));
        }
コード例 #9
0
 public void test_get_signature_candidate()
 {
     // if there aren"t at least 2 non-empty lines there should be no signature
     foreach (var lines in new[] { new string[] { }, new[] { "" }, new[] { "", "" }, new[] { "abc" } })
     {
         Bruteforce.GetSignatureCandidate(lines).ShouldBeEmpty();
     }
 }
コード例 #10
0
        public void test_blank_lines_inside_signature_2()
        {
            var msgBody = @"Blah
--

John Doe";

            Bruteforce.ExtractSignature(msgBody).ShouldBe(new Tuple <string, string>("Blah", "--\r\n\r\nJohn Doe"));
        }
コード例 #11
0
 public void test_get_signature_candidate_5()
 {
     // test long lines not encluded
     using (new TooLongSignatureLineScope(3))
     {
         var lines = new[] { "BR,", "long", "Bob" };
         Bruteforce.GetSignatureCandidate(lines).ShouldBe(new[] { "Bob" });
     }
 }
コード例 #12
0
        public void TestIsPointCloseToEmptyListOfPoints()
        {
            Point        p1         = new Point(0, 0);
            List <Point> points     = new List <Point>();
            Bruteforce   bruteforce = new Bruteforce(points, 2.0);
            bool         actual     = bruteforce.PointIsCloseToOtherPoints(p1);

            Assert.AreEqual(false, actual);
        }
コード例 #13
0
        public void test_signature_words()
        {
            var msgBody = @"Hey!

Thanks!
Roman";

            Bruteforce.ExtractSignature(msgBody).ShouldBe(new Tuple <string, string>("Hey!", "Thanks!\r\nRoman"));
        }
コード例 #14
0
        public void test_signature_separated_by_dashes()
        {
            var msgBody = @"Hey man! How r u?
---
Roman";

            Bruteforce.ExtractSignature(msgBody)
            .ShouldBe(new Tuple <string, string>("Hey man! How r u?", "---\r\nRoman"));
        }
コード例 #15
0
 public void test_get_signature_candidate_4()
 {
     // test when message is longer then the SIGNATURE_MAX_LINES
     using (new SignatureMaxLinesScope(2))
     {
         var lines = new[] { "text1", "text2", "signature1", "", "signature2" };
         Bruteforce.GetSignatureCandidate(lines).ShouldBe(new[] { "signature1", "", "signature2" });
     }
 }
コード例 #16
0
 public void test_get_signature_candidate_3()
 {
     // test when message is shorter then SIGNATURE_MAX_LINES
     using (new SignatureMaxLinesScope(3))
     {
         var lines = new[] { "text", "", "", "signature" };
         Bruteforce.GetSignatureCandidate(lines).ShouldBe(new[] { "signature" });
     }
 }
コード例 #17
0
        private void timer_Tick(object sender, EventArgs e)
        {
            if (Bruteforce.IsActive)
            {
                Bruteforce.Update();
                if (Bruteforce.HasResult)
                {
                    lbCount.Text  = Bruteforce.FirstTask.Counter.ToString("0,0");
                    tbResult.Text = Bruteforce.Result;
                    var duration = Bruteforce.EndTime - Bruteforce.StartTime;
                    lbTime.Text =
                        $"{duration.TotalHours:00}:hr {duration.Minutes:00}:min {duration.Seconds:00}:s {duration.Milliseconds:0000}:ms";
                    //if (e.HasResult)
                    //{
                    tbResult.BackColor = Color.LightGreen;
                    //}
                    //else
                    //{
                    //    tbResult.BackColor = Color.Tomato;
                    //}
                }

                if (Bruteforce.Speed > 0)
                {
                    _speedAverage.Add(Bruteforce.Speed);
                    if (_speedAverage.Count > 50)
                    {
                        _speedAverage.RemoveAt(0);
                    }

                    lbSpeed.Text = $"{Bruteforce.Speed:n} hashes/s";
                    var avg = _speedAverage.Average();
                    lbAvarage.Text = $"{avg:n} hashes/s";
                    lbCount.Text   = $"{Bruteforce.Tasks.Sum(x => x.Counter):0,0}";

                    var time = DateTime.Now - Bruteforce.StartTime;
                    lbTime.Text =
                        $"{time.TotalHours:00}:hr {time.Minutes:00}:min {time.Seconds:00}:s {time.Milliseconds:0000}:ms";
                    TimeSpan maxTime;
                    try
                    {
                        var space = (ulong)StringHelper.CalculateSpace(Bruteforce.Charset, (int)numMinCount.Value,
                                                                       (int)numCount.Value);
                        maxTime         = TimeSpan.FromSeconds(space / avg);
                        lblMaxTime.Text =
                            $"{maxTime.TotalHours:00}:hr {maxTime.Minutes:00}:min {maxTime.Seconds:00}:s {maxTime.Milliseconds:0000}:ms";
                    }
                    catch (OverflowException)
                    {
                        maxTime         = TimeSpan.MaxValue;
                        lblMaxTime.Text =
                            $"> {maxTime.Days:00}days: {maxTime.Hours:00}:hr {maxTime.Minutes:00}:min {maxTime.Seconds:00}:s {maxTime.Milliseconds:0000}:ms";
                    }
                }
            }
        }
コード例 #18
0
        public void test_blackberry_signature()
        {
            var msgBody = @"Heeyyoooo.
Sent wirelessly from my BlackBerry device on the Bell network.
Envoyé sans fil par mon terminal mobile BlackBerry sur le réseau de Bell.";

            var sig = msgBody.Substring("Heeyyoooo.".Length, msgBody.Length - "Heeyyoooo.".Length);

            Bruteforce.ExtractSignature(msgBody).ShouldBe(new Tuple <string, string>("Heeyyoooo.", sig.Trim()));
        }
コード例 #19
0
 public void test_mark_candidate_indexes()
 {
     using (new TooLongSignatureLineScope(3))
     {
         // spaces are not considered when checking line length
         Bruteforce.MarkCandidateIndexes(
             new[] { "BR,  ", "long", "Bob" },
             new[] { 0, 1, 2 }).ShouldBe("clc".ToCharArray());
     }
 }
コード例 #20
0
ファイル: Form1.cs プロジェクト: deepdigger/PunktNaehe
 private void SetPointProximity()
 {
     double epsilon = Calculations.CalculateEpsilon(points);
     Dictionary<string, IPointProximity> pointProximities = new Dictionary<string, IPointProximity>();
     IPointProximity bruteforce = new Bruteforce(points, epsilon);
     IPointProximity grid = new Grid(points, epsilon);
     pointProximities.Add("bruteforce", bruteforce);
     pointProximities.Add("grid", grid);
     pointProximity = pointProximities[algorithm];
 }
コード例 #21
0
        private void btStart_Click(object sender, EventArgs e)
        {
            _speedAverage.Clear();
            var hash = comboBoxHash.SelectedItem as IBruteforceHash;

            Bruteforce.Start(hash, tbCharset.Text, (int)numMinCount.Value, (int)numCount.Value, (int)numThreads.Value, tbInput.Text);

            var space = (ulong)StringHelper.CalculateSpace(Bruteforce.Charset, (int)numMinCount.Value, (int)numCount.Value);

            lblCharspaceValue.Text = space.ToString("0,0");
        }
コード例 #22
0
        public void test_signature_words_3()
        {
            var msgBody = @"Hey!
--
--
Regards,
Roman";

            Bruteforce.ExtractSignature(msgBody)
            .ShouldBe(new Tuple <string, string>("Hey!", "--\r\n--\r\nRegards,\r\nRoman"));
        }
コード例 #23
0
        public void test_line_starts_with_signature_word()
        {
            var msgBody = @"Hey man!
Thanks for your attention.
--
Thanks!
Roman";

            Bruteforce.ExtractSignature(msgBody)
            .ShouldBe(new Tuple <string, string>("Hey man!\r\nThanks for your attention.", "--\r\nThanks!\r\nRoman"));
        }
コード例 #24
0
 public void test_mark_candidate_indexes_2()
 {
     using (new TooLongSignatureLineScope(3))
     {
         // only candidate lines are marked
         // if line has only dashes it"s a candidate line
         Bruteforce.MarkCandidateIndexes(
             new[] { "-", "long", "-", "- i", "Bob" },
             new[] { 0, 2, 3, 4 }).ShouldBe("ccdc".ToCharArray());
     }
 }
コード例 #25
0
        public void test_blank_lines_inside_signature(string test)
        {
            var msgBody = @"Blah.

" + test + @"

Sent from my HTC smartphone!";

            Bruteforce.ExtractSignature(msgBody)
            .ShouldBe(new Tuple <string, string>("Blah.", test + "\r\n\r\nSent from my HTC smartphone!"));
        }
コード例 #26
0
        public void TestIPointProximity()
        {
            double          epsilon                = 2;
            Point           p                      = new Point(0, 0);
            List <Point>    points                 = new List <Point>();
            IPointProximity testGrid               = new Grid(points, epsilon);
            IPointProximity testBruteforce         = new Bruteforce(points, epsilon);
            bool            PointIsCloseGrid       = testGrid.PointIsCloseToOtherPoints(p);
            bool            PointIsCloseBruteforce = testBruteforce.PointIsCloseToOtherPoints(p);

            Assert.IsFalse(PointIsCloseGrid && PointIsCloseBruteforce);
        }
コード例 #27
0
        public void test_line_starts_with_dashes()
        {
            var msgBody = @"Hey man!
Look at this:

--> one
--> two
--
Roman";

            Bruteforce.ExtractSignature(msgBody)
            .ShouldBe(new Tuple <string, string>("Hey man!\r\nLook at this:\r\n\r\n--> one\r\n--> two", "--\r\nRoman"));
        }
        public void CheckEachPointAndMakeBoolList()
        {
            IPointProximity bruteforce = new Bruteforce(points, epsilon);
            IPointProximity grid       = new Grid(points, epsilon);

            ClosePoints = new List <bool>();
            foreach (Point p in points)
            {
                bool equalBruteforce = bruteforce.PointIsCloseToOtherPoints(p);
                bool equalGrid       = grid.PointIsCloseToOtherPoints(p);
                ClosePoints.Add(equalBruteforce == equalGrid);
            }
        }
コード例 #29
0
        public void test_signature_cant_start_from_first_line()
        {
            var msgBody = @"Thanks,

Blah

regards

John Doe";

            Bruteforce.ExtractSignature(msgBody)
            .ShouldBe(new Tuple <string, string>("Thanks,\r\n\r\nBlah", "regards\r\n\r\nJohn Doe"));
        }
コード例 #30
0
        private static void InstanceTestsDeviation(int cities, int trueSolution)
        {
            var graph = new Graph($"C:\\My Work\\Studies\\PWr\\PEA\\BF-DP\\Effective-Algorithms-Design\\pea_proj\\pea\\instances\\data{cities}.txt");

            Write(graph);

            IAlgorithmsInterface algorithm = new Bruteforce(graph)
            {
                Name = $"Brute force{cities}D"
            };

            Write(algorithm);
            ComputeAndSaveDeviation(algorithm, trueSolution, 10);
        }