Advertisement
Ajay_kumar

Bat2exe(stub source code)

Jul 24th, 2014
793
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.27 KB | None | 0 0
  1. '   Bat2exe converter Stub Code
  2. '   Author : skyte
  3. '   http://sec-articles.blogspot.com
  4.  
  5. Imports System
  6. Imports System.IO
  7. Imports System.AppDomain
  8. Imports System.Diagnostics
  9. Imports Microsoft.VisualBasic
  10.  
  11. Module Module1
  12.  
  13.     Private Declare Auto Function GetConsoleWindow Lib "kernel32.dll" () As IntPtr
  14.     Private Declare Auto Function ShowWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean
  15.  
  16.     Private Const SW_HIDE As Integer = 0
  17.     Private Const SW_SHOW As Integer = 5
  18.  
  19.     Sub Main()
  20.         Dim hiddenmode As Boolean = False
  21.         Dim hWndConsole As Integer
  22.         hWndConsole = GetConsoleWindow()
  23.         ShowWindow(hWndConsole, SW_HIDE)
  24.        
  25.         Try
  26.             Dim exepath As String = AppDomain.CurrentDomain.BaseDirectory + Process.GetCurrentProcess.ProcessName + ".exe"
  27.             Dim tempdir As String = My.Computer.FileSystem.SpecialDirectories.Temp
  28.             'For exe path
  29.             Dim SP() As String = Split(System.IO.File.ReadAllText(exepath), "[SPLITTING_POINT]")
  30.             Dim batchf As Byte() = unsecure(Convert.FromBase64String(SP(1)))
  31.             '[BDPROC]Dim bindedf As Byte() = unsecure(Convert.FromBase64String(SP(3)))
  32.             My.Computer.FileSystem.WriteAllBytes(tempdir & "\cmd.bat", batchf, False)
  33.             '[BDPROC]My.Computer.FileSystem.WriteAllBytes(tempdir & "\" & SP(2), bindedf, False)
  34.             If hiddenmode = True Then
  35.                 Dim vbwriter As New IO.StreamWriter(tempdir + "\" + "start.vbs")
  36.                 vbwriter.WriteLine("set objShell = CreateObject(""WScript.Shell"")")
  37.                 vbwriter.WriteLine("objShell.Run """ + tempdir + "\cmd.bat"", vbHide, TRUE")
  38.                 vbwriter.Close()
  39.  
  40.                 ' run program
  41.                 Dim ps As ProcessStartInfo
  42.                 Dim psname As String = (tempdir & "\" & "start.vbs")
  43.                 ps = New ProcessStartInfo(psname)
  44.                 Dim proc As New Process()
  45.                 proc.StartInfo = ps
  46.                 proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
  47.                 proc.Start()
  48.                 proc.WaitForExit()
  49.                 File.Delete(psname)
  50.                 File.Delete(tempdir & "\" & "cmd.bat")
  51.             Else
  52.                 Dim ps As ProcessStartInfo
  53.                 Dim psname As String = (tempdir & "\" & "cmd.bat")
  54.                 ps = New ProcessStartInfo(psname)
  55.                 Dim proc As New Process()
  56.                 proc.StartInfo = ps
  57.                 proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal
  58.                 proc.Start()
  59.                 proc.WaitForExit()
  60.                 File.Delete(psname)
  61.             End If
  62.             '[BDPROC]Process.Start(tempdir & "\" & SP(2))
  63.         Catch ex As Exception
  64.             Process.GetCurrentProcess.Kill()
  65.         End Try
  66.         Process.GetCurrentProcess.Kill()
  67.  
  68.     End Sub
  69.  
  70.     Function unsecure(ByVal data As Byte()) As Byte()
  71.         Using SA As New System.Security.Cryptography.RijndaelManaged
  72.             SA.IV = New Byte() {1, 9, 2, 8, 3, 7, 4, 5, 6, 0, 1, 4, 3, 0, 0, 7}
  73.             SA.Key = New Byte() {7, 0, 0, 3, 4, 1, 0, 6, 5, 4, 7, 3, 8, 2, 9, 1}
  74.             Return SA.CreateDecryptor.TransformFinalBlock(data, 0, data.Length)
  75.         End Using
  76.     End Function
  77.  
  78. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement