Batch Index du Forum
S’enregistrerRechercherFAQMembresGroupesConnexion
Répondre au sujet Page 1 sur 1
Traduire code C (Brute Force) en Vbscript
Auteur Message
Répondre en citant
Message Traduire code C (Brute Force) en Vbscript 
Salut Wink
J'ai vu ce code dans le net en C qui traite le "Brute Force"

Code:
char pass[4]="aaaa";
for(a='a'; a<'z'; a++) {
    pass[0] = a;
    for(b='a'; b<'z'; b++) {
        pass[1] = b;
        for(c='a'; c<'z'; c++) {
            pass[2] = c;
            for(d='a'; d<'z'; d++) {
                pass[3] = d;
                verify_pass(pass);
            }
        }
    }
}

Alors je me demande s'il ya une âme charitable de le traduire en vbscript !
Merci !




______________________________________________________
Mes Contributions en Téléchargement
Message Publicité 
PublicitéSupprimer les publicités ?


Répondre en citant
Message Traduire code C (Brute Force) en Vbscript 
Voila : (Il y a surement un moyen plus simple/opti de le faire mais bon)
Code:

dim pass : pass = Array("a", "a", "a", "a")
dim chars : chars = Split("a b c d e f g h i j k l m n o p q r s t u v w x y z")

for each a in chars
   pass(0) = a
   for each b in chars
      pass(1) = b
      for each c in chars
         pass(2) = c
            for each d in chars
            pass(3) = d
            verifypass(strpass)
         next
      next
   next
next
wscript.quit

function strpass
   for each item in pass
      strpass = strpass + item
   next
end function

sub verifypass(str)
   ' Ton code
end sub





______________________________________________________
MineBat

Keep programming
Répondre en citant
Message Traduire code C (Brute Force) en Vbscript 
Salut IronBatcher Wink et un grand merci à vous de votre aide Okay
Voilà, j'ai bien adapté votre code avec un ajout d'une fonction qui calcule le temps passé pour cracker le mot de passe saisi avec InputBox !



Code:
Title = "Password Brute Force Cracker by Hackoo 2018"
Dim pass(5)
Dim Numbers : Numbers = Split("1 2 3 4 5 6 7 8 9 0")
Dim Lower_Alphabet : Lower_Alphabet = Split("a b c d e f g h i j k l m n o p q r s t u v w x y z")
Dim Upper_Alphabet : Upper_Alphabet = Split("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z")
Do
   Mot_de_Passe_Saisi = InputBox("Veuillez saisir un mot de passe qui contient seulement 6 caractères." & vbcrlf & vbcrlf &_
   "Please enter a password that contains only 6 characters.",Title,"")
   If Mot_de_Passe_Saisi = "" Then Wscript.Quit(1)
   If Valide(Mot_de_Passe_Saisi) = False Then
      MsgBox Mot_de_Passe_Saisi & " is not a valid input please re-try again !",48,Title
   End If
Loop Until Valide(Mot_de_Passe_Saisi) = True
'--------------------------------------------------
   dtmStartTime = Timer
   Wscript.echo("")
   Wscript.echo "   Please wait ... We are trying to crack the input password ..."
   wscript.echo "            Trying to crack only with Numbers [0-9]"
   Call BruteForce(Numbers)
   wscript.echo "            Trying to crack only with Lower Alphabet [a-z]"
   Call BruteForce(Lower_Alphabet)
   wscript.echo "            Trying to crack only with Upper Alphabet [A-Z]"
   Call BruteForce(Upper_Alphabet)
'--------------------------------------------------
Function Valide(Saisie)
   Set RegularExpressionObject = New RegExp
   With RegularExpressionObject
      .Pattern = "^(?=.{6}$) *\w* *$"
      If .Test(Saisie)= True then
         Valide = True
      end if
   End With
End Function
'-------------------------------------------------
Sub BruteForce(CharSet)
for each a in CharSet
   pass(0) = a
   for each b in CharSet
      pass(1) = b
      for each c in CharSet
         pass(2) = c
         for each d in CharSet
            pass(3) = d
            for each e in CharSet
               pass(4) = e
               for each f in CharSet
                  pass(5) = f
                  Crack(strpass)
               next
            next
         next
      next
   next
