Exemplo n.º 1
0
        static void Main(string[] args)
        {
            String allText = System.IO.File.ReadAllText(@"../../TextFile1.txt");

            string[][]      logInCollection      = PredictionModel.readFromFile(allText);
            double          testTime             = 24;
            double          testDay              = 3;
            PredictionModel logInPredictionModel = new PredictionModel(testTime, testDay, logInCollection);
            string          logInRiskLevel       = logInPredictionModel.logInRisk;
            string          logInOutput          = logInPredictionModel.logInOutput;

            Console.WriteLine(logInOutput);
            Console.WriteLine("The risk level is " + logInRiskLevel);


            string currentPublicIP       = PredictionModel.getCurrentPublicIP();
            string currentpubliclocation = PredictionModel.getCurrentPublicIPLocation(currentPublicIP);
            string macAddress            = PredictionModel.getCurrentMAC();
            string date = PredictionModel.getCurrentDate();

            string[][] ipAddressCollection =
            {
                new string[] { "131.23.244.105", "C00008",   "4"  },
                new string[] { "131.23.244.105", "C00008",   "4"  },
                new string[] { "147.120.34.99",  "C00008",   "1"  },
                new string[] { "131.23.244.105", "D00008",   "3"  },
                new string[] { currentPublicIP,  "D8000",    "4"  },
                new string[] { currentPublicIP,  macAddress, date },
                new string[] { currentPublicIP,  macAddress, date },
                new string[] { "151.23.244.105", "C000324",  date }
            };
            //string[] query = new string[] { "1311.23.244.105", "C0000008", date};
            //string[] query = new string[] { currentPublicIP, macAddress, date };
            string[] query = new string[] { "151.23.244.105", "C000324", date };

            PredictionModel ipPredictionModel = new PredictionModel(ipAddressCollection, query);
            string          ipRisk            = ipPredictionModel.ipRisk;
            string          ipOutput          = ipPredictionModel.ipOutput;

            Console.WriteLine(ipOutput);
            double logInPercentage = Convert.ToDouble(logInRiskLevel) / 5.0;
            double ipPercentage    = Convert.ToDouble(ipRisk);

            logInPercentage = (logInPercentage / 100) * 30;
            ipPercentage    = (ipPercentage / 100) * 70;
            double riskLevel = logInPercentage + ipPercentage;

            Console.WriteLine(logInPercentage);
            Console.WriteLine(ipRisk);
            Console.WriteLine(riskLevel);
            string riskStatement = null;

            //Can do anything
            if (riskLevel <= 0.4)
            {
                riskStatement = "The risk level is low";
            }

            // Removing access control and giving access control
            else if (riskLevel <= 0.70)
            {
                riskStatement = "The risk level is medium";
            }

            //Instantly Re authenticate
            else if (riskLevel > 0.70)
            {
                riskStatement = "The risk level is high";
            }


            Console.WriteLine(riskStatement);

            //string fileName = @"../../../../testing/IPPrediction.py";

            //Process p = new Process();
            //p.StartInfo = new ProcessStartInfo(@"../../../../../../../../Anaconda/python.exe", fileName)
            //{
            //    RedirectStandardOutput = true,
            //    UseShellExecute = false,
            //    CreateNoWindow = true
            //};
            //p.Start();

            //string output = p.StandardOutput.ReadToEnd();
            //Console.WriteLine(output);



            //string currentPublicIP = PredictionModel.getCurrentPublicIP();
            //string currentPublicLocation = PredictionModel.getCurrentPublicIPLocation(currentPublicIP);
            //Console.WriteLine(currentPublicIP + " is at " + currentPublicLocation);

            //string localIP = getCurrentPrivateIP();
            //string macAddress = getCurrentMAC(localIP);
            //Console.WriteLine(macAddress);
            //string date = getCurrentDate();



            //string[][] ipAddressCollection =
            //{
            //    new string [] {"131.23.244.105","C00008" , "4"} ,
            //    new string [] {"131.23.244.105", "C00008" , "4"} ,
            //    new string [] { "147.120.34.99", "C00008" , "1"} ,
            //    new string [] { "131.23.244.105", "D00008" , "3"},
            //    new string [] { localIP , "D8000" , "4"},
            //    new string [] { localIP , macAddress , date},
            //    new string [] { localIP , macAddress , date}
            //};
            //string[] query = new string[] { localIP, macAddress , date};
            //Dictionary<string, int> count = getCountNumber(ipAddressCollection);
            //string[][] keyData = getValueArray(ipAddressCollection);
            //string[] queryKey = checkQueryData(query, ipAddressCollection);
            //Console.WriteLine(queryKey[0]);
            //Console.WriteLine("Convert a certain IP and MAC and DAY to key form : " + queryKey[0] +  queryKey[1] + queryKey[2] + queryKey[3]);
            //string[] retrieveValue = new string[] { queryKey[0], queryKey[1], queryKey[2] };
            //string[] retrievedDataValue = getKeyInformation(queryKey, ipAddressCollection);
            //Console.WriteLine("Convert Key to Info " + retrievedDataValue[0] + " " + retrievedDataValue[1] + " " + retrievedDataValue[2] + " " + retrievedDataValue[3]);

            //foreach (var element in keyData)
            //{
            //    Console.WriteLine(element[0] + element[1] + element[2] + element[3]);
            //}


            //foreach (var element in count)
            //{
            //    Console.WriteLine(element.Key + " = " + element.Value);
            //}
            //int counter = 0;
            //string[][] testingList = new string[keyData.Count()][];
            //string[][] passList = new string[keyData.Count()][];
            //foreach (var element in keyData)
            //{
            //    passList[counter] = new string[] { element[0], element[1], element[2], Convert.ToString(count.ElementAt(counter).Value) };
            //    string[] question = new string[] { element[0], element[1], element[2] };
            //    string[] data = getKeyInformation(question, ipAddressCollection);
            //    testingList[counter] = new string[] { data[0], data[1], data[2], Convert.ToString(count.ElementAt(counter).Value) };
            //    counter++;
            //}

            //Console.WriteLine("PASSING IN PARAMETER LIST");
            //Console.WriteLine("IP " + " MAC " + "       DAY " + "     COUNT ");
            //foreach (var element in passList)
            //{

            //    Console.WriteLine(element[0] + "     " + element[1] + "        " + element[2] + "         " + element[3]);
            //}

            //Console.WriteLine("CHECKING THE LIST");
            //foreach (var element in testingList)
            //{
            //    Console.WriteLine("IP is " + element[0] + " MAC Address " + element[1] + " Day of the week " + element[2] + " with a count of " + element[3]);
            //}
        }