Esempio n. 1
0
        void run_cmd()
        {
            //@"..\ImmunityScans\venv\Scripts\python.exe"
            //@"..\Python37\python.exe"

            //checkUPX();

            ProcessStartInfo ranStat = new ProcessStartInfo();

            ranStat.FileName               = @"C:\Users\niluf\Desktop\Immunity\ImmunityApp\ImmunityFormApp1\bin\ImmunityScans\venv\Scripts\pythonw.exe";                  //cmd is full path to python.exe
            ranStat.Arguments              = @"C:\Users\niluf\Desktop\Immunity\ImmunityApp\ImmunityFormApp1\bin\ImmunityScans\ransomwareStatic.pyw" + " " + fullFileName; //args is path to .py file and any cmd line args
            ranStat.UseShellExecute        = false;
            ranStat.RedirectStandardOutput = true;
            using (Process process = Process.Start(ranStat))
            {
                using (StreamReader reader = process.StandardOutput)
                {
                    string result = reader.ReadToEnd();
                    Console.Write(result);
                }
            }

            StreamReader f1   = new StreamReader(@"C:\Users\niluf\Desktop\Immunity\ImmunityApp\ImmunityFormApp1\bin\common\ranStatLevel.txt");
            string       ranS = "";

            ranS = f1.ReadLine();
            f1.Close();

            StreamWriter truncFile = File.CreateText(@"C:\Users\niluf\Desktop\Immunity\ImmunityApp\ImmunityFormApp1\bin\common\ranStatLevel.txt");

            truncFile.Flush();
            truncFile.Close();

            if (ranS == "0000" || ranS == "5555")
            {
                Console.WriteLine("ERROR");
            }
            else if (ranS == "1111")
            {
                MessageBox.Show("File not Supported");
                this.Hide();
                Home H3 = new Home();
                H3.ShowDialog();
                this.Close();
                this.Dispose();
            }
            ranStatLevel = float.Parse(ranS);
            Console.WriteLine("ranStatLevel:");
            Console.WriteLine(ranS);

            ProcessStartInfo spyStat = new ProcessStartInfo();

            spyStat.FileName               = @"C:\Users\niluf\Desktop\Immunity\ImmunityApp\ImmunityFormApp1\bin\ImmunityScans\venv\Scripts\pythonw.exe";               //cmd is full path to python.exe
            spyStat.Arguments              = @"C:\Users\niluf\Desktop\Immunity\ImmunityApp\ImmunityFormApp1\bin\ImmunityScans\spywareStatic.pyw" + " " + fullFileName; //args is path to .py file and any cmd line args
            spyStat.UseShellExecute        = false;
            spyStat.RedirectStandardOutput = true;
            using (Process process = Process.Start(spyStat))
            {
                using (StreamReader reader = process.StandardOutput)
                {
                    string result = reader.ReadToEnd();
                    Console.Write(result);
                }
            }

            StreamReader f2   = new StreamReader(@"C:\Users\niluf\Desktop\Immunity\ImmunityApp\ImmunityFormApp1\bin\common\spyStatLevel.txt");
            string       spyS = "";

            spyS = f2.ReadLine();
            f2.Close();

            StreamWriter truncFile2 = File.CreateText(@"C:\Users\niluf\Desktop\Immunity\ImmunityApp\ImmunityFormApp1\bin\common\spyStatLevel.txt");

            truncFile2.Flush();
            truncFile2.Close();

            if (spyS == "0000" || spyS == "5555")
            {
                MessageBox.Show("error from spyware ML");
            }
            if (spyS == "1111")
            {
                MessageBox.Show("File not Supported");
                this.Hide();
                Home H3 = new Home();
                H3.ShowDialog();
                this.Close();
            }
            spyStatLevel = float.Parse(spyS);
            Console.WriteLine("spystatlevel:");
            Console.WriteLine(spyS);

            mlresults();
        }