//setup the scanner engine
        private void SetupScannerEngine()
        {
            //setup the scanner engine path
            string temp = my_location + "\\engine\\";

            //write the correct engine configurations according to path
            StreamWriter writter = new StreamWriter(temp + "clamd.conf");

            writter.WriteLine("TCPSocket 3310");
            writter.WriteLine("MaxThreads 2");
            writter.WriteLine("LogFile " + temp + "clamd.log");
            writter.WriteLine("DatabaseDirectory " + temp + "db");
            writter.Close();

            //insert the correct registry settings according to path
            //I am not using try catch block because, I am already running as admin
            //so probably it will not give error, will fix this if gives error in future
            RegistryKey key;

            key = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("Software\\ClamAV\\");
            key.SetValue("ConfigDir", temp);
            key.Close();
            key = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("Software\\ClamAV\\");
            key.SetValue("DataDir", temp + "db");
            key.Close();


            //Install the AV scanner service
            con.RunExternalExe(temp + "clamd.exe", "--install");

            //install the AV updater service
            con.RunExternalExe(temp + "freshclam.exe", "--install");

            //start the antivirus services...
            try
            {
                string status = string.Empty;
                service.ServiceName = "FreshClam";
                status = service.Status.ToString();
                if (status == "Stopped")
                {
                    service.Start();
                }

                status = string.Empty;
                service.ServiceName = "ClamD";
                status = service.Status.ToString();
                if (status == "Stopped")
                {
                    service.Start();
                }
            }
            catch
            {
                pictureBox1.Image = Properties.Resources.unsecured;
                pictureBox3.Image = Properties.Resources.cross;
                av_service_error  = true;
                MetroFramework.MetroMessageBox.Show(this, "Unable to start antivirus services, kindly restart the application or see help manual on how to start services manually", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public void FirewallStart(bool flag)
 {
     if (IsFirewallInstalled)
     {
         if (flag)
         {
             manager.LocalPolicy.CurrentProfile.FirewallEnabled = true;
         }
         else
         {
             // there will be an exception if we try to turnoff windows firewall directly via API
             ConsoleSetups con = new ConsoleSetups();
             con.RunExternalExe("netsh.exe", "Firewall set opmode disable");
         }
     }
 }
Esempio n. 3
0
 public void CreateOrUnlockFolder(Form1 main)
 {
     if (no_valut)
     {
         //there's no vault, show user first time info and take vault location and password
         MetroFramework.MetroMessageBox.Show(main, "Please create a folder anywhere in your computer and select the location of that folder. It will be used as vault and put your important files inside that folder to protect and lock it", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
         FolderBrowserDialog fbd = new FolderBrowserDialog();
         fbd.ShowNewFolderButton = true;
         fbd.Description         = "Select the folder to make a new vault";
         if (fbd.ShowDialog() == DialogResult.OK)
         {
             using (var form = new VaultPassword())
             {
                 form.Text            = "Create Password";
                 form.metroTile1.Text = "Create";
                 var result = form.ShowDialog();
                 if (result == DialogResult.OK)
                 {
                     password = form.password;
                     con.RunExternalExe("attrib.exe", "+s +h +r +a " + '"' + fbd.SelectedPath + '"');
                     SetPermission(fbd.SelectedPath, AccessControlType.Deny);
                     RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Netsky Antivirus");
                     if (key != null)
                     {
                         key.SetValue("Update", Encrypt(password, hashKey));
                         key.SetValue("UniqueID", Encrypt(fbd.SelectedPath, hashKey));
                     }
                     else
                     {
                         key = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Netsky Antivirus");
                         key.SetValue("Update", Encrypt(password, hashKey));
                         key.SetValue("UniqueID", Encrypt(fbd.SelectedPath, hashKey));
                     }
                     no_valut    = false;
                     salted_pass = password;
                     vault_loc   = fbd.SelectedPath;
                     MetroFramework.MetroMessageBox.Show(main, "Vault created successfully", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 } //end if
             }     //end using
         }         //end if
     }
     else
     {
         //vault is there, get key and open it
         using (var form = new VaultPassword())
         {
             form.Text            = "Enter password";
             form.metroTile1.Text = "Open";
             var result = form.ShowDialog();
             if (result == DialogResult.OK)
             {
                 password = form.password;
                 if (password == salted_pass)
                 {
                     SetPermission(vault_loc, AccessControlType.Allow);
                     con.RunExternalExe("attrib.exe", "-s -h -r -a " + '"' + vault_loc + '"');
                     Process.Start(vault_loc);
                 }
                 else
                 {
                     MetroFramework.MetroMessageBox.Show(main, "Invalid password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
     }
 }