我正在试验一些十六进制扫描仪源。
以下代码有效,但速度很慢:
Public Class frmMain
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadFile.Click
Dim ArrayHold() As Byte
Dim Index As Integer = 0
Dim Str As New StringBuilder
Dim tStr As String = ""
Dim tempStr As String = ""
Dim IndexEnd As Integer = 0
Dim InputString As String = ""
OpenDia.Filter = "All Files|*.*"
If OpenDia.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim myStreamReader As StreamReader = Nothing
myStreamReader = File.OpenText(OpenDia.FileName)
InputString = myStreamReader.ReadToEnd()
ArrayHold = Encoding.Default.GetBytes(InputString)
Do
IndexEnd = Index + 9
For x As Integer = Index To IndexEnd
If x > UBound(ArrayHold) Then
tempStr = tempStr
Else
tStr = UCase(Convert.ToString(ArrayHold(x), 16))
If tStr.Length < 2 Then tStr = "0" & tStr
Str.Append(tStr)
tempStr = tempStr & Chr(ArrayHold(x))
End If
Next
Index = Index + 10
Loop While IndexEnd < UBound(ArrayHold)
If InStr(1, Str.ToString, "58354f2150254041505b345c505a58353428505e2937434329377d2445494341522d5354414e4441", vbTextCompare) Then
Label1.Text = "Eicar-test-signature virus Detected!"
End If
End If
End Sub
End Class
为了加快速度,我可以在 XML 文件中使用这种格式:
?xml version="1.0"?>
<signatures>
<signature>
<name>Eicar-Test-Signature</name>
<hex>58354f2150254041505b345c505a58353428505e2937434329377d2445494341522d5354414e4441</hex>
</signature>
<signature>
<name>Mid/Kakworm-Z</name>
<hex>66732e4372656174655465787446696c652877642b276b616b2e72656727293b74322e77726974652827524547454449</hex>
</signature>
</signatures>
但我不知道如何在 VB.NET 中读取和实现 XML 文件。很难吗,有人可以帮忙吗?