LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   wordlist generator ! (https://www.linuxquestions.org/questions/linux-newbie-8/wordlist-generator-906159/)

noony123 10-03-2011 04:36 AM

wordlist generator !
 
Hi all.

Is there any sort of wordlist generator. Like i want to create words containing lower case and digits of 8 characters. Is there any tool available in linux to do it ? also can the tool in advance tell me how much space shall be required to store the file.

Kindly guide me

druuna 10-03-2011 05:23 AM

Hi,

After some digging I found an old script I found on-line that creates random words based on some criteria:
Code:

#!/bin/bash
## word generator : random 'words'
##  with given length, or range
##  with choice of wharacters to be used

chars0="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"
chars1="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"
chars2="0 1 2 3 4 5 6 7 8 9"
chars3="& | é @ ⬠\" # ' ( § ^ è ! ç { à } ) - _ ° ^ \" \$ [ ] % ù £ µ = + ~ : / ; . , ? "

function increment {
    INPUT=$1
    [[ ${#INPUT} -ge $minlen ]]  && echo $1
    if [[ ${#INPUT} -lt $maxlen ]]; then
          for c in $chars; do
              increment $1$c
          done
    fi
}

function showUsage {
    echo "$0 MAXLEN [MINLEN] [a [A [n [p]]]]"
    echo
    echo "    MAXLEN    integer  Maximum lenght, or specific lengt if MINLEN is omitted"
    echo "    MINLEN    integer  Minimum lenght, equals MAXLEN if omitted"
    echo ""
    echo "    characters:"
    echo "    a    lower case    a-z"
    echo "    A    Uppercase      A-Z"
    echo "    n    numeric        0-9"
    echo "    p    punctuation    . ?"
}

## argument handler
[[ "$1" = "" ]] && showUsage && exit
maxlen=$1
[[ $2 -eq 0 ]] && minlen=$maxlen || minlen=$2

for arg in "$@"; do
    case $arg in
          a) chars="$chars $chars0" ;;
          A) chars="$chars $chars1" ;;
          n) chars="$chars $chars2" ;;
          p) chars="$chars $chars3" ;;
    esac;
done

#fallback
[[ "$chars" = "" ]] && chars="$chars0"

## kickof

for i in $chars; do
    increment $i
done

exit 0

If you run the script (./word.generator.sh 8 8 a n > 8.char.words.list), you'll get all the permutations.

I don't have a clue how large the created file will be (I'm guessing several hundred Mb, possibly a few Gb). I do know that it will take a long time to generate the output....

Hope this helps.

grail 10-03-2011 05:31 AM

Well assuming something like 'aaaaaaaa' is acceptable for all lower case and numbers and also assuming that one line per word would mean 10 characters per line (2 for \n),
then I would say about ... 11Tib (give or take)

druuna 10-03-2011 08:06 AM

Hi grail,

Quote:

Originally Posted by grail (Post 4488714)
Well assuming something like 'aaaaaaaa' is acceptable for all lower case and numbers and also assuming that one line per word would mean 10 characters per line (2 for \n),
then I would say about ... 11Tib (give or take)

Man, my estimate is way off!!

How do you calculate this? I know there are 36 possibilities at each position and you need 10 chars per permutation (assuming 8 positions). But how to calculate all this to a accurate number?

Thanks in advance.

grail 10-03-2011 01:30 PM

Well my math was a little rusty, but I used the following:
Code:

((36! / 28!)*10)/1024^4 ~ 11.1Tib

druuna 10-03-2011 03:50 PM

Hi,
Quote:

Originally Posted by grail (Post 4489000)
Well my math was a little rusty, but I used the following:
Code:

((36! / 28!)*10)/1024^4 ~ 11.1Tib

I've been playing with the above and cannot get correct numbers when creating tests. I think it has got to do with XY! not using aaaaaaaa bbbbbbbb etc

0-9 on 2 positions => 100 (10^2) combo's, not (10!/8!) => 90
0-9 on 3 positions => 1000 (10^3) combo's, not (10!/7!) => 720

Took me a while, but after trail and error I came up with this:
Code:

((36^8) * (8+1)) / 1024^4 ~= 23 Tb
Not that the OP will be happier with that number :D

Using: 4 positions, using a-z + 0-9:
Code:

$ ./word.generator.sh 4 4 a n > 4pos.36
$ ls -l 4pos.36
-rw-r----- 1 druuna internet 8398080 Oct  3 22:27 4pos.36
 $ wc -c 4pos.36
8398080 4pos.36
$ echo "((36^4) * (4+1))" | bc
8398080


grail 10-03-2011 04:13 PM

Sorry ... my bad .. was thinking about combinations instead of repeating permutations ... good catch :)

So more than double ... ouch


All times are GMT -5. The time now is 10:46 PM.