Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Imports System.Security
- Imports System.Security.Cryptography
- Imports MetroFramework.Forms
- Public Class Fsmain
- Function SHA256_SIG(ByVal file_name As String)
- Return SHA256_engine("SHA-256", file_name)
- End Function
- Function SHA256_engine(ByRef hash_type As String, ByRef file_name As String)
- Dim SIG
- SIG = SHA256.Create()
- Dim hashValue() As Byte
- Dim filestream As FileStream = File.OpenRead(file_name)
- filestream.Position = 0
- hashValue = SIG.ComputeHash(filestream)
- Dim hash_hex = PrintByteArray(hashValue)
- Stream.Null.Close()
- Return hash_hex
- End Function
- Public Function PrintByteArray(ByRef array() As Byte)
- Dim hex_value As String = ""
- Dim i As Integer
- For i = 0 To array.Length - 1
- hex_value += array(i).ToString("x2")
- Next i
- Return hex_value.ToLower
- End Function
- Private Sub Browsebutton_Click(sender As Object, e As EventArgs) Handles Browsebutton.Click
- If SampleFetch.ShowDialog = DialogResult.OK Then
- Dim path As String = SampleFetch.FileName
- Selectfile.Text = path
- Dim Sample As String
- Sample = SHA256_SIG(path)
- SignatureREF.Text = SHA256_SIG(path)
- Using f As System.IO.FileStream = System.IO.File.OpenRead("blacklist.txt")
- Using s As System.IO.StreamReader = New System.IO.StreamReader(f)
- While Not s.EndOfStream
- Dim line As String = s.ReadLine()
- If (line = Sample) Then
- Result.Visible = True
- SignatureREF.Visible = True
- Result.Text = "Dirty"
- Resetme.Visible = True
- RemoveMAL.Visible = True
- Else
- Result.Visible = True
- SignatureREF.Visible = True
- Result.Text = "Clean"
- Resetme.Visible = True
- RemoveMAL.Visible = False
- End If
- End While
- End Using
- End Using
- End If
- End Sub
- Private Sub Fsmain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Result.Visible = False
- SignatureREF.Visible = False
- Resetme.Visible = False
- RemoveMAL.Visible = False
- End Sub
- Private Sub Resetme_Click(sender As Object, e As EventArgs) Handles Resetme.Click
- Selectfile.Text = Nothing
- SignatureREF.Text = Nothing
- Result.Visible = False
- SignatureREF.Visible = False
- Resetme.Visible = False
- RemoveMAL.Visible = False
- End Sub
- Private Sub RemoveMAL_Click(sender As Object, e As EventArgs) Handles RemoveMAL.Click
- Dim ask As MsgBoxResult = MsgBox("Would you like to remove the Dirty file?", MsgBoxStyle.YesNo, MessageBoxIcon.None)
- If ask = MsgBoxResult.Yes Then
- System.IO.File.Delete(Selectfile.Text$)
- Else
- MsgBox("You sure you want to keep this file?")
- Dim filepath As String = IO.Path.Combine("c:Dirty", "Dirty.txt")
- Using sw As New StreamWriter(filepath)
- sw.WriteLine(" " & DateTime.Now)
- sw.WriteLine(" " & Selectfile.Text)
- sw.WriteLine(" " & SignatureREF.Text)
- sw.WriteLine(" " & Result.Text)
- sw.WriteLine("-------------------")
- sw.Close()
- End Using
- End If
- End Sub
- End Class
Add Comment
Please, Sign In to add comment