Beispiel #1
0
        private void ShowReport()
        {
            AV_Reports reports = (AV_Reports)Settings.Get_Settings(typeof(AV_Reports));
            AV_Report  report  = reports.av_reports[reportid];

            label4.Text = report.file;
            label5.Text = report.time;

            Point offset = label3.Location;

            int distance  = 60;
            int step      = 15;
            int labelsize = 30;
            int x_step    = 200;

            font = label3.Font;

            foreach (AV_Result result in report.av_results)
            {
                distance += labelsize;
                distance += step;
                Label avname = new Label();
                avname.Location  = new Point(offset.X, offset.Y + distance);
                avname.Text      = result.av_name + ": ";
                avname.Font      = font;
                avname.ForeColor = date_color;
                avname.AutoSize  = true;

                Label av_value = new Label();
                av_value.Location = new Point(offset.X + x_step, offset.Y + distance);
                av_value.Text     = result.result;
                av_value.AutoSize = true;
                av_value.Font     = font;
                if (result.result.Equals("Clean"))
                {
                    av_value.ForeColor = clean_color;
                }
                else
                {
                    av_value.ForeColor = detected_color;
                }

                this.Controls.Add(avname);
                this.Controls.Add(av_value);
            }
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public void Reload(FilesNum files_info)
        {
            int files_num = files_info.num;

            if (parentform.last_history == 0 && files_num == 0)
            {
                return;
            }

            if (files_num != 0)
            {
                label1.Text = "Scan Results";
                TogglePanel(panel2, true);
                TogglePanel(panel3, false);

                TogglePanel(panel5, false);

                label3.Text = files_num.ToString();
                int threatsfound = files_info.threats;

                if (threatsfound > 0)
                {
                    TogglePanel(panel4, true);
                }
                else
                {
                    TogglePanel(panel4, false);
                }

                label4.Text = threatsfound.ToString();
                if (threatsfound == 0)
                {
                    label4.ForeColor = clean_color;
                }
                else
                {
                    label4.ForeColor = detected_color;
                }
                label6.Text = files_info.duration;
            }
            else
            {
                label1.Text = "Scan History";
                TogglePanel(panel2, false);
                TogglePanel(panel3, true);
                TogglePanel(panel4, false);
                TogglePanel(panel5, true);
            }


            label2.Visible = false;
            try
            {
                AV_Reports reports = (AV_Reports)Settings.Get_Settings(typeof(AV_Reports));
                if (reports.av_reports.Count == 0)
                {
                    label2.Visible = true;
                    TogglePanel(panel5, false);
                }

                LoadGridValues(reports, files_num);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                label2.Visible = true;
            }



            if (files_num == 0)
            {
                parentform.last_history = 0;
            }
            else
            {
                parentform.last_history = 1;
            }
        }
Beispiel #4
0
        private void LoadGridValues(AV_Reports reports, int files_num)
        {
            dataGridView1.Rows.Clear();

            SHA256 sha256obj = SHA256.Create();

            if (files_num == 0)
            {
                files_num = reports.av_reports.Count;
            }

            bool   threat;
            string filehash;
            int    i = 0;

            foreach (AV_Report report in reports.av_reports)
            {
                if (i == files_num)
                {
                    break;
                }
                threat = VT_API.IsThreat(report);


                if (!File.Exists(report.file))
                {
                    if (!threat)
                    {
                        dataGridView1.Rows.Add(report.time, report.file, "Removed");
                        dataGridView1.Rows[i].Cells[2].Style.ForeColor = label_color;
                    }
                    else
                    {
                        dataGridView1.Rows.Add(report.time, report.file, "Clean");
                        dataGridView1.Rows[i].Cells[2].Style.ForeColor = clean_color;
                        dataGridView1.Rows[i].Cells[3].Value           = Properties.Resources.theme_background;
                    }
                }
                else
                {
                    filehash = VT_API.BytesToHexString(sha256obj.ComputeHash(File.ReadAllBytes(report.file)));

                    if (threat && filehash.Equals(report.hash))
                    {
                        dataGridView1.Rows.Add(report.time, report.file, "Detected");
                        dataGridView1.Rows[i].Cells[2].Style.ForeColor = detected_color;
                    }
                    else
                    {
                        if (threat)
                        {
                            dataGridView1.Rows.Add(report.time, report.file, "Removed");
                            dataGridView1.Rows[i].Cells[2].Style.ForeColor = label_color;
                        }
                        else
                        {
                            dataGridView1.Rows.Add(report.time, report.file, "Clean");
                            dataGridView1.Rows[i].Cells[2].Style.ForeColor = clean_color;
                            dataGridView1.Rows[i].Cells[3].Value           = Properties.Resources.theme_background;
                        }
                    }
                }

                dataGridView1.Rows[i].Cells[0].Style.ForeColor = date_color;
                i++;
            }
            sha256obj.Dispose();

            dataGridView1.Refresh();
            dataGridView1.ClearSelection();
        }