Hash Creator - Créez vos hash simplement

Download | Vote Up (2) | Vote Down (0)
#!/usr/bin/env ruby
require 'digest/md5'
require 'digest/sha1'

####################################
##                  / Hash Creator  /                    ##
##                                                                         ##
##            -Coded by AppleSt0rm-               ##
####################################


def outputUsage()
        puts "===================== Hash Creator Usage ====================="
        puts " usage : <script> [command]   [empreinte]"
        puts " Commandes :"
        puts "        md5 [empreinte] :        Renvoi le md5 de votre hash"
        puts "       sha1 [empreinte] :        Renvoi le sha1 de votre hash"
        puts "       test [empreinte] :        Renvoi le niveau de sécurité"
        puts "       hash [empreinte] : Renvoi le hash perso"
        puts "hash+hash*n [empreinte] : Vous pouvez additionner les hashs"
        puts "hash+salt*n [empreinte] : Ajoutez simplement des Salts :)"
        puts "--------------------------------------------------------------"
        puts " example :"
        puts "       md5+md5+sha1 votremotdepasse"
        puts " md5+VotreSalt+sha1 votremotdepasse"
        puts "               sha1 votremotdepasse"
        puts "=============================================================="
end

def methode( hashMeth, hashEmpr ) #fonction d'extraction de(s) méthode(s)
        hashtag = hashMeth.split('+')
        nbrHash = hashtag.length - 1 #nombre méthodes dans hashtag
        i = nbrHash
        empreinte = hashEmpr
        until (i == -1)
                #applique du hash sur hashEmpr tant que i != -1
                if hashtag[i] == "md5"
                        empreinte = Digest::MD5.hexdigest(empreinte)
                elsif hashtag[i] == "sha1"
                        empreinte = Digest::SHA1.hexdigest(empreinte)
                else
                        empreinte = hashtag[i]+empreinte
                end
                i -= 1
        end
        puts empreinte
end
def md5(empreinte)
        empreinte = Digest::MD5.hexdigest(empreinte)
        return empreinte
end
def sha1(empreinte)
        empreinte = Digest::MD5.hexdigest(empreinte)
        return empreinte
end
def test(empreinte)
        tag = empreinte.split('')
        nbrTag = tag.length
        a = 0
        if nbrTag < 6
                puts empreinte + " > Mot de passe Médiocre."
        elsif nbrTag >= 6 && nbrTag < 10
                if empreinte.match(/[a-z]/)
                        a += 1
                        if empreinte.match(/[A-Z]/)
                                a += 1
                                if empreinte.match(/[0-9]/)
                                        a += 1
                                        if empreinte.match(/[\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\?\@\[\\\\\\\]\_\`\{\|\}\~\]]/)
                                                a += 1
                                        end
                                end
                        end
                end
                if a <= 2
                        puts empreinte + " > Mot de passe Mauvais."
                elsif a > 2 && a <= 5
                        puts empreinte + " > Mot de passe Moyen."
                end
        elsif nbrTag >= 10 && nbrTag <= 16
                if empreinte.match(/[a-z]/)
                        a += 1
                        if empreinte.match(/[A-Z]/)
                                a += 1
                                if empreinte.match(/[0-9]/)
                                        a += 1
                                        if empreinte.match(/[\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\?\@\[\\\\\\\]\_\`\{\|\}\~\]]/)
                                                a += 1
                                        end
                                end
                        end
                end
                if a <= 2
                        puts empreinte + " > Mot de passe Suffisant."
                elsif a > 2 && a <= 5
                        puts empreinte + " > Mot de passe Très suffisant."
                end
        elsif nbrTag > 16
                if empreinte.match(/[a-z]/)
                        a += 1
                        if empreinte.match(/[A-Z]/)
                                a += 1
                                if empreinte.match(/[0-9]/)
                                        a += 1
                                        if empreinte.match(/[\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\?\@\[\\\\\\\]\_\`\{\|\}\~\]]/)
                                                a += 1
                                        end
                                end
                        end
                end
                if a <= 2
                        puts empreinte + " > Mot de passe Bon."
                elsif a == 3
                        puts empreinte + " > Mot de passe Très bon."
                elsif a > 3
                        puts empreinte + " > Mot de passe Excelent !"
                end
        else 
                puts "Impossible de lire le mot de passe"
        end
end
def hash(empreinte)
        nomUser = exec("grep $USER /etc/passwd | cut -d: -f5")
        emp = md5(nomUser+empreinte)
        emp2 = md5(nomUser+emp)
        empF = md5(emp2)
        puts "le hash perso est md5(md5(Nom_User.md5(Nom_User.Mot_De_Passe))) et donne :"
        puts empF
end
if not ARGV[0].nil?
        if ARGV[0] == "test"
                if not ARGV[1].nil?
                        test(ARGV[1])
                else
                        outputUsage()
                end
        elsif ARGV[0] == "hash"
                if not ARGV[1].nil?
                        hash(ARGV[1])
                else
                        outputUsage()
                end
        elsif not ARGV[1].nil?
                hashMeth = ARGV[0]
                hashEmpr = ARGV[1]
                methode(hashMeth , hashEmpr)
                
        else
                outputUsage()
        end
else
        outputUsage()
end

AppleStorm


Be the first to give feedback !

Please login to comment !