Exemplo n.º 1
0
        private void Cleanup()
        {
            /* Save changes to the scan task */
            logger.Info("Performing cleanup actions");
            scanTask.LastCompletionTime = DateTime.Now;
            scanTask.LastWriteTime      = DateTime.Now;
            scanTask.LastRunOwner       = Utils.GetCurrentUserName();

            try
            {
                scanTask.Save(AppFolders.TaskFolder);
            }
            catch (Exception ex)
            {
                logger.Warn(ex, "Failed to update scan task");
            }

            /* Produce the report */
            logger.Info("Storing scan report");
            scanReport = new ScanReport(scanTask, detectedFiles.ToList(), scannedDirectories.Count);

            try
            {
                scanReport.Save(AppFolders.ReportFolder);
            }
            catch (Exception ex)
            {
                logger.Warn(ex, "Failed to store scan report");
            }

            logger.Info("Scan completed");
            SetScannerStatus(ScanStatus.COMPLETED);
        }
Exemplo n.º 2
0
        public async Task <ScanReport> GetScanResultFile(String scanId, String mainScanDirPath)
        {
            //JObject statusRes = await GetScanStatus(scanId, mainScanDirPath);
            ScanReport report = null;
            //Run task to read the result file
            await Task.Run(() =>
            {
                String report_path   = Path.Combine(mainScanDirPath, Constants.ScanFolderName + scanId, Constants.ScanLogFile);
                ScanStatusResult scr = ReadScanStatusFile(scanId, mainScanDirPath, Constants.ScanStatusFile, null);

                //Proceed only if this scan has actually been conducted
                //Handling possibility of user entering invalid scanId and breaking the application
                if (scr != null)
                {
                    report = new ScanReport
                    {
                        Id        = scr.Id,
                        Timestamp = DateTime.ParseExact(scr.Id, DATE_TIME_FORMAT, System.Globalization.CultureInfo.InvariantCulture).ToUniversalTime(),
                        Report    = GetScanParsedLogs(report_path)
                    };
                }
            });

            //All the contents of the file and the timestamp
            return(report);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Delete a report file.
 /// </summary>
 /// <param name="file"></param>
 public static void RemoveReport(ScanReport report)
 {
     try
     {
         File.Delete(Path.Combine(AppFolders.ReportFolder, string.Format("{0}.json", report.Guid)));
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Failed to delete report file: {0}", report.Guid);
         throw;
     }
 }
Exemplo n.º 4
0
        public ScanSession(string path, string initiator)
        {
            ScanEngine scan = new ScanEngine();

            Initiator = initiator;
            report    = new ScanReport(initiator);
            ScanObjectBuilder build       = new ScanObjectBuilder(path);
            List <ScanObject> scanObjects = build.GetObjects();

            foreach (var sObj in scanObjects)
            {
                report.AddRecord(scan.StartScanObject(sObj));
                report.scannedObjects++;
            }
        }
Exemplo n.º 5
0
        public ActionResult <ScanReport> ScanSubreddit([FromBody] ScanOrder order)
        {
            string content_string = _redditApiServices.GetSubredditString(order.subreddit_name);

            ScanReport output = new ScanReport {
                keyword_match_percentage = _scanner.ScanString(content_string, order.keywords),
                most_popular_words       = _scanner.ReturnMostFrequentKeywords(content_string, 15)
            };

            //temporary db action
            _dbContext.Subreddits.Add(new Subreddit {
                subreddit_name = order.subreddit_name
            });

            return(output);
        }
Exemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog FBD = new FolderBrowserDialog();

            FBD.ShowNewFolderButton = false;
            if (FBD.ShowDialog() == DialogResult.OK)
            {
                ScanSession session = new ScanSession(@FBD.SelectedPath, "User");

                ScanReport report = session.getReport();
                foreach (var s in report.listThread)
                {
                    string[] f = s.Split(' ');
                    listBox1.Items.Add("Расположение файла" + f[0] + "\tИмя вируса:" + f[1]);
                }
                report.SaveResult();
            }
        }
Exemplo n.º 7
0
        private void listViewReports_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selectedItemCount = listViewReports.SelectedItems.Count;

            logger.Trace("Selected listview item changed");

            if (selectedItemCount > 0)
            {
                ScanReport report = typedReportView.SelectedObject;

                this.Text = string.Format("{0}: {1}", WindowTitleBase, report.Name);

                webBrowserReport.Navigate("about:blank");
                webBrowserReport.Document.OpenNew(false);
                webBrowserReport.Document.Write(report.GenerateHTML());
                webBrowserReport.Refresh();
            }

            SetButtonStates(selectedItemCount);
            UpdateStatusBarText();
        }
