如何在 ASP.NET C# 中检查病毒扫描的结果?
我有一个ajax上传器,允许用户将图片上传到程序,然后该程序将显示回用户。我想在允许该文件保留在服务器中之前检查该文件是否有病毒。以下是将文件发送到病毒扫描程序的代码。我希望能够查看扫描结果是否产生病毒,然后如果确实有病毒,则将其从服务器中删除。
try
{
Process myProcess = new Process();
myProcess.StartInfo.FileName = @"C:\Program Files\AVG\AVG8\avgscanx.exe";
//myProcess.StartInfo.FileName=@"C:\Program Files\ClamWin\bin\clamscan.exe";
string myprocarg = @"""C:\Documents and Settings\Administrator.USER20501\My Documents\Luke's Projects\DADS\212\Images\FinalLogo" + file.ClientFileName + @"""";
myProcess.StartInfo.Arguments = myprocarg;
myProcess.OutputDataReceived += new DataReceivedEventHandler(myProcess_OutputDataReceived);
myProcess.ErrorDataReceived += new DataReceivedEventHandler(myProcess_ErrorDataReceived);
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
myProcess.BeginOutputReadLine();
myProcess.WaitForExit();
}
catch (Exception)
{
}
void myProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
// this value will always be null.......
string s = e.Data.ToString();
}
void myProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
string s = e.Data.ToString();
}
I have an ajax uploader to allow a user to upload a picture to the program that will display back to the user afterwards. I would like to check this file for viruses before allowing the file to stay in the server. Below is the code where it sends the file to the virus scanner. I would like to be able to see if the scan results yield a virus and then delete it from the server if it does have a virus.
try
{
Process myProcess = new Process();
myProcess.StartInfo.FileName = @"C:\Program Files\AVG\AVG8\avgscanx.exe";
//myProcess.StartInfo.FileName=@"C:\Program Files\ClamWin\bin\clamscan.exe";
string myprocarg = @"""C:\Documents and Settings\Administrator.USER20501\My Documents\Luke's Projects\DADS\212\Images\FinalLogo" + file.ClientFileName + @"""";
myProcess.StartInfo.Arguments = myprocarg;
myProcess.OutputDataReceived += new DataReceivedEventHandler(myProcess_OutputDataReceived);
myProcess.ErrorDataReceived += new DataReceivedEventHandler(myProcess_ErrorDataReceived);
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
myProcess.BeginOutputReadLine();
myProcess.WaitForExit();
}
catch (Exception)
{
}
void myProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
// this value will always be null.......
string s = e.Data.ToString();
}
void myProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
string s = e.Data.ToString();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个罕见的巧合,用户上传了一个特殊的手工制作的 jpg/png/任何图像文件,利用了读取组件/库的未知(在这种情况下防病毒软件无用)漏洞。
如果漏洞是已知的,并且您的反病毒软件知道漏洞利用签名(或在运行之前拦截漏洞利用),则更罕见的情况是阻止它并保护您的系统(使用不是最新的库)。
如果上述操作系统具有 DEP 和 ASLR 感知(完全强制执行)组件,则情况更为罕见。
It's a rare coincidence that the user uploads a special hand-crafted jpg/png/whatever image file exploiting an unknown (antivirus useless in this case) vulnerability of the reading components/libraries.
Still more rare if the vulnerability is known and your AV knows the exploit signature (or intercepts the exploit before running it) blocking it and safe-guarding your system (with libraries not up-to-date).
Even more rare if the abovementioned operating system has DEP and ASLR aware (fully enforced) components.