[VB.NET] LOGICIEL POUR DE/CRYPTER UNE APPLICATION DANS UNE IMAGE

Paradise'

Premium
Inscription
30 Juin 2013
Messages
4 259
Réactions
4 384
Points
20 795
wPwVpv.png

[VB.NET] LOGICIEL POUR DE/CRYPTER UNE APPLICATION DANS UNE IMAGE


[tabs]
[tab=Informations concernant ce tutoriel]• Temps de lecture : 15 minutes.
Temps de rédaction : 02 heures.
Difficulté : ★★★
Matériel requis : Ordinateur sous Windows XP/Vista/7/8/8.1, Visual Studio, Cryptexe.dll
Tutoriel proposé par la GTP, écris par Boosterz GTP.
[/tab]
[tab=Téléchargements]Cryptexe.dll : | |
Je tiens à précisé les assemblys sont réalisé par moi pour vous faire gagné du temps.
Code source : | |
[/Tab]
[/tabs]
1407685278-ligne.png

yr0hAy.png

PRÉSENTATION DU LOGICIEL.

Donc dans ce premier chapitre je vais vous présentez le logiciel quand dans le second chapitre je vous apprendrez à créer.
Ce logiciel est une application pratique car elle permet de cacher un .exe derrière une image donc si vous avez des applications que vous ne voulez pas montrez au grand publique il est fait pour vous.
Attention si vous perdez la clef de cryptage et le mutex le logiciel sera perdu à tout jamais derrière cette image, voila pourquoi je vous conseil de tout de même le noté dans un coins de votre pc.
f069f6d9aea2caf2fdc07f4dcd7cd813.gif

Dans ce tutoriel je vous montrerez comment faire seulement la partie :
  • Encrypt Image
  • Decrypt Image
Tout simplement car la partie Options est quelque chose que tout le monde peut faire avec un peu de bonne volonté.

1407685278-ligne.png

TN60TL.png

TUTORIEL.

Alors donc avant de commencé je vais vous dire le nom des items.
Textbox de " Image Source " : src_image_2crypt
Textbox de " Image Cryptée " : crypted_output_image
Textbox de " Application " : src_file_2crypt
Textbox de " Clef de cryptage " : crypting_key
Textbox de "Mutex " : crypting_mutex

Textbox de " Image Cryptée " : crypted_intput_image
Textbox de " Decrypt Fichier " : decrypt_filename
Textbox de " Clef de cryptage " : crypted_key
Textbox de " Mutex " : crypted_mutex

Donc maintenant on va passer au codage.
Vous mettez l'utilisation de Cryptexe.dll
Code:
Imports Cryptexe
Ensuite les variables.
Code:
    Dim SourceFNameFull, SourceFNameLite As String
    Dim EncryptFNameFull, EncryptFNameLite As String
    Dim OuputFNameFull As String
    Dim CurrentMUTEX, CurrentKey As String
f519de29ae9e6efc5ea458c992a0f413.png

Donc ensuite on met un code à l'ouverture de l'application
Code:
        crypting_key.Text = ByteArrayToString(MakeRandomKey(30))
        crypting_mutex.Text = "MUTEX-" & random_digit(5) & "-" & random_digit(2)


        CurrentMUTEX = crypting_mutex.Text
        CurrentKey = crypting_key.Text
        crypted_key.Text = CurrentKey
        crypted_mutex.Text = CurrentMUTEX
41a0014cccc6eaefc845f7061ba2553a.png

Voila donc c'est déjà bien :) vous aurez quelques erreurs, ne vous en faites pas c'est de passage.
Donc ensuite on continue sur les fonctions !
La fonction Random :
Code:
    Public Function random_string(ByVal lenght As Integer) As String
        Randomize()
        Dim s As New System.Text.StringBuilder("")
        Dim b() As Char = "1ABCDE2FGHIJ3KLMNO4PQRST5UVWXY6Zabcd7efghi8jklmn9opqrs0tuvwxyz".ToCharArray()
        For i As Integer = 1 To lenght
            Randomize()
            Dim z As Integer = Int(((b.Length - 2) - 0 + 1) * Rnd()) + 1
            s.Append(b(z))
        Next
        Return s.ToString
    End Function
8af6882a5d3f64ecd6d12bf22a1b8e6f.png

