|
-
Jun 22nd, 2018, 08:06 AM
#1
Thread Starter
Member
I want to use a Function inside a sub, how is this done?
I have a Private Function called GetMD5String. All this function does, is it scans for files that are being opened, and if their MD5 matches with a database, an alert is shown saying
Everything works well, however, I have one issue.
I need to refresh the GetMD5String function so that my program continues to have GetMD5String monitoring the files being opened. The way I think is the most practical way of doing it, is putting my GetMD5String function into a Timer1_Tick sub so my program can check every set interval. I've tried this, but I'm getting this error:
Argument not specified for parameter 'strFilename' of 'Private Function GetMD5String(strFilename As String) As String
I get this error when I try to pass GetMD5String() into Timer1_Tick
Is there any way I can refresh GetMD5String without needing to use a Timer? Or, by using a Timer but a different way of doing so?
GetMD5String code:
Code:
Private Function GetMD5String(ByVal strFilename As String) As String
Dim MD5 As String = GetMD5String(strFilename)
Dim cMD5 = Security.Cryptography.MD5.Create
Dim bytHash As Byte()
Dim sb As New System.Text.StringBuilder
Dim scanbox As New TextBox
scanbox.Text = My.Computer.FileSystem.ReadAllText("viruslist.txt").ToString
Me.OpenFileDialog1.FileName = strFilename
Using cStream As New IO.FileStream(strFilename, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
bytHash = cMD5.ComputeHash(cStream)
End Using
For Each c In bytHash
sb.Append(c.ToString("X2"))
Next
If scanbox.Text.Contains(sb.ToString) Then
Detect.ShowDialog()
WriteToLog("Malicious exploit detected.")
Quarantinevb.ListBox1.Items.Add(strFilename)
End If
Return sb.ToString
End Function
Thanks
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|