next
End Sub
'--------------------------------------------
Function strpass
   for each item in pass
      strpass = strpass + item
   next
end Function
'--------------------------------------------
sub Crack(str)
   If str = Mot_de_Passe_Saisi then
      wscript.echo("")
      wscript.echo "            The Password is found as :  " & Mot_de_Passe_Saisi & vbCrlf & vbCrlf &_
      "          The Duration time to crack is " & GetElapsedTime
      wscript.echo("")
      wscript.quit(0)
   End if
end sub
'--------------------------------------------
Function GetElapsedTime
    Const SECONDS_IN_DAY    = 86400
    Const SECONDS_IN_HOUR   = 3600
    Const SECONDS_IN_MINUTE = 60
    Const SECONDS_IN_WEEK   = 604800
    dtmEndTime = Timer
    seconds = Round(dtmEndTime - dtmStartTime, 2)
    If seconds < SECONDS_IN_MINUTE Then
        GetElapsedTime = seconds & " seconds "
        Exit Function
    End If
    If seconds < SECONDS_IN_HOUR Then
        minutes = seconds / SECONDS_IN_MINUTE
        seconds = seconds MOD SECONDS_IN_MINUTE
        GetElapsedTime = Int(minutes) & " minutes " & seconds & " seconds "
        Exit Function
    End If
    If seconds < SECONDS_IN_DAY Then
        hours   = seconds / SECONDS_IN_HOUR
        minutes = (seconds MOD SECONDS_IN_HOUR) / SECONDS_IN_MINUTE
        seconds = (seconds MOD SECONDS_IN_HOUR) MOD SECONDS_IN_MINUTE
        GetElapsedTime = Int(hours) & " hours " & Int(minutes) & " minutes " & seconds & " seconds "
        Exit Function
    End If
    If seconds < SECONDS_IN_WEEK Then
        days    = seconds / SECONDS_IN_DAY
        hours   = (seconds MOD SECONDS_IN_DAY) / SECONDS_IN_HOUR
        minutes = ((seconds MOD SECONDS_IN_DAY) MOD SECONDS_IN_HOUR) / SECONDS_IN_MINUTE
        seconds = ((seconds MOD SECONDS_IN_DAY) MOD SECONDS_IN_HOUR) MOD SECONDS_IN_MINUTE
        GetElapsedTime = Int(days) & " days " & Int(hours) & " hours " & Int(minutes) & " minutes " & seconds & " seconds "
        Exit Function
    End If
End Function
'--------------------------------------------


Donc il vaut mieux de lancer ce vbscript avec le moteur cscript comme dans ce batch Okay
Code:
@echo off
Title Cracking Password by Hackoo Crackoo 2018
Mode 70,10 & color 0A
Cscript //nologo BruteForce.vbs
pause


Je vais laisser cette discussion ouverte dont le but d'ajouter et de discuter sur autres codes comme C++ et d'essayer de les traduire et on va prendre bien sûr le meilleur de ces derniers du côté optimistion de temps et de calcul Okay




______________________________________________________
Mes Contributions en Téléchargement
Répondre en citant
Message Traduire code C (Brute Force) en Vbscript 
Intéressant mais limiter, un peu d'aide Okay : http://batch.xoo.it/t5935-Bruteforce-exe.htm?q=bruteforce#p44594




______________________________________________________
C:\Ma chaine Youtube_
 
D:\Mon forum_
 
Répondre en citant
Message Brute Force en C++ 
Bonjour Wink
J'ai trouvé un autre code en C++ :
Code:
[lang=C]
// *** SIMPLE C++ BRUTE FORCE EXAMPLE CODE ***
// written by malo1992
//
// Completely open source, do what you want with it.
// Have fun!
//
// Germany, June 2011

#include <iostream>
#include <string>
using namespace std;

/* CHARACTER LISTS */
char lower[27]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','\0'};
char upper[27]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','\0'};
char numbs[11]={'0','1','2','3','4','5','6','7','8','9','\0'};
char symbls[30]={'!','?','.',':',',','-','_','#','$','*','+','%','&','/','\\','(',')','[',']','@','=',';','{','}','<','>','|','^','"','\0'};
char alphabet[95];                // This will contain the brute force alphabet

/* VARIABLES */
string password = "";            // We will brute-force this
string bruteword = "";            // The string we want to be =password
string pw = "";        // Just a help variable; contains the matching bruteword
string letters = "";            // Letters that will be added to the current character(alphabet[X]) in order to create the bruteword
bool pw_found = false;            // Password ain't found yet.
int maxChars = 15;                // Maximum length of the bruteword (can be changed by the user)
int minChars = 1;                // Minimum length o. t. BW ( " )
int alph_length = 0;            // Length of the char alphabet

/* VOIDS */
void asdf();        // Nonsense, but funny ;P
void createAlph();        // Creates brute alphabet
void check(string bruteword);        // Checks if bruteword = password
void brute (int charsInBW, int instance, string letters);        // BRUTE BRUTE BRUTE

/* PROGRAM CODE */
int  main()
{
    // START ROUTINE //
    cout << endl;
    cout << "Enter a password to attack: ";
    cin >> password;   

    cout << endl;
    cout << "Minimum length of the bruteword(default 1): ";
    cin >> minChars;
    cout << "Maximum length of the bruteword(default 15): ";
    cin >> maxChars;

    // CREATING THE ALPHABET ARRAY //
    createAlph();

    // Right before we start...
    cout << endl;
    cout << "**" << endl;
    cout << "Password string that will be attacked: '" << password << "'" << endl;
    alph_length = strlen(alphabet);
    cout << "Brute force alphabet: " << alphabet << endl;
    cout << "Characters: " << alph_length << endl;
    asdf();        // Some useless extra feature, I was bored
    cout << "**" << endl << endl;
    cout << "Press ENTER to start brute forcing..." << endl;
    cin.get();cin.get();        // Forces the application to wait for user input

    // LET'S GO! //
    for( int i=minChars; i<=maxChars ; i++)        // Bruteword needs [i] characters.
    {        // ( e.g. the brutewords with 1 character don't match? Then use 2 characters etc etc ... )
        brute(i,0,letters);   
    }        // Read the comments in void brute() for further information.

    // FOR()-LOOP STOPPED, PASSWORD FOUND OR NOT?
    if ( pw_found )
    {   // match! :D
        cout << "Bruteforcing stopped." << endl << endl;
        cout << "PASSWORD MATCH!!! -> " << pw << endl << endl;
        cout << "Press ESCAPE to close the application...";
        cin.get();        // Forces the application to wait for user input
    }
    else
    {    // no match ... :(
        cout << "Bruteforcing stopped." << endl << endl;
        cout << "*** No matching password has been found." << endl << endl;
        cout << "Press ESCAPE to close the application...";
        cin.get();        // Forces the application to wait for user input
    }

    return 0;
}

void brute(int charsInBW, int instance, string letters)
{   
    for(int b=0; b<alph_length ; b++ )        // There are [alph_length] characters in char array alphabet( e.g.'a'=position 0 and 'z'=position 25).
    {        // Now, alphabet[b] can display every single character in the chosen alphabet.
        if( !pw_found )        // Password still unknown?
        {
            if ( instance+1 != charsInBW )        // How many characters needs the bruteword(this is told by charsInBW)? If >1, then use this ( comparable to "picture in picture" or "mise en abyme" ) ...
            {        // It creates [charsInBW-1] running brute voids(and each one of them defines exactly 1 character in the bruteword) that run within a brute void that already started(e.g. the first instance started by int main).
                brute(charsInBW, instance+1, alphabet[b]+letters);        // "instance+1": One needed brute-instance less, because a new one ... 
            }        // ... with alphabet[b]+(letters of other instances) in the "letters"-string has been started.
            else check(alphabet[b]+letters);    // This is the last instance which checks ...
        }        // ... if (current character)+(letters of all other instances) is =password.   
        else    // A matching password has been found!
        {
            b=alph_length;        // This stops the for()-loops in void brute...
            maxChars = pw.size();            // ... and in int main().
        }
    }
}