Exemplo n.º 8
0
        private void toolStripButtonBrowser_Click(object sender, EventArgs e)
        {
            ScanReport report = typedReportView.SelectedObject;

            saveFileDialogReport.FileName = string.Format("{0}.html", report.Task.Name);

            DialogResult dr = saveFileDialogReport.ShowDialog(this);

            if (dr == DialogResult.OK)
            {
                try
                {
                    using (var sw = new StreamWriter(saveFileDialogReport.FileName, false))
                    {
                        logger.Debug(
                            "Exporting report {0} to {1}",
                            report.Name,
                            saveFileDialogReport.FileName);

                        sw.Write(webBrowserReport.DocumentText);
                        sw.Flush();
                    }
                }
                catch (Exception err)
                {
                    logger.Error(err, "Unable to export report as a web page.");
                    MessageBox.Show(
                        string.Format(
                            "The report could not be saved as a web page.{0}Detail:{1}",
                            Environment.NewLine,
                            err.Message),
                        "Report Manager",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1);
                }
            }
        }
Exemplo n.º 9
0
        public HttpResponseMessage UpdateScanReportStatus(string projectCode, string systemIP, string startTime, string endTime, string status, string scriptName, string hostName)

        {
            using (XoriskManagementBackendEntities db = new XoriskManagementBackendEntities())
            {
                ScanReport newReport = new ScanReport();
                newReport.CreatedAt   = DateTime.Now;
                newReport.UpdatedAt   = DateTime.Now;
                newReport.ProjectCode = projectCode;
                newReport.SystemIP    = systemIP;
                DateTime s;
                DateTime.TryParse(startTime, out s);
                DateTime e;
                DateTime.TryParse(endTime, out e);
                //DateTime startDate = Helper.GetDate(startTime);
                newReport.StartTime = s;
                newReport.EndTime   = e;
                //newReport.StartTime = Helper.GetDate(startTime);
                //newReport.EndTime = Helper.GetDate(endTime);
                //newReport.StartTime = startTime;
                //newReport.EndTime = endTime;
                newReport.Status     = status;
                newReport.ScriptName = scriptName;
                newReport.SystemMAC  = hostName;
                db.ScanReports.Add(newReport);
                db.SaveChanges();

                //newReport.Status = status;
            }
            HttpResponseMessage response = new HttpResponseMessage();

            response.StatusCode = HttpStatusCode.OK;

            return(response);

            // return new string[] { "Video/Script1.vbe", "Video/Script2.vbe", "Video/Script3.vbe", "Video/Script4.vbe" };
        }
Exemplo n.º 10
0
        public ScanReport StartScanObject(ScanObject obj)
        {
            if (obj.ScanRegions == null)
            {
                ulong      i   = 0;
                ScanReport rep = new ScanReport();
                foreach (var chobj in obj.ChildObjects)
                {
                    for (i = 0; i < chobj.SizeObject(); i++)
                    {
                        byte[] prefix = new byte[8];
                        prefix = chobj.Read(i);

                        List <ThreadSignature> signatures = tree.CheckSignature(prefix);
                        if (signatures != null)
                        {
                            foreach (var sig in signatures)
                            {
                                if (sig.SignatureFirstByteMinOffset < i && sig.SignatureFirstByteMaxOffset > i)
                                {
                                    uint   dataLength = sig.Signature.DataLength;
                                    byte[] searchSign = new byte[dataLength];
                                    searchSign = chobj.Read(i);
                                    if (sig.Signature.IsMatch(searchSign))
                                    {
                                        rep.AddRecord(new ScanReport(new string(sig.ThreadName), obj.Path + chobj.Name));
                                    }
                                }
                            }
                        }
                    }
                }
                rep.scannedObjects = i;
                return(rep);
            }
            else
            {
                for (ulong i = 0; i < obj.SizeObject(); i++)
                {
                    byte[] prefix = new byte[8];
                    prefix = obj.Read(i);

                    List <ThreadSignature> signatures = tree.CheckSignature(prefix);
                    if (signatures != null)
                    {
                        foreach (var sig in signatures)
                        {
                            if (sig.SignatureFirstByteMinOffset < i && sig.SignatureFirstByteMaxOffset > i)
                            {
                                uint   dataLength = sig.Signature.DataLength;
                                byte[] searchSign = new byte[dataLength];
                                searchSign = obj.Read(i);
                                if (sig.Signature.IsMatch(searchSign))
                                {
                                    return(new ScanReport(new string(sig.ThreadName), obj.Path));
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }