最簡單的殺毒軟體測試代碼~

來源:互聯網
上載者:User

  '延時n毫秒的函數
  Private Declare Sub mSecSleep Lib "kernel32" Alias "Sleep" (ByVal lngmSec As Long)

 

  Dim VirStr As String
  Dim VirSample As String
 
  CmdVirusTest.Enabled = False
 
  '採用兩個字串串連,以保證產生病毒樣本前不會被查殺!
  VirStr = "X5O!P%@AP[4/PZX54(P^)7CC)7}"
  VirStr = VirStr + "$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"
 
  '用Date & Timer作為病毒樣本的名字,保證每次的檔案名稱都不同,使用殺毒軟體無法屏蔽
  VirSample = "c:/testvir" & Right$(Year(Now), 2) & Month(Now) & Day(Now) & Int(Timer) & ".exe"

On Error GoTo kill

  '產生病毒樣本
  Open VirSample For Output As #1
    Print #1, VirStr
  Close #1
 
  DoEvents
 
  '延遲2.5s 保證寫入檔案完成
  mSecSleep 2500
  DoEvents
 
  '訪問檔案,以備殺毒軟體偵測
On Error GoTo kill

  Open VirSample For Input As #1
    Input #1, VirStr
  Close #1
 
  '延遲5.0 s 保證殺毒軟體查詢病毒庫完成
  mSecSleep 5000
  DoEvents
 
  '檢查病毒樣本是否已被查殺
  If Dir$(VirSample) = "" Then
kill:
    MsgBox "您的殺毒軟體已經成功清除病毒樣本!", vbOKOnly
  Else
    kill VirSample
    MsgBox "警告:您的殺毒軟體未能正確檢測並查殺到病毒樣本,建議立即更換或升級您的殺毒軟體!", vbOKOnly
  End If

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.