Donc je ne vais pas vous mettre un screen sur chaque fonction.
Code:
    Public Function random_digit(ByVal lenght As Integer) As String
        Randomize()
        Dim s As New System.Text.StringBuilder("")
        Dim b() As Char = "1234567890".ToCharArray()
        For i As Integer = 1 To lenght
            Randomize()
            Dim z As Integer = Int(((b.Length - 2) - 0 + 1) * Rnd()) + 1
            s.Append(b(z))
        Next
        Return s.ToString
    End Function

Code:
    Public Function StringToByteArray(ByVal TextString As String) As Byte()
        Return System.Text.Encoding.Default.GetBytes(TextString)
    End Function

Code:
    Public Function ByteArrayToString(ByVal TextBytes As Byte()) As String
        Return System.Text.Encoding.Default.GetString(TextBytes)
    End Function

Code:
    Public Function MakeRandomKey(ByVal KeyLenth As Integer) As Byte()
        Return StringToByteArray(random_string(KeyLenth))
    End Function

Voila pour les fonctions c'est fait ! :D
Donc ensuite on passe aux boutons !
Donc on commence par le cryptage:
Bouton de génération d'une nouvelle clef et d'un nouveau mutex :
Code:
        crypting_key.Text = ByteArrayToString(MakeRandomKey(30))
        crypting_mutex.Text = "MUTEX-" & random_digit(5) & "-" & random_digit(2)
        CurrentMUTEX = crypting_mutex.Text
        CurrentKey = crypting_key.Text

Bouton pour chercher les images et l'application dans votre PC :
Code:
        Dim OFileDialog1 As New OpenFileDialog
        OFileDialog1.Title = "Choisir l'image source à crypter"
        OFileDialog1.Filter = "JPEG Files (.jpg)|*.jpg|PNG Files (.png)|*.png|Bitmap Files (.bmp)|*.bmp|GIF Files (.gif)|*.gif|Icon Files (.ico)|*.ico"
        If Not OFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then Exit Sub
        src_image_2crypt.Text = OFileDialog1.FileName
        SourceFNameFull = OFileDialog1.FileName
        SourceFNameLite = OFileDialog1.SafeFileName

        Dim OFileDialog2 As New OpenFileDialog
        OFileDialog2.Title = "Choisir le fichier à crypter"
        OFileDialog2.Filter = "Executable Files|*.exe;*.com;*.scr|Library Files (.dll)|*.dll|All Files|*.*"
        If Not OFileDialog2.ShowDialog = Windows.Forms.DialogResult.OK Then Exit Sub
        src_file_2crypt.Text = OFileDialog2.FileName
        EncryptFNameFull = OFileDialog2.FileName
        EncryptFNameLite = OFileDialog2.SafeFileName

        Dim SFileDialog As New SaveFileDialog
        SFileDialog.Title = "Choisir le chemin de sortie de l'image"
        SFileDialog.Filter = "JPEG Files (.jpg)|*.jpg|PNG Files (.png)|*.png|Bitmap Files (.bmp)|*.bmp|GIF Files (.gif)|*.gif|Icon Files (.ico)|*.ico"
        If Not SFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then Exit Sub
        crypted_output_image.Text = SFileDialog.FileName
        OuputFNameFull = SFileDialog.FileName

Et le bouton pour crypté :
Code:
       Dim src_bytes As Byte() = IO.File.ReadAllBytes(SourceFNameFull)
        Dim cry_bytes As Byte() = IO.File.ReadAllBytes(EncryptFNameFull)

        Dim cry_password As Byte() = StringToByteArray(crypting_key.Text)
        Dim trg_body As String = String.Empty

        trg_body += ByteArrayToString(src_bytes)

        trg_body += crypting_mutex.Text
        trg_body += ByteArrayToString(cry_password)

        trg_body += crypting_mutex.Text
        trg_body += EncryptFNameLite

        trg_body += crypting_mutex.Text
        trg_body += src_bytes.Length.ToString

        trg_body += crypting_mutex.Text
        trg_body += "#CRC#"

        trg_body += crypting_mutex.Text
        cry_bytes = Cryptexe.Cryptexe.RC4EnDeCrypt(cry_bytes, cry_password)
        trg_body += ByteArrayToString(cry_bytes)

        Dim trg_bytes As Byte() = StringToByteArray(trg_body)
        IO.File.WriteAllBytes(OuputFNameFull, trg_bytes)

        Dim msg As String = "File " & EncryptFNameLite & " succeed crypted!" & vbCrLf & vbCrLf & "Encrypted size: " & _
            src_bytes.Length.ToString & " Byte(s)" & vbCrLf & crypting_mutex.Text & vbCrLf & _
            "Secure Key: " & crypting_key.Text & vbCrLf & vbCrLf & _
            "Crypted File: " & vbCrLf & OuputFNameFull
        MsgBox(msg, MsgBoxStyle.Exclamation, "Image Crypter")

Donc voila :D Ensuite le décryptage :
Le bouton pour cherche l'image crypté et l'enregistrement :
Code:
       If Trim(crypted_mutex.Text).Length = 0 Then Exit Sub

        Dim OFileDialog As New OpenFileDialog
        OFileDialog.Title = "Choix ne l'image à décrypter"
        OFileDialog.Filter = "JPEG Files (.jpg)|*.jpg|PNG Files (.png)|*.png|Bitmap Files (.bmp)|*.bmp|GIF Files (.gif)|*.gif|Icon Files (.ico)|*.ico"
        If Not OFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then Exit Sub
        crypted_intput_image.Text = OFileDialog.FileName

        Dim src_bytes As Byte() = IO.File.ReadAllBytes(crypted_intput_image.Text)
        Dim src_text As String = ByteArrayToString(src_bytes)

        Dim check_mutex = Split(src_text, crypted_mutex.Text)
        If check_mutex.Length = 1 Then
            decrypt_filename.Text = "Mauvais mutex ou fichier non crypter"
            Exit Sub
        End If

        Dim check_crypted = Split(src_text, crypted_mutex.Text)(4)
        If check_crypted = "#CRC#" Then
            decrypt_filename.Text = Split(src_text, crypted_mutex.Text)(2) & " // " & _
                Split(src_text, crypted_mutex.Text)(3) & " Byte(s)"
        Else
            decrypt_filename.Text = "L'image cryptée est corrompu!"
        End If

Et pour finir le bouton pour décrypté :
Code:
        If Trim(decrypt_filename.Text).Length = 0 Then Exit Sub
        If Trim(crypted_intput_image.Text).Length = 0 Then Exit Sub
        If decrypt_filename.Text = "Mauvais mutex ou image non crypté" Then Exit Sub
        If decrypt_filename.Text = "L'image est corompue" Then Exit Sub
        If IO.File.Exists(crypted_intput_image.Text) = False Then Exit Sub

        Dim src_bytes As Byte() = IO.File.ReadAllBytes(crypted_intput_image.Text)
        Dim src_text As String = ByteArrayToString(src_bytes)

        Dim key_check = Split(src_text, crypted_mutex.Text)(1)
        If Not key_check = crypted_key.Text Then
            MsgBox("Incorrect key!")
            Exit Sub
        End If

        Dim SFileDialog As New SaveFileDialog
        SFileDialog.Title = "Sauvegarder le logiciel"
        SFileDialog.FileName = Split(src_text, crypted_mutex.Text)(2)
        If Not SFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then Exit Sub

        Dim crypted_bytes As Byte() = StringToByteArray(Split(src_text, crypted_mutex.Text)(5))
        Dim decrypted_bytes As Byte() = Cryptexe.Cryptexe.RC4EnDeCrypt(crypted_bytes, StringToByteArray(crypted_key.Text))

        IO.File.WriteAllBytes(SFileDialog.FileName, decrypted_bytes)
        Dim msg As String = "File " & Split(src_text, crypted_mutex.Text)(2) & " succeed decrypted into:" & _
            vbCrLf & SFileDialog.FileName
        MsgBox(msg, MsgBoxStyle.Exclamation, "Image Crypter")

1407685278-ligne.png


1407687234-finish.png

FIN DU TUTORIEL

Merci à tous d'avoir lu ce tutoriel, je vous dis à très bientôt pour de prochains tutoriels ! :tchuss:

Sujet rédigé entièrement par Boosterz GTP


 

Crocus31

Premium
Inscription
22 Janvier 2014
Messages
3 539
Réactions
1 465
Points
9 696
Super tuto merci a toi ! :D

Toi qui est fort en VB, pourrai tu me dire si ça serai possible de crypter le code source d'un logiciel ? :)
 

Paradise'

Premium
Inscription
30 Juin 2013
Messages
4 259
Réactions
4 384
Points
20 795
Super tuto merci a toi ! :D

Toi qui est fort en VB, pourrai tu me dire si ça serai possible de crypter le code source d'un logiciel ? :)

Oui si tu veux je pourrai ( futur proche ) faire un tutoriel pour créer un crypter, pas le meilleur mais bon.. Sinon sur google tu as plein de logiciel
 
Haut