private static void Version() { ClamdClient ClamdClient = new ClamdClient("localhost", 3310, 1024); Console.WriteLine($"Version {ClamdClient.Version()}"); Console.WriteLine($"Stats {ClamdClient.Stats()}"); }
private static int doIt() { ClamdClient ClamdClient = new ClamdClient("localhost", 3310, 1024); bool ret = ClamdClient.Ping(); Console.WriteLine($"ping {ret}"); if (ret) { ClamdClient.Reload(); Console.WriteLine($"Version {ClamdClient.Version()}"); Console.WriteLine($"Stats {ClamdClient.Stats()}"); string Filepath = "c:/Users/ETService/Documents/Malware/res/Infizierter-Inhalt-3134511.doc.donotopen"; using (FileStream fileStream = File.OpenRead(Filepath)) { ClamdResult clamdResult = ClamdClient.Instream(fileStream); Console.WriteLine($"HasVirus={clamdResult.HasVirus}"); if (clamdResult.HasVirus) { foreach (InfectedFile InfectedFile in clamdResult.InfectedFiles) { Console.WriteLine($"Path:{Filepath} FileName:{InfectedFile.FileName} Virus:{InfectedFile.VirusName}"); } } } // ClamdClient.Shutdown(); } return(ret?1:0); }
private static void CheckFile(String Filepath) { ClamdClient ClamdClient = new ClamdClient("localhost", 3310, 1024); using (FileStream fileStream = File.OpenRead(Filepath)) { ClamdResult clamdResult = ClamdClient.Instream(fileStream); Console.WriteLine($"HasVirus={clamdResult.HasVirus}"); if (clamdResult.HasVirus) { foreach (InfectedFile InfectedFile in clamdResult.InfectedFiles) { Console.WriteLine($"Path:{Filepath} FileName:{InfectedFile.FileName} Virus:{InfectedFile.VirusName}"); } } } }
private static void WaitPing() { Task t = Task.Run(() => { bool ret; ClamdClient ClamdClient = new ClamdClient("localhost", 3310, 1024); do { if (!(ret = ClamdClient.Ping())) { Thread.Sleep(1000); } }while(!ret); }); TimeSpan timeSpan = TimeSpan.FromSeconds(180); if (!t.Wait(timeSpan)) { throw new TimeoutException(); } Console.WriteLine("ClamAV server available."); }
private static void Reload() { ClamdClient ClamdClient = new ClamdClient("localhost", 3310, 1024); ClamdClient.Reload(); }
public void SetupTests() { //Setup ClamdClient clamd = new ClamdClient(clamdServer, clamdPort); //Setup Scan Directories cleanScanDirectory = string.Format("{0}{1}clean{1}", baseTestDir, Path.DirectorySeparatorChar); infectedScanDirectory = string.Format("{0}{1}infected{1}", baseTestDir, Path.DirectorySeparatorChar); }
public void Ping_Connection_Refused_Fail() { ClamdClient failClamd = new ClamdClient("NO-SERVER", 3310); var result = failClamd.Ping(); Assert.IsFalse(result); }