protected void spamdetect_Click(object sender, EventArgs e)
        {
            row = sp.Spam.NewSpamRow();

            row.Querylength        = Convert.ToInt32(Querylength2.Text);
            row.domain_token_count = Convert.ToInt32(domain_token_count2.Text);
            row.path_token_count   = Convert.ToInt32(path_token_count2.Text);
            row.longdomaintokenlen = Convert.ToInt32(longdomaintokenlen2.Text);
            row.avgpathtokenlen    = Convert.ToDouble(avgpathtokenlen2.Text);
            row.tld                         = Convert.ToInt32(tld2.Text);
            row.charcompace                 = Convert.ToInt32(charcompace2.Text);
            row.charcompvowels              = Convert.ToInt32(charcompvowels2.Text);
            row.ldl_url                     = Convert.ToInt32(ldl_url2.Text);
            row.ldl_path                    = Convert.ToInt32(ldl_url2.Text);
            row.ldl_getArg                  = Convert.ToInt32(ldl_getArg2.Text);
            row.dld_getArg                  = Convert.ToInt32(dld_getArg2.Text);
            row.dld_path                    = Convert.ToInt32(dld_path2.Text);
            row.pathLength                  = Convert.ToInt32(pathLength2.Text);
            row.subDirLen                   = Convert.ToInt32(subDirLen2.Text);
            row.this_fileExtLen             = Convert.ToInt32(thisfileExtLen2.Text);
            row.ArgLen                      = Convert.ToInt32(ArgLen2.Text);
            row.ArgUrlRatio                 = Convert.ToDouble(ArgUrlRatio2.Text);
            row.domainUrlRatio              = Convert.ToDouble(domainUrlRatio2.Text);
            row.pathDomainRatio             = Convert.ToDouble(pathDomainRatio2.Text);
            row.CharacterContinuityRate     = Convert.ToDouble(CharacterContinuityRate2.Text);
            row.NumberofDotsinURL           = Convert.ToInt32(NumberofDotsinURL2.Text);
            row.URL_DigitCount              = Convert.ToInt32(URL_DigitCount2.Text);
            row.URL_Letter_Count            = Convert.ToInt32(URL_Letter_Count2.Text);
            row.Extension_DigitCount        = Convert.ToInt32(Extension_DigitCount2.Text);
            row.Filename_LetterCount        = Convert.ToInt32(Filename_LetterCount2.Text);
            row.host_letter_count           = Convert.ToInt32(host_letter_count2.Text);
            row.Query_LetterCount           = Convert.ToInt32(Query_LetterCount2.Text);
            row.Domain_LongestWordLength    = Convert.ToInt32(Domain_LongestWordLength2.Text);
            row.Path_LongestWordLength      = Convert.ToInt32(Path_LongestWordLength2.Text);
            row.Arguments_LongestWordLength = Convert.ToInt32(Arguments_LongestWordLength2.Text);
            //  row.URL_sensitiveWord = Convert.ToBoolean(URL_sensitiveWord2.Text);
            row.spcharUrl            = Convert.ToInt32(spcharUrl2.Text);
            row.delimeter_path       = Convert.ToInt32(delimeter_path2.Text);
            row.NumberRate_URL       = Convert.ToDouble(NumberRateURL2.Text);
            row.NumberRate_FileName  = Convert.ToDouble(NumberRate_FileName2.Text);
            row.NumberRate_AfterPath = Convert.ToDouble(NumberRate_AfterPath2.Text);

            row.SymbolCount_URL           = Convert.ToInt32(SymbolCount_URL2.Text);
            row.SymbolCount_FileName      = Convert.ToInt32(SymbolCount_FileName2.Text);
            row.SymbolCount_Directoryname = Convert.ToInt32(SymbolCount_Directoryname2.Text);
            row.Entropy_Afterpath         = Convert.ToDouble(Entropy_Afterpath12.Text);
            row.Entropy_Domain            = Convert.ToDouble(Entropy_Domain2.Text);
            row.Entropy_Extension         = Convert.ToDouble(Entropy_Extension2.Text);
            row.Entropy_Filename          = Convert.ToDouble(Entropy_Filename2.Text);
            row.Entropy_URL       = Convert.ToDouble(Entropy_URL2.Text);
            row.URL_sensitiveWord = Convert.ToInt32(URL_sensitiveWord2.Text);
            sp.Spam.Rows.Add(row);
            am.Update(row);
            int s = Convert.ToInt32(am.maxid());

            Response.Redirect("checkspam.aspx?q=" + s);
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int s = Convert.ToInt32(Request.QueryString["q"]);

            am.Fill(sp.Spam);
            row = sp.Spam.FindById(s);

            n.WriteScript("dataset=read.csv('Spam.csv') " +
                          Environment.NewLine + "   dataset = na.omit(dataset)" +
                          Environment.NewLine + " dataset$class=factor(dataset$class,levels = c(0,1))" +

                          Environment.NewLine + "library(caTools)" +
                          Environment.NewLine + "set.seed(123)" +
                          Environment.NewLine + "   split= sample.split(dataset$class,SplitRatio = 0.75)" +
                          Environment.NewLine + " training_set = subset(dataset, split == TRUE)" +
                          Environment.NewLine + " test_set = subset(dataset, split == FALSE)" +



                          Environment.NewLine + "dataframe<-data.frame(Querylength=" + row.Querylength + ",domain_token_count=" + row.domain_token_count + ",path_token_count=" + row.path_token_count + ",longdomaintokenlen=" + row.longdomaintokenlen + ",avgpathtokenlen=" + row.avgpathtokenlen + ",tld=" + row.tld + ",charcompvowels=" + row.charcompvowels + ",charcompace=" + row.charcompace + ",ldl_url=" + row.ldl_url + ",ldl_path=" + row.ldl_path + ",ldl_getArg=" + row.ldl_getArg + ",dld_path=" + row.dld_path + ",dld_getArg=" + row.dld_getArg + ",pathLength=" + row.pathLength + ",subDirLen=" + row.subDirLen + ",this.fileExtLen=" + row.this_fileExtLen + ",ArgLen=" + row.ArgLen + ",ArgUrlRatio=" + row.ArgUrlRatio + ",domainUrlRatio=" + row.ArgUrlRatio + ",pathDomainRatio=" + row.pathDomainRatio + ",NumberofDotsinURL=" + row.NumberofDotsinURL + ",CharacterContinuityRate=" + row.CharacterContinuityRate + ",URL_DigitCount=" + row.URL_DigitCount + ",Extension_DigitCount=" + row.Extension_DigitCount + ",URL_Letter_Count=" + row.URL_Letter_Count + ",host_letter_count=" + row.host_letter_count + ",Filename_LetterCount=" + row.Filename_LetterCount + ",Query_LetterCount=" + row.Query_LetterCount + ",Domain_LongestWordLength=" + row.Domain_LongestWordLength + ",Path_LongestWordLength=" + row.Path_LongestWordLength + ",Arguments_LongestWordLength=" + row.Arguments_LongestWordLength + ",URL_sensitiveWord=" + row.URL_sensitiveWord + ",spcharUrl=" + row.spcharUrl + ",delimeter_path=" + row.delimeter_path + ",NumberRate_URL=" + row.NumberRate_URL + ",NumberRate_FileName=" + row.NumberRate_FileName + ",NumberRate_AfterPath=" + row.NumberRate_AfterPath + ",SymbolCount_URL=" + row.SymbolCount_URL + ",SymbolCount_Directoryname=" + row.SymbolCount_Directoryname + ",SymbolCount_FileName=" + row.SymbolCount_FileName + ",Entropy_URL=" + row.Entropy_URL + ",Entropy_Domain=" + row.Entropy_Domain + ",Entropy_Filename=" + row.Entropy_Filename + ",Entropy_Extension=" + row.Entropy_Extension + ",Entropy_Afterpath=" + row.Entropy_Afterpath + ",class=0)" +


                          Environment.NewLine + "test_set=rbind(test_set,dataframe)" +



                          Environment.NewLine + "training_set[1:45]=scale(training_set[1:45])" +
                          Environment.NewLine + " test_set[1:45] = scale(test_set[1:45])" +

                          Environment.NewLine + "library(class)" +
                          //Environment.NewLine + "classifier = randomForest(x = training_set[1:45], y = training_set$label, ntree = 100)" +
                          Environment.NewLine + "y_pred = knn(train = training_set[,-46],test = test_set[, -46],cl = training_set[, 46], k = 5, prob = TRUE)" +
                          //Environment.NewLine + "cm = table(test_set[, 46], y_pred)" +
                          //Environment.NewLine + "print(cm)"
                          Environment.NewLine + "y_pred=tail(y_pred,1)" +
                          Environment.NewLine + "print(y_pred)"
                          );
            String x = n.executeR();

            //Response.Write(x);
            if (x[1] == '1')
            {
                Response.Redirect("safe.aspx");
            }
            else
            {
                Response.Redirect("WebForm2.aspx");
            }
            Response.End();
        }