void check(string bruteword)
{
    cout << bruteword << endl;
    if ( bruteword == password )  // Bruteword matches?
    {
        pw_found = true;    // Stops the creation of instances in void brute.
        pw = bruteword;        // Writes a global string for displaying the matching bruteword in int main.
    }
}

void createAlph()        // Should be self explanatory ...
{
    cout << endl;
    string answ = "";                // This will store the user's answers during alphabet construction

    cout << "Attack with lower case letters(Y/N)? ";
    cin >> answ;
    if ( answ == "y" || answ == "Y" ) strncat_s(alphabet,sizeof(alphabet),lower,sizeof(lower));
    else if ( answ == "n" || answ == "N" ) cout << "*** No lower case letters." << endl;
    else cout << "*** Wrong input." << endl << "Lower case letters have NOT been added to the brute force alphabet." << endl;
    answ = "";         // Reset for possible rewrite

    cout << "Attack with numbers(Y/N)? ";
    cin >> answ;
    if ( answ == "y" || answ == "Y" ) strncat_s(alphabet,sizeof(alphabet),numbs,sizeof(numbs));
    else if ( answ == "n" || answ == "N" ) cout << "*** No numbers." << endl;
    else cout << "*** Wrong input." << endl << "Numbers have NOT been added to the brute force alphabet." << endl;
    answ = "";

    cout << "Attack with upper case letters(Y/N)? ";
    cin >> answ;
    if ( answ == "y" || answ == "Y" ) strncat_s(alphabet,sizeof(alphabet),upper,sizeof(upper));
    else if ( answ == "n" || answ == "N" ) cout << "*** No upper case letters." << endl;
    else cout << "*** Wrong input." << endl << "Upper case letters have NOT been added to the brute force alphabet." << endl;
    answ = "";

    cout << "Attack with symbols(Y/N)? ";
    cin >> answ;
    if ( answ == "y" || answ == "Y" ) strncat_s(alphabet,sizeof(alphabet),symbls,sizeof(symbls));
    else if ( answ == "n" || answ == "N" ) cout << "*** No symbols." << endl;
    else cout << "*** Wrong input." << endl << "Symbols have NOT been added to the brute force alphabet." << endl;
    answ = "";
}

void asdf()
{
    string first = "";
    string last = "";
    char cFirst=alphabet[0];
    char cLast=alphabet[alph_length-1];

    for(int i=1; i<=minChars;i++)
    {
        first=first+cFirst;
    }

    for(int i=1; i<=maxChars;i++)
    {
        last=last+cLast;
    }

    cout << "Going to attack from '" << first << "' to '" << last << "'!" << endl;
}
//
// END OF FILE





______________________________________________________
Mes Contributions en Téléchargement
Répondre en citant
Message Traduire code C (Brute Force) en Vbscript 
Salut Wink
Voici une petite mise à jour avec une barre d'attente en HTA Okay



https://pastebin.com/uZsJYmhU



Dernière édition par Hackoo le Dim 9 Sep 2018 - 23:37; édité 1 fois

______________________________________________________
Mes Contributions en Téléchargement
Répondre en citant
Message Traduire code C (Brute Force) en Vbscript 
Salut,

J'ai lu ton code, mais ça ne me semble pas d'un grand intérêt mis
à part faire mouliner inutilement le CPU. Y'a pas d'application
concrète, surtout en vbs.



Message Traduire code C (Brute Force) en Vbscript 


Montrer les messages depuis:
Répondre au sujet Page 1 sur 1
  



Index | créer un forum | Forum gratuit d’entraide | Annuaire des forums gratuits | Signaler une violation | Conditions générales d'utilisation
Copyright 2008 - 2016 // Batch