Solved

fastest method to make a wordlist.

Posted on 2004-10-20
7
275 Views
Last Modified: 2006-11-17
Hi,

1)I want to make a wordlist with all possible words (a-zzzzz ; for example).  (the same as here: http://www.apocalypseonline.com/security/tools/redirect.asp?red_tool=dictmake.zip )
What is the fastest way to do this (I allready made the part which writes to the disk): finding the "next in line" (for example : if you have a the "next" function should give b, if you have zz, it should give aaa).
2)If you do a "typedef special_char char"->you make a type "special_char" which is exactly the same as a char;
and you want tonoverload the operator++ for special_char's, is it also overloaded for char's in that case? If so, what should you do to make that it is only overloaded for special_char's and not for char's ??


Thanks in advance.
0
Comment
Question by:Kappa_Alfa_Kappa
  • 4
  • 3
7 Comments
 
LVL 1

Expert Comment

by:gugario
ID: 12358971
You would have to make a second class if you wanted a separate operator.  Typedefing simply means "this expression now is the same as this other one".  But you don't need overloaded operators for that problem, you could do this:

char increaseChar (char value)
{        
    if  (value != ' z' ) return ( char (value + 1) );
    else return 'a';
}

string getNext ( string current )
{
         int i = current.size()-1;   //start at last
         while ( 1 )
         {
                   if (i == -1) //got to the end, and it's all "a's now"
                   {
                            current = "a" + current;
                            break;
                   }
                   current[i] == increaseChar(current[i]);
                   if (current[i] != 'a')  break;  //you didn't overflow.
           }
           return current;
}
             
             





0
 

Author Comment

by:Kappa_Alfa_Kappa
ID: 12363834
Thanks for your code. I tried it.


/////
#include <windows.h>
#include <iostream>
using namespace std;

char increaseChar (char value);
char * getNext ( char * current );
#define MAXLEN 10
int main(int argc, char* argv[])
{
      char  zz[MAXLEN]="ezze";
      for(int i=0; i<20;i++){
            printf(getNext(zz));
      printf("\n");}
      return 0;
}

char increaseChar (char value)
{        
   if  (value != ' z' ) return ( char (value + 1) );
   else return 'a';
}

char * getNext ( char * current )
{
        int i = strlen(current)-1;   //start at last
        while ( 1 )
        {
                  if (i == -1) //got to the end, and it's all "a's now"
                  {
                           current = "a" ;                                             ;
                           break;
                  }
                  current[i] = increaseChar(current[i]);
                  if (current[i] != 'a')  break;  //you didn't overflow.
          }
          return current;
}
////
but after the "z" it goes to the next in line in ascii->"{" and so on ({|}~&#8962;Çüéâäàåç....).
and when it reaches the last one, the lengthdoesn't increases (doesn't goes from ZZ->AAA)...
I think it has something to do with me replacing the string to char* 's, but I'm not sure....

Thaks again for your help.
0
 

Author Comment

by:Kappa_Alfa_Kappa
ID: 12364135
found it:
it works like that:
////////////
char increaseChar (char value)
{        
   if  (value != 'z' ) return ( char (value + 1) );
   else return 'a';
}

char * getNext ( char * current )
{int k;
        int i =k= strlen(current)-1;   //start at last
        while(1){  


        current[i] = increaseChar(current[i]);
                  if (current[i] == 'a')
                              {      i--;
                                    if(i==-1)
                                          {current[k+1]='a';
                                          }
                              }
                          else break;  
            }
          return current;
}
//////////
Do you happen to see severe errors??? (I'm only a beginner).

Thanks.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Kappa_Alfa_Kappa
ID: 12364354
hmmm.... sorry but it was wrong after all.
here is my current code:
/////

char * getNext ( char * current )
{int k;
        int i =k= strlen(current)-1;  

        while(1){  
        current[i] = increaseChar(current[i]);
                  if (current[i] == 'a')
                              {      i--;
                                    if(i==-1)
                                          {current[k+1]='z';
                                          i=strlen(current)-1;
                                          }
                              }
                          else break;  
            }
          return current;
}
//////
which gives:
....  x       y       z       ba      bb      bc ....
.... zy      zz      aba     abb     abc     abd ....

Do you know what is wrong with it ??

Thanks.
0
 
LVL 1

Expert Comment

by:gugario
ID: 12364775
i'm taking a look right now... i'll get back to you shortly!
0
 
LVL 1

Accepted Solution

by:
gugario earned 125 total points
ID: 12365157
Ok, that's not too bad...
change:
                           if(i==-1)
                                   {current[k+1]='z';
                                   i=strlen(current)-1;
                                   }
to:
                            if(i==-1)
                                   {current[k+1]='a';
                                   break;
                                   }

Do you understand why?  For instance, if the initial string was 'zzz', by the time it gets to i = -1, it would be 'aaa', so all we do is add the extra 'a' to the end, and we get "aaaa"....
0
 

Author Comment

by:Kappa_Alfa_Kappa
ID: 12367051
That works indeed. When I see it I understand why ( If I do it really slow with an example...).

Thanks a lot for all your help.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now