Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            TotalMessage msg = new TotalMessage("Delete Threats", "Are you sure you want to delete all threats?", MessageBoxButtons.YesNo);
            DialogResult res = msg.ShowDialog();

            if (res == DialogResult.Yes)
            {
                string file;
                bool   not_removed = false;
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    if (dataGridView1.Rows[i].Cells[2].Value.ToString().Equals("Detected"))
                    {
                        file = dataGridView1.Rows[i].Cells[1].Value.ToString();
                        try
                        {
                            if (File.Exists(file))
                            {
                                File.Delete(file);
                            }


                            dataGridView1.Rows[i].Cells[2].Value           = "Removed";
                            dataGridView1.Rows[i].Cells[2].Style.ForeColor = label_color;
                        }
                        catch
                        {
                            try
                            {
                                Process[] processCollection = Process.GetProcesses();
                                foreach (Process p in processCollection)
                                {
                                    try
                                    {
                                        if (p.MainModule.FileName.Equals(file))
                                        {
                                            p.Kill();
                                        }
                                    }
                                    catch
                                    { }
                                }
                                File.Delete(file);
                            }
                            catch
                            {
                                not_removed = true;
                            }
                        }
                    }
                }

                if (not_removed)
                {
                    TotalMessage not_removed_msg = new TotalMessage("Delete Threats Error", "Something went wrong, could not delete some file(s).", MessageBoxButtons.OK);
                    not_removed_msg.ShowDialog();
                }
            }
        }
Beispiel #2
0
        private bool IsAnyKeyValid()
        {
            if (!Settings.isPremium() && !Settings.isPublic())
            {
                TotalMessage msg = new TotalMessage("Scan Error", "No available key found!", MessageBoxButtons.OK);
                msg.ShowDialog();
                msg.Dispose();
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            TotalMessage msg = new TotalMessage("Delete Threat", "Are you sure you want to delete this threat?", MessageBoxButtons.YesNo);
            DialogResult res = msg.ShowDialog();

            if (res == DialogResult.Yes)
            {
                string file = label4.Text;

                try
                {
                    if (File.Exists(file))
                    {
                        File.Delete(file);
                    }
                    else
                    {
                        TotalMessage not_removed_msg = new TotalMessage("Delete Threat Error", "File has been moved or already deleted!", MessageBoxButtons.OK);
                        not_removed_msg.ShowDialog();
                    }

                    parentform.SetFileRemovedInRow(reportid);
                }
                catch
                {
                    try
                    {
                        Process[] processCollection = Process.GetProcesses();
                        foreach (Process p in processCollection)
                        {
                            try
                            {
                                if (p.MainModule.FileName.Equals(file))
                                {
                                    p.Kill();
                                }
                            }
                            catch
                            { }
                        }
                        File.Delete(file);
                    }
                    catch
                    {
                        TotalMessage not_removed_msg = new TotalMessage("Delete Threat Error", "Something went wrong, could not delete some file(s).", MessageBoxButtons.OK);
                        not_removed_msg.ShowDialog();
                        return;
                    }
                }
                button1.Hide();
            }
        }
Beispiel #4
0
        private void btn_Exit_Click(object sender, EventArgs e)
        {
            TotalMessage msg = new TotalMessage(Settings.AppName, "Are you sure you want to exit?", MessageBoxButtons.YesNo);

            if (msg.ShowDialog() == DialogResult.Yes)
            {
                notifyIcon.Visible = false;
                notifyIcon.Icon    = null;
                notifyIcon.Dispose();
                msg.Dispose();
                Application.Exit();
            }
            msg.Dispose();
        }
Beispiel #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            TotalMessage msg = new TotalMessage("Clear History", "Are you sure you want to clear the history?", MessageBoxButtons.YesNo);
            DialogResult res = msg.ShowDialog();

            if (res == DialogResult.Yes)
            {
                if (File.Exists(Settings.ReportsFile))
                {
                    File.Delete(Settings.ReportsFile);
                }
                parentform.last_history = 1;
                parentform.btn_History_Click(null, null);
            }
        }
Beispiel #6
0
        public async Task <bool> CheckForInternetConnection()
        {
            bool res = await Settings.IsInternetAvailable();

            if (!res)
            {
                if (net_msg != null)
                {
                    net_msg.Close();
                }
                net_msg = new TotalMessage("Scan Error", "No internet connection :( ", MessageBoxButtons.OK);
                net_msg.ShowDialog();
                net_msg = null;

                return(false);
            }
            return(true);
        }
Beispiel #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            TotalMessage msg = new TotalMessage("Files Scan", "Are you sure you want to cancel the scan?", MessageBoxButtons.YesNo);

            openedmsg = msg;
            if (msg.ShowDialog() == DialogResult.Yes)
            {
                foreach (var key in tasks.Keys.ToList())
                {
                    tasks[key] = true;
                }

                timer1.Stop();
                timer1.Enabled   = false;
                progressBar1.Tag = -1;
                TogglePanel(panel1, false);
                TogglePanel(panel2, false);
            }
        }
Beispiel #8
0
        public void AddToScan(string file, int scan_cmd)
        {
            if (AnyTaskActive())
            {
                if (msg_already_running == null)
                {
                    TotalMessage msg = new TotalMessage("Files Scan", "There is already an active scan running", MessageBoxButtons.OK);
                    msg_already_running = msg;
                    msg.ShowDialog();
                    msg.Dispose();
                    msg_already_running = null;
                    return;
                }
            }

            if (!IsAnyKeyValid())
            {
                return;
            }

            if (!queue_enabled)
            {
                if (scan_cmd == 1 && parent.Visible && parent.opened_runsafe)
                {
                    parent.HideForm();
                    parent.opened_runsafe = false;
                }


                queue_enabled = true;
                Task.Run(() => CloseQueue((scan_cmd == 1) ? true : false));
                upload_files.Clear();
            }

            if (queue_enabled)
            {
                upload_files.Add(file);
            }
        }
Beispiel #9
0
        private async Task <bool> ScanFiles(string taskid, bool runsafe)
        {
            Keys keys = Settings.GetKeys();

            bool PremiumAvailable = keys.key[1].value != null && !String.IsNullOrEmpty(keys.key[1].value);
            bool PublicAvailable  = keys.key[0].value != null && !String.IsNullOrEmpty(keys.key[0].value);
            bool PremiumActive    = keys.key[1].active;
            bool PublicActive     = keys.key[0].active;


            string key;
            int    scannedfiles = 0;
            int    totalfiles   = upload_files.Count;
            int    threatsfound = 0;
            bool   ispremium    = PremiumAvailable && PremiumActive;

            if (ispremium)
            {
                key = keys.key[1].value;
            }
            else
            {
                if (PublicAvailable && PublicActive)
                {
                    key = keys.key[0].value;
                }
                else
                {
                    return(false);
                }
            }

            List <string> active_avs = Settings.GetActiveAVs();
            AV_Reports    av_reports;

            try
            {
                av_reports = (AV_Reports)Settings.Get_Settings(typeof(AV_Reports));
            }
            catch
            {
                av_reports            = new AV_Reports();
                av_reports.av_reports = new List <AV_Report>();
            }

            List <string> queued_files = new List <string>();

            if (totalfiles == 1)
            {
                UpdateCurrentFile(upload_files[0]);
            }


            pictureBox4.Image   = Properties.Resources.loading;
            pictureBox4.Enabled = true;


            timer1.Enabled = true;
            timer1.Stop();
            timer1.Interval = 1000;
            start_time      = DateTime.Now;
            timer1.Start();
            timer1_Tick(null, null);


            foreach (var file in upload_files)
            {
                await Task.Delay(1000);


                AV_Report report = await VT_API.ScanFile(file, key, active_avs, false, ispremium, this);

                if (TaskCanceled(taskid))
                {
                    return(false);
                }


                if (report == null)
                {
                    queued_files.Add(file);
                }
                else
                {
                    UpdateCurrentFile(file);
                    av_reports.av_reports.Insert(0, report);
                    scannedfiles++;
                    if (VT_API.IsThreat(report))
                    {
                        threatsfound++;
                    }
                    UpdateLabels(scannedfiles, totalfiles, threatsfound);
                }
            }

            foreach (var file in queued_files)
            {
                UpdateCurrentFile(file);

                AV_Report report = await VT_API.ScanFile(file, key, active_avs, true, ispremium, this);

                if (TaskCanceled(taskid))
                {
                    return(false);
                }



                av_reports.av_reports.Insert(0, report);
                scannedfiles++;
                if (VT_API.IsThreat(report))
                {
                    threatsfound++;
                }
                UpdateLabels(scannedfiles, totalfiles, threatsfound);
            }



            Settings.Save_Settings(av_reports);
            tasks.Remove(taskid);
            timer1.Stop();
            timer1.Enabled = false;
            TogglePanel(panel1, false);
            TogglePanel(panel2, false);

            progressBar1.Tag = -1;

            FilesNum fileinfo = new FilesNum(totalfiles);

            fileinfo.threats  = threatsfound;
            fileinfo.duration = "0";
            fileinfo.duration = label15.Text;

            parent.last_history = 1;
            parent.btn_History_Click(fileinfo, null);

            if (openedmsg != null)
            {
                openedmsg.Close();
                openedmsg = null;
            }

            if (runsafe)
            {
                if (threatsfound > 0)
                {
                    notify_form.SetLabelMsg("Threats Found, no file(s) opened.", Color.FromArgb(192, 0, 0));
                    notify_form.ToggleButton(true);
                }
                else
                {
                    await Task.Run(() => StartFiles());

                    notify_form.SetLabelMsg("No Threats Found. Opening File(s)", Color.Green);
                    notify_form.DelayedClose(3000);
                }
            }

            return(true);
        }