public void EmptyFileNameThrows()
        {
            var subject = new MalwareScanner();

            Assert.Throws <ArgumentException>(() => subject.HasVirus(new byte[1] {
                new byte()
            }, String.Empty));
        }
        public void TestMethodShouldReturnTrue()
        {
            // If this test fails, it's because virus scanning on the machine is not working.
            var subject = new MalwareScanner(AppName);
            var result  = subject.TestIfItIsWorking();

            Assert.True(result.IsItWorking);
        }
        public void DoesNotDetectInnocuousByteArray()
        {
            var arr     = Encoding.UTF8.GetBytes(@"bob");
            var subject = new MalwareScanner(AppName);
            var result  = subject.HasVirus(arr, "bob.com");

            Assert.False(result);
        }
        public void DoesNotDetectInnocousStream()
        {
            var stream  = this.CreateStream(@"bob");
            var subject = new MalwareScanner(AppName);
            var result  = subject.HasVirus(stream, "bob.com");

            Assert.False(result);
        }
        public void CanDetectEICARInByteArray()
        {
            var arr     = Encoding.UTF8.GetBytes(@"X5O!P%@AP[4\PZX54(P^)7CC)7}" + @"$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*");
            var subject = new MalwareScanner(AppName);
            var result  = subject.HasVirus(arr, "eicar.com");

            Assert.True(result);
        }
        public void CanDetectEICARInStream()
        {
            var stream  = this.CreateStream(@"X5O!P%@AP[4\PZX54(P^)7CC)7}" + @"$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*");
            var subject = new MalwareScanner(AppName);
            var result  = subject.HasVirus(stream, "eicar.com");

            Assert.True(result);
        }
        public void HandlesStreamPositionInSeekableStream()
        {
            var stream = this.CreateStream(@"X5O!P%@AP[4\PZX54(P^)7CC)7}" + @"$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*");

            stream.Position = 10;
            var subject = new MalwareScanner(AppName);
            var result  = subject.HasVirus(stream, "eicar.com");

            Assert.True(result);
            Assert.Equal(10, stream.Position);
        }
        public MainWindowViewModel()
        {
            OpenFileCommand   = new SimpleCommand(OpenFileCommandExecute);
            OpenFolderCommand = new SimpleCommand(OpenFolderCommandExecute);
            FastScanCommand   = new SimpleCommand(FastScanCommandExecute, FastScanCommandCanExecute);
            DeepScanCommand   = new SimpleCommand(DeepScanCommandExecute, FastScanCommandCanExecute);
            Models            = new ObservableCollection <SampleViewModel>();

            ConfigGateway configGateway = new ConfigGateway();

            _fileTypeChecker = new FileTypeChecker();
            _scanner         = new MalwareScanner(configGateway.YaraPath, configGateway.IndexRule, configGateway.CustomRule, configGateway.DbPath, configGateway.QuarantinePath, configGateway.ApiKey, configGateway.StringsPath);
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var virus = Encoding.UTF8.GetBytes(
                "X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*");

            using (var scanner = new MalwareScanner())
            {
                var selfTest = scanner.TestIfItIsWorking();
                Console.WriteLine($"IsItWorking: {selfTest.IsItWorking}");
                Console.WriteLine($"Exception: {selfTest.Exception}");
                var result = scanner.HasVirus(virus, nameof(virus));
                Console.WriteLine($"HasVirus: {result}");
                //// ToDo: log positive scan result or selfTest.IsItWorking != true
            }
        }
Beispiel #10
0
        public ServerScanFileService(string applicationName)
        {
            _amsiService = new MalwareScanner(applicationName);

            _defaultFileName = System.Guid.NewGuid().ToString("n");
        }
        public void NullArrayThrowsError()
        {
            var subject = new MalwareScanner();

            Assert.Throws <ArgumentException>(() => subject.HasVirus((byte[])null, "bob"));
        }