Jun 29, 2010 03:00 PM
(This post was last modified: Jun 29, 2010 10:53 PM by [Eprouvez].)
Generator Class
Hey guys, recently I made a class that gives you:
- Random Key
- Random Numbers
- Random Symbols
- Random Strings
- CodeDom - Change Icon & Assembly
- Assembly Information
And here it is for free, with no sh!tcash.
This was made in Visual Basic 2010.
Code
Imports System.Reflection
Public Class Generator
Public Class Random
Public Shared Function Key(ByVal Length As Integer, Optional ByVal Letters As Boolean = True, Optional ByVal Numbers As Boolean = True, _
Optional ByVal Symbols As Boolean = False) As String
Dim Append As String = Nothing, Out As String = Nothing
If Letters Then Append &= "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"
If Numbers Then Append &= "1234567890"
If Symbols Then Append &= "`~!@#$%^&*()-_=+[{]}\|;:'"",<.>/?"
Dim R As New System.Random, S As New System.Text.StringBuilder(Append)
For I = 0 To Length - 1 : Out &= S.Chars(R.Next(0, S.Length)) : Next
Return Out
End Function
Public Shared Function Letters(ByVal Length As Integer) As String
Dim R As New System.Random, S As New System.Text.StringBuilder("aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"), Out As String = Nothing
For I = 0 To Length - 1 : Out &= S.Chars(R.Next(0, S.Length)) : Next
Return Out
End Function
Public Shared Function Numbers(Optional ByVal Length As Integer = 8) As Integer
Dim R As New System.Random, S As New System.Text.StringBuilder("123456789"), Out As String = Nothing
For I = 0 To Length - 1 : Out &= S.Chars(R.Next(0, S.Length)) : Next
Return Val(Out)
End Function
Public Shared Function Numbers(ByVal Min As Integer, ByVal Max As Integer) As Integer
Dim R As New System.Random() : Return R.Next(Min, Max)
End Function
Public Shared Function Symbols(Optional ByVal Length As Integer = 8) As String
Dim R As New System.Random, S As New System.Text.StringBuilder("`~!@#$%^&*()-_=+[{]}\|;:'"",<.>/?"), Out As String = Nothing
For I = 0 To Length - 1 : Out &= S.Chars(R.Next(0, S.Length)) : Next
Return Out
End Function
End Class
Public Class CodeDom
Private _Source, _Output, _Main, _Icon As String, _Visible, _CSharp As Boolean
Public Property MainClass() As String
Get
Return _Main
End Get
Set(ByVal value As String)
_Main = value
End Set
End Property
Public Property VisibleForm() As Boolean
Get
Return _Visible
End Get
Set(ByVal value As Boolean)
_Visible = value
End Set
End Property
Public Property Source() As String
Get
Return _Source
End Get
Set(ByVal value As String)
_Source = value
End Set
End Property
Public Property CSharp As Boolean
Get
Return _CSharp
End Get
Set(ByVal value As Boolean)
_CSharp = value
End Set
End Property
Public Property Icon As String
Get
Return _Icon
End Get
Set(ByVal value As String)
_Icon = value
End Set
End Property
Sub New(ByVal Output As String)
_Output = Output
End Sub
Sub Compile()
Dim I = My.Computer.FileSystem.SpecialDirectories.Temp & "\M" & IO.Path.GetExtension(_Icon)
If _Source = Nothing Then Exit Sub
Dim CodeProvider As Object
If _CSharp Then
CodeProvider = New Microsoft.CSharp.CSharpCodeProvider
Else
CodeProvider = New Microsoft.VisualBasic.VBCodeProvider
End If
Dim Parameters As New System.CodeDom.Compiler.CompilerParameters
With Parameters
.GenerateExecutable = True
.OutputAssembly = _Output
If Not _Visible Then .CompilerOptions &= "/target:winexe"
If Not _Icon = Nothing Then
IO.File.Copy(_Icon, I)
.CompilerOptions &= " /win32icon:" & I
End If
.MainClass = _Main
.IncludeDebugInformation = False
For Each ASM In AppDomain.CurrentDomain.GetAssemblies
.ReferencedAssemblies.Add(ASM.Location)
Next
End With
Dim Results = CodeProvider.CompileAssemblyFromSource(Parameters, _Source)
If IO.File.Exists(I) Then IO.File.Delete(I)
If Results.Errors.Count > 0 Then
For Each E In Results.Errors
MsgBox(E.ErrorText)
Next
End If
End Sub
End Class
Public Class Assembly
Public Structure FileInformation
Dim FileName, Description, Company, Product, Copyright, Trademarks, OriginalName As String
Dim FileVersion As FileVersionInfo, ProductVersion As ProductVersionInfo
Public Structure FileVersionInfo
Dim Major, Minor, Build, Rivision As Integer, Full As String
End Structure
Public Structure ProductVersionInfo
Dim Major, Minor, Build, Rivision As Integer, Full As String
End Structure
End Structure
Public Shared Function GetFileVersion(ByVal File As String) As FileInformation
Dim x As New FileInformation, F As New FileInformation.FileVersionInfo, P As New FileInformation.ProductVersionInfo
Dim Diagnostic = System.Diagnostics.FileVersionInfo.GetVersionInfo(File) : x.OriginalName = Diagnostic.OriginalFilename
x.FileName = Diagnostic.FileName : x.Company = Diagnostic.CompanyName : x.Description = Diagnostic.FileDescription
x.Copyright = Diagnostic.LegalCopyright : x.Product = Diagnostic.ProductName : x.Trademarks = Diagnostic.LegalTrademarks
F.Full = Diagnostic.FileVersion : F.Major = Diagnostic.FileMajorPart : F.Minor = Diagnostic.FileMinorPart
F.Build = Diagnostic.FileBuildPart : F.Rivision = Diagnostic.FilePrivatePart
P.Full = Diagnostic.ProductVersion : P.Major = Diagnostic.ProductMajorPart : P.Minor = Diagnostic.ProductMinorPart
P.Build = Diagnostic.ProductBuildPart : P.Rivision = Diagnostic.ProductPrivatePart
x.ProductVersion = P : x.FileVersion = F : Return x
End Function
End Class
End ClassUse this class like so:
Code
Public Class Form1
Dim Title As String = "<Assembly: System.Reflection.AssemblyTitle(""[Title]"")> "
Dim Description As String = "<Assembly: System.Reflection.AssemblyDescription(""[Description]"")>"
Dim Company As String = "<Assembly: System.Reflection.AssemblyCompany(""[Company]"")>"
Dim Product As String = "<Assembly: System.Reflection.AssemblyProduct(""[Product]"")>"
Dim Copyright As String = "<Assembly: System.Reflection.AssemblyCopyright(""[Copyright]"")>"
Dim Trademark As String = "<Assembly: System.Reflection.AssemblyTrademark(""[Trademark]"")>"
Dim Version As String = "<Assembly: System.Reflection.AssemblyVersion(""[Version]"")>"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.SelectedIndex = 1
ComboBox2.SelectedIndex = 1
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Using S As New SaveFileDialog
S.FileName = "*.exe"
S.Filter = "Executable File (*.exe)|*.exe"
If S.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim Last As String = Nothing, Code As String = RichTextBox1.Text
If RichTextBox1.Text.Contains("<Assembly:") = False Then
For I As Integer = 0 To RichTextBox1.Lines.Count - 1
If RichTextBox1.Lines(I).Contains("Imports") = False Then
Last = RichTextBox1.Lines(I - 1).ToString : Exit For
End If
Next
End If
MsgBox(Last)
Dim Str As New System.Text.StringBuilder()
Str.AppendLine(Last)
Str.AppendLine(Title.Replace("[Title]", TextBox4.Text))
Str.AppendLine(Description.Replace("[Description]", TextBox5.Text))
Str.AppendLine(Company.Replace("[Company]", TextBox6.Text))
Str.AppendLine(Product.Replace("[Product]", TextBox7.Text))
Str.AppendLine(Copyright.Replace("[Copyright]", TextBox8.Text))
Str.AppendLine(Trademark.Replace("[Trademark]", TextBox9.Text))
If TextBox10.Text = Nothing Then
Str.AppendLine(Version.Replace("[Version]", "0.0.0.0"))
Else
Str.AppendLine(Version.Replace("[Version]", TextBox10.Text))
End If
Code = Code.Replace(Last, Str.ToString)
MsgBox(Code)
Dim x As New Generator.CodeDom(S.FileName)
x.MainClass = TextBox2.Text
x.Icon = TextBox3.Text
x.CSharp = CBool(ComboBox2.Text)
x.Source = Code
x.VisibleForm = CBool(ComboBox1.Text)
x.Compile()
End If
End Using
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Using O As New OpenFileDialog
O.FileName = "*.ico"
O.Filter = "Icon Files (*.ico, *.icon)|*.ico, *.icon"
If O.ShowDialog Then
TextBox3.Text = O.FileName
End If
End Using
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Using O As New OpenFileDialog
O.FileName = "*.exe"
O.Filter = "Executable Files (*.exe)|*.exe|All Files (*.*)|*.*"
If O.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim x = Generator.Assembly.GetFileVersion(O.FileName)
TextBox4.Text = x.OriginalName
TextBox5.Text = x.Description
TextBox6.Text = x.Company
TextBox7.Text = x.Product
TextBox8.Text = x.Copyright
TextBox9.Text = x.Trademarks
TextBox10.Text = x.FileVersion.Full
End If
End Using
End Sub
End ClassHere's the full project:
http://www.mediafire.com/download.php?1ntmvz2lott
I will make a new thread soon on how to use CodeDom to create stubs for Crypters and Keyloggers. (:
Thanks,
[Eprouvez]
Please credit (:
Credits to AeonHack & [Eprouvez]


