0

I am trying to create a wordlist of 16 positions words using the charset mixalpha-numeric-all from the charset list came with crunch (/usr/share/crunch/).

I tried this command:

crunch 16 16 -f /usr/share/crunch/charset.lst mixalpha-numeric-all -d 1@,%^

but the result is : abababab... i want : abcdef012.-& (not necessary in order but without any repetition in the rest)

if 'a' is used, cant be reused in the other 15 positions and so one.

While I post this, I am trying to combine with other programs as sed. But never used before so any help will be appreciated.

Update: I couldn't find a way to use sed to do it, so i made my own script.

#!/usr/bin/env bash

word=$1
char_count=0
word_length=${#word}

function log {
  echo $1 >> log.txt 
} 

log "Word to validate: $word"
log "Word length: $word_length"

#RETURN: 0 = char no repited, 1 = char repited
function checkRepetition {    
   #Repetitions of the letter. 1 rep is allowed, because is the   same char/position on the string
    local rep=0

    for (( j=0; j<$word_length; j++ )); do
    
    local char=${word:$j:1}
    
    log "Value of position ( $j ) on the compared string IS: $char"

    if [ $1 = $char ]; then
        let "rep++"
    fi
    if [ $rep -eq 2 ]; then
        echo "The char ( $char ) has been found twice."            
        return 1
    fi

done

return 0 }

 for (( i=0; i<$word_length; i++ )); do

   char_to_compare=${word:$i:1}

    log "Value of position ( $i ) to compare inside function IS: $char_to_compare"

    checkRepetition $char_to_compare

    if [ $? -eq 0 ]; then
      echo "For now the word looks VALID"
      let "char_count++"
      echo "Checking next position..."
    else
      echo "The word has repetead chars, so is NOT VALID"
      break 
    fi

done

if [ $char_count -eq $word_length ]; then
   echo "The word is VALID."
   echo "Adding word to file."
   echo $word >> wordlist.txt
fi

Now I am trying to make crunch pass each generated word to this script, no luck yet without having to save it to a file first. Again, any help will be appreciated.

Thanks

Infofly
  • 1
  • 3

1 Answers1

0

I found the way using xargs -L1

crunch 16 16 -f /usr/share/crunch/charset.lst mixalpha-numeric-all -d 1@,%^ | xargs -L1 ./delete_repeat_pattern.sh

This method causes error because they are too many arguments. Thanks to a friend found a simple solution. Surround my script with:

cat - | while read LINE
do
  word=$LINE

  the code of my script..

done
Infofly
  • 1
  • 3