예제 #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            long UID = Convert.ToInt32(txtUpdateId.Text);

            Configuration Config = Repository.Find <Configuration>
                                       (s => s.UID == UID)
                                   .FirstOrDefault();

            //Config.Parameter = txtParameter.Text;
            Config.Value = txtUpdateValue.Text;

            Repository.Update(Config);
            LoadGrid();
            grpUpdate.Visible = false;

            txtUpdateId.Clear();
            txtUpdateValue.Clear();
        }
예제 #2
0
        public void URLDetection(string Url)
        {
            bool IsNewRecord = false;

            Resource Resource = Repository
                                .Find <Resource>(s => s.Url == Url)
                                .FirstOrDefault();

            if (Resource == null)
            {
                Resource    = new Resource(Url);
                IsNewRecord = true;
            }

            int ProbabilityCounter = 0;

            if (CombinedStats == null)
            {
                MessageBox.Show("Error: Cannot conduct analysis, baseline data not found");
                return;
            }

            Resource.SetDetectionVariables();

            if (Resource.NumberOfFullStops > CombinedStats.FullStopAverage)
            {
                ProbabilityCounter += 1;
            }

            if (Resource.NumberOfAtSymbols > CombinedStats.AtSymbolsAverage)
            {
                ProbabilityCounter += 1;
            }

            if (Resource.NumberOfForwardSlashes > CombinedStats.ForwardSlashAverage)
            {
                ProbabilityCounter += 1;
            }

            if (Resource.NumberOfMultipleForwardSlashes > CombinedStats.MultipleForwardSlashAverage)
            {
                ProbabilityCounter += 1;
            }

            if (CombinedStats.AverageIPAddress <= 0.5)
            {
                if (Resource.HasIPAddress)
                {
                    ProbabilityCounter += 1;
                }
            }

            if (CombinedStats.AveragePortNumbers <= 0.5)
            {
                if (Resource.HasPortNumber)
                {
                    ProbabilityCounter += 1;
                }
            }

            if (CombinedStats.AverageBadHttps <= 0.5)
            {
                if (Resource.IsBadHttps)
                {
                    ProbabilityCounter += 1;
                }
            }

            if (ProbabilityCounter >= 3)
            {
                Resource.IsPhishing = true;
            }

            if (Resource.IsPhishing)
            {
                lblPhishingInd.Text         = String.Format("Based on the testing performed, {0} is a phishing site according to the analysis shown below", Url);
                lblFishPercentage.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                lblPhishingInd.Text         = String.Format("Based on the testing performed, {0} is not a phishing site according to the analysis shown below", Url);
                lblFishPercentage.ForeColor = System.Drawing.Color.Green;
            }

            double ProbabilityPercentage = ProbabilityCounter * 100 / 7;

            lblFishPercentage.Text = ProbabilityPercentage.ToString() + " %";

            grdUrlAnalysis.Rows.Clear();

            grdUrlAnalysis.Rows.Add("Number of Full Stops", CombinedStats.FullStopAverage.ToString(), Resource.NumberOfFullStops.ToString());
            grdUrlAnalysis.Rows.Add("Number of @ Symbols", CombinedStats.AtSymbolsAverage.ToString(), Resource.NumberOfAtSymbols.ToString());
            grdUrlAnalysis.Rows.Add("Number of Double Forward Slashes", CombinedStats.ForwardSlashAverage.ToString(), Resource.NumberOfForwardSlashes.ToString());
            grdUrlAnalysis.Rows.Add("Number of Multiple Forward Slashes", CombinedStats.MultipleForwardSlashAverage.ToString(), Resource.NumberOfForwardSlashes.ToString());

            grdUrlAnalysis.Rows.Add("Contains IP Address", CombinedStats.AverageIPAddress.ToString(), Resource.HasIPAddress.ToString());
            grdUrlAnalysis.Rows.Add("Contains Port Number", CombinedStats.AveragePortNumbers.ToString(), Resource.HasPortNumber.ToString());
            grdUrlAnalysis.Rows.Add("Invalid HTTPS", CombinedStats.AverageBadHttps.ToString(), Resource.IsBadHttps.ToString());

            grpUrl.Visible = true;

            if (IsNewRecord)
            {
                Repository.Add(Resource);
            }
            else
            {
                Repository.Update(Resource);
            }
        }