Guest User

Untitled

a guest
Mar 19th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. Imports System.IO
  2. Imports System.Security
  3. Imports System.Security.Cryptography
  4. Imports MetroFramework.Forms
  5.  
  6. Public Class Fsmain
  7. Function SHA256_SIG(ByVal file_name As String)
  8. Return SHA256_engine("SHA-256", file_name)
  9. End Function
  10.  
  11. Function SHA256_engine(ByRef hash_type As String, ByRef file_name As String)
  12.  
  13. Dim SIG
  14. SIG = SHA256.Create()
  15. Dim hashValue() As Byte
  16.  
  17. Dim filestream As FileStream = File.OpenRead(file_name)
  18. filestream.Position = 0
  19. hashValue = SIG.ComputeHash(filestream)
  20. Dim hash_hex = PrintByteArray(hashValue)
  21.  
  22. Stream.Null.Close()
  23.  
  24. Return hash_hex
  25. End Function
  26.  
  27. Public Function PrintByteArray(ByRef array() As Byte)
  28.  
  29. Dim hex_value As String = ""
  30. Dim i As Integer
  31. For i = 0 To array.Length - 1
  32. hex_value += array(i).ToString("x2")
  33. Next i
  34.  
  35. Return hex_value.ToLower
  36. End Function
  37.  
  38. Private Sub Browsebutton_Click(sender As Object, e As EventArgs) Handles Browsebutton.Click
  39. If SampleFetch.ShowDialog = DialogResult.OK Then
  40. Dim path As String = SampleFetch.FileName
  41. Selectfile.Text = path
  42.  
  43. Dim Sample As String
  44. Sample = SHA256_SIG(path)
  45. SignatureREF.Text = SHA256_SIG(path)
  46.  
  47. Using f As System.IO.FileStream = System.IO.File.OpenRead("blacklist.txt")
  48. Using s As System.IO.StreamReader = New System.IO.StreamReader(f)
  49. While Not s.EndOfStream
  50.  
  51. Dim line As String = s.ReadLine()
  52.  
  53.  
  54. If (line = Sample) Then
  55. Result.Visible = True
  56. SignatureREF.Visible = True
  57. Result.Text = "Dirty"
  58. Resetme.Visible = True
  59. RemoveMAL.Visible = True
  60.  
  61. Else
  62.  
  63. Result.Visible = True
  64. SignatureREF.Visible = True
  65. Result.Text = "Clean"
  66. Resetme.Visible = True
  67. RemoveMAL.Visible = False
  68.  
  69. End If
  70. End While
  71. End Using
  72. End Using
  73. End If
  74. End Sub
  75.  
  76. Private Sub Fsmain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  77.  
  78. Result.Visible = False
  79. SignatureREF.Visible = False
  80. Resetme.Visible = False
  81. RemoveMAL.Visible = False
  82.  
  83. End Sub
  84.  
  85. Private Sub Resetme_Click(sender As Object, e As EventArgs) Handles Resetme.Click
  86.  
  87. Selectfile.Text = Nothing
  88. SignatureREF.Text = Nothing
  89. Result.Visible = False
  90. SignatureREF.Visible = False
  91. Resetme.Visible = False
  92. RemoveMAL.Visible = False
  93.  
  94. End Sub
  95.  
  96. Private Sub RemoveMAL_Click(sender As Object, e As EventArgs) Handles RemoveMAL.Click
  97.  
  98. Dim ask As MsgBoxResult = MsgBox("Would you like to remove the Dirty file?", MsgBoxStyle.YesNo, MessageBoxIcon.None)
  99.  
  100. If ask = MsgBoxResult.Yes Then
  101. System.IO.File.Delete(Selectfile.Text$)
  102.  
  103. Else
  104.  
  105. MsgBox("You sure you want to keep this file?")
  106. Dim filepath As String = IO.Path.Combine("c:Dirty", "Dirty.txt")
  107. Using sw As New StreamWriter(filepath)
  108. sw.WriteLine(" " & DateTime.Now)
  109. sw.WriteLine(" " & Selectfile.Text)
  110. sw.WriteLine(" " & SignatureREF.Text)
  111. sw.WriteLine(" " & Result.Text)
  112. sw.WriteLine("-------------------")
  113. sw.Close()
  114.  
  115. End Using
  116. End If
  117. End Sub
  118. End Class
Add Comment
Please, Sign In to add comment