2011-08-04 46 views
0

我有一個ajax上傳器允許用戶上傳圖片到程序,然後顯示回用戶。我希望在允許文件留在服務器之前檢查該文件是否有病毒。以下是將文件發送到病毒掃描程序的代碼。我希望能夠看到掃描結果是否會產生病毒,然後如果確實有病毒,請將其從服務器上刪除。如何檢查asp.net c#中的病毒掃描結果?

try 
{ 
    Process myProcess = new Process(); 
    myProcess.StartInfo.FileName = @"C:\Program Files\AVG\AVG8\avgscanx.exe"; 
    //[email protected]"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(); 
} 

回答

1

這是一種罕見的巧合,用戶上傳一個特殊的手工製作的JPG/PNG /任何圖像文件,攻擊閱讀組件/庫未知(殺毒在這種情況下無用的)漏洞。

如果已知漏洞並且您的AV知道漏洞利用簽名(或者在運行漏洞之前攔截漏洞)阻止漏洞,並且安全地保護您的系統(庫不是最新版本),那麼這種情況更爲罕見。

如果上述操作系統具有DEP和ASLR感知(完全執行)組件,則更爲罕見。