Exemple #1
0
        private void ScanFile(object fileName)
        {
            if (!ScanThreaded)
            {
                ScanThreaded = true;
                Thread thread = new Thread(ScanFile)
                {
                    Priority = ThreadPriority.BelowNormal, IsBackground = true
                };
                thread.Start(fileName);
                return;
            }
            ScanThreaded = false;

            ScanEventArgs args = new ScanEventArgs {
                Detections = new Dictionary <string, string>()
            };

            string path = (string)fileName;

            Http.TimeOut      = 600000;
            Http.DebugMode    = true;
            Http.AutoRedirect = true;

            FileInfo fileInfo = new FileInfo(path);

            Http.UploadData data = new Http.UploadData(File.ReadAllBytes(path), fileInfo.Name, "file");

            Http.Referer = "http://www.cyber-software.org/scan/index.php?cs=csscanner";

            NameValueCollection fields = new NameValueCollection
            {
                { "send", "Check File" },
                { "url", "http://" },
                { "domen", "http://" },
                { "pack", "http://" }
            };

            Http.HttpResponse response = Http.GetResponse(Http.Verb.POST, "http://www.cyber-software.org/scan/index.php?cs=csscanner", null, fields, data);

            args.BBCode = Http.ParseBetween(response.Html, "<textarea style=\"width: 100%; height: 200px;\">[u]", "</textarea>",
                                            "<textarea style=\"width: 100%; height: 200px;\">".Length);

            args.Rate = Http.ParseBetween(args.BBCode, "[u][b]Result:[/b][/u] ", "[u][b]", "[u][b]Result:[/b][/u] ".Length).Trim();

            args.Link = Http.ParseBetween(args.BBCode, "[url]", "[/url", "[url]".Length);

            string detections = Http.ParseBetween(args.BBCode, "[/url]", "[i]", "[/url]".Length).Trim();

            string[] lines = detections.Split('\n');
            foreach (string t in lines)
            {
                string[] x = t.Split(new string[] { "[/b] : [color=" }, StringSplitOptions.RemoveEmptyEntries);

                for (int s = 0; s < x.Length; s++)
                {
                    x[s] = x[s].Replace("[b]", "").Replace("green]", "").Replace("red]", "").Replace("[/color]", "");
                }
                args.Detections.Add(x[0].Trim(), x[1].Replace("File seems clean", "Clean").Trim());
            }

            OnScanComplete(args);
        }