server monitoring


+ Reply to Thread
Results 1 to 7 of 7

Thread: Word List Generator

  1. #1
    Join Date
    Jan 2005
    Location
    <(o)><(o)>
    Posts
    623

    Word List Generator

    This tool is a basic word generator. It will create every possible combination for the character set you supply. It runs on my computer (AMD athlon 64 Bit 2.2 GHZ 2GB RAM) at over 500,000 combinations a second. I wrote this to compare run times of C++ & PHP, but I'm sure you can think of many uses for it:

    Sorry for the weird layout. My compiler was acting up with tabs.
    Code:
    #include <iostream>
    #include <string>
    #include <time.h>
    #include <stdlib.h>
    #include <fstream>
    using namespace std;
    
    int main()
    {   // DATA ENTRY BEGIN --------------------------------------------------------
        system("cls");
        unsigned short int error=0;
        string poss;//POSSIBLE CHARACTER COMBINATIONS
        unsigned short int pass;//MAXIMUM PASSWORD LENGTH
        string password; //ACTUAL PASSWORD
        unsigned short int found=0;
        
        cout << "SELECT CHARACTER SET:\n\n";
        cout << "\t1. abcdefghijklmnopqrstuvwxyz\n";
        cout << "\t2. ABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
        cout << "\t3. 0123456789\n\n";
        cout << "\t4. 1&2\n";
        cout << "\t5. 1&2&3\n";
        cout << "\t6. Other\n\t";
        cout << "----------------------------------\n\t";
        
        unsigned short int choice; // SELECTION FROM CHARACTER SET
        string dataset; //STRING FOR CHARACTER SET
        cin >> choice;    
        
        switch ( choice ) {
        
          case 1 : 
            // Process for test = 1
            dataset="abcdefghijklmnopqrstuvwxyz";
            break;
        
          case 2 : 
            // Process for test = 5
            dataset="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            break;
        
          case 3 : 
            // Process for test = 5
            dataset="0123456789";
            break;
        
          case 4 : 
            // Process for test = 5
            dataset="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
            break;
            
          case 5 : 
            // Process for test = 5
            dataset="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            break;
        
          case 6 : 
            // Process for all other cases.
            cout << "\nENTER YOUR OWN CHARACTER SET: ";
            cin >> dataset;
            break;
            
          default :
            error=1;
        
        }
        if(error==0){
            poss=dataset;
            
            cout << "\nENTER PASSWORDS MAXIMUM LENGTH: ";
            cin >> pass;
            
            unsigned short int i=0;
            while(poss[i])
            {
                          i++;
            }
                
            int pass_array[pass-1];
            unsigned short int j=0;
            while(j<pass)
            {
                          pass_array[j]=0;
                          j++;
            }
            
            unsigned short int comb_max=i-1; // SIZE OF COMBINATIONS ARRAY
            signed short int pass_max=j-1; // MAXIMUM SIZE OF PASSWORD
            
            signed short int pointer; //POINTER WILL EQUAL THE CURRENT PASS SIZE
            // THIS ENABLES THE FLOATING POINT TO CHANGE THE COMBINATIONS
            
            unsigned int counter=0; // COUNTER FOR EACH COMBINATION TRY
            
            // DATA ENTRY END ----------------------------------------------------------
            
            // OPENS THE TEXT FILE TO WRITE PASSWORDS TO
            ofstream myfile;
            myfile.open ("c:\\passwords.txt");
            // -----------------------------------------    
            
            // ---- start timer ----
            time_t start,end;
            double dif;
            time (&start);
            
            while(pass_max>=0)
            {
            do
            {
                     pointer=pass_max;
                     while(pass_array[pointer]<=comb_max)
                     {
                                                         string curr;//  CURRENT PASSWORD TRY
                                                         counter++;
                                                         j=0;
                                                         while(j<=pass_max)
                                                         {
                                                                           curr+= poss[pass_array[j]];
                                                                           j++;
                                                         }
                                                         myfile << curr << " \n";
                                                         pass_array[pointer]=pass_array[pointer]+1;
                     }
                     pass_array[pointer]=0;
                     pointer--;
                     while(pass_array[pointer]==comb_max)
                     {
                                                         pass_array[pointer]=0;
                                                         pointer--;
                     }
                     pass_array[pointer]=pass_array[pointer]+1;
            }
            while(pointer>=0);
            
            pass_max--;
            }
            // ---- end timer ----
            end:
            time (&end);
            dif = difftime (end,start);
            
            // ---- close text file ---- //
            myfile.close();
            // ------------------------- //
            
            // ----- DISPLAY RESULTS ---- //
            unsigned int combinations_per_second;
            combinations_per_second=counter/dif;
            system("cls");
            cout << "\nWORDLIST CREATED";
            cout << "\n------------------------------";
            cout << "\nRUN TIME:\t " << dif << " sec";
            cout << "\nCOMBINATIONS:\t " << counter;
            cout << "\nCOMB/SEC: \t " << combinations_per_second;
            cout << "\n\n\n";
            system("pause");
            return 0;
        }else{
            cout << "\tINVALID CHOICE!";
            system("pause");      
        }   
    }
    [url=http://www.syntaxmaster.info/tools/services.php]Speed Up Windows XP[/url]
    [url=http://www.syntaxmaster.info/tools/ip.php]Get An Ip Address[/url]
    [url=http://www.syntaxmaster.info/tools/base_converter.php]Base Converter[/url]
    --------------------------------
    [URL=http://www.boninroad.com/syntaxmaster/]Old Site[/URL]
    [URL=http://www.syntaxmaster.info]Comming Soon[/URL]

  2. #2
    Join Date
    Sep 2006
    Location
    Eat
    Posts
    1,655
    Man, I wish I had the time to learn all this programming that you have, I feel like a nub

    Once again, nice work SyntaX!

  3. #3
    Join Date
    Sep 2005
    Location
    UK
    Posts
    2,054
    Remember that all system() function usage slows programs down, so don't use them in any loops or CPU-intensive parts.

    It doesn't look like you did. Good.

  4. #4
    Join Date
    Sep 2006
    Location
    Eat
    Posts
    1,655
    He used system('pause') in the last while loop of his code, dunno if that counts or not.

  5. #5
    Join Date
    Sep 2005
    Location
    UK
    Posts
    2,054
    Probably not; if the intention is to pause, CPU usage won't be a concern.

    Yeah, it's ok.

  6. #6
    Join Date
    Jan 2005
    Location
    <(o)><(o)>
    Posts
    623
    Very good job. I was wondering about something like this. Too bad you need a separate program to make the hashes though.
    Actually You dont need a separate program, I just havn't figured out how to use the hash.h files associated with c++. If you can demonstrate the use of the function I can easily add it in.
    [url=http://www.syntaxmaster.info/tools/services.php]Speed Up Windows XP[/url]
    [url=http://www.syntaxmaster.info/tools/ip.php]Get An Ip Address[/url]
    [url=http://www.syntaxmaster.info/tools/base_converter.php]Base Converter[/url]
    --------------------------------
    [URL=http://www.boninroad.com/syntaxmaster/]Old Site[/URL]
    [URL=http://www.syntaxmaster.info]Comming Soon[/URL]

  7. #7
    Join Date
    Jan 2005
    Location
    <(o)><(o)>
    Posts
    623
    LOL, Its funny you mention that because I actually have written all that already. I output the combinations to a file using c++ (because its the fastest). Then I run a PHP script (because I cant figure out md5 in c++) that takes the output and hashes each one. Then I run another c++ script (because its the fastest) that compares each line of the file to passwords. LoL Crazy stuff, but whatever works right?

    About your code
    Your code crashes because 1 is always 1 and that will fall into an infinite loop.

    poss is an array. Lets say poss is this: poss=array("55","2","whatever")
    This means that poss[i] is pointing to an element in the array only when i is 0,1,2.
    Once i=3 poss[3] does not exist so it returns FALSE. This makes it fall out of the loop.

    IN PHP IT IS A LITTLE DIFFERENT
    Code:
    $test=array("55","2","whatever"); $i=0;
    
    while(isset($test[$i])){
        echo "SET AND NO ERRORS";
        $i++;
    }
    You will get a WARNING (not exactly an error) if you do it this way:
    Code:
    $test=array("55","2","whatever"); $i=0;
    
    while($test[$i]){
        echo "SET AND NO ERRORS";
        $i++;
    }
    It will throw a warning in your PHP logs about '3'. I try to keep my logs completely clean of warnings and errors. This way you can really see when something is going wrong.
    Last edited by SyntaXmasteR; 08-30-2007 at 11:47 AM.
    [url=http://www.syntaxmaster.info/tools/services.php]Speed Up Windows XP[/url]
    [url=http://www.syntaxmaster.info/tools/ip.php]Get An Ip Address[/url]
    [url=http://www.syntaxmaster.info/tools/base_converter.php]Base Converter[/url]
    --------------------------------
    [URL=http://www.boninroad.com/syntaxmaster/]Old Site[/URL]
    [URL=http://www.syntaxmaster.info]Comming Soon[/URL]

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts