Ejemplo n.º 1
0
        public measure run(string input_file1, string input_file2)
        {
            JToken binary1_ep = readJSON(input_file1);
            JToken binary2_ep = readJSON(input_file2);

            string name1   = binary1_ep["name"].ToString();
            string packer1 = binary1_ep["packer"].ToString();
            string name2   = binary2_ep["name"].ToString();
            string packer2 = binary2_ep["packer"].ToString();

            double mnemonic_lcs = getMnemonicLCS(binary1_ep, binary2_ep);

            EditDistance.ngram_similarity ngram_similarity = getNgramEditDistance(binary1_ep, binary2_ep, 8);

            return(new measure(name1, packer1, name2, packer2, mnemonic_lcs, ngram_similarity.ngram_edit_distance, ngram_similarity.edit_distance));
        }
Ejemplo n.º 2
0
        private void target(int i)
        {
            JToken[] couple = new JToken[2];

            while (true)
            {
                lock (thisLock)
                {
                    if (queue.IsEmpty)
                    {
                        break;
                    }
                    queue.TryDequeue(out couple);
                }

                string srcName             = couple[0]["name"].ToString();
                int    srcAddr             = (int)couple[0]["addr"];
                int    srcNumOfMne         = couple[0]["mnemonics"].Count();
                string dstName             = couple[1]["name"].ToString();
                int    dstAddr             = (int)couple[1]["addr"];
                int    dstNumOfMne         = couple[1]["mnemonics"].Count();
                double cosine_similarity   = getCosineSimilarity(couple[0], couple[1]);
                string cosine_time         = timer.Elapsed.ToString();
                double mnemonic_similarity = getMnemonicLCS(couple[0], couple[1]);
                EditDistance.ngram_similarity ngram_similarity = getNgramEditDistance(couple[0], couple[1], 8);
                string ngram_time   = timer.Elapsed.ToString();
                bool   authenticity = (couple[0]["name"].ToString() == couple[1]["name"].ToString());

                lock (thisLock)
                {
                    StreamWriter writer = File.AppendText("test.csv");
                    writer.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}", srcName, srcNumOfMne, dstName, dstNumOfMne, cosine_similarity, mnemonic_similarity, ngram_similarity.ngram_edit_distance, ngram_similarity.slope1_ratio, ngram_similarity.continuous_equal_slope2, ngram_similarity.continuous_equal_slope3, authenticity);
                    writer.Close();
                }
            }
        }