Xenon
Xenon

Reputation: 207

Wordlist Generator in Bash

I am trying to create a wordlist consisting of the same password followed by a 4-digit numeric pin. The pin goes through every possible combination of 10,000 variations. The desired output should be like this:

 UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ 1111
 UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ 1112
 UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ 1113

and so on.

I created a shell script that almost get this, but awk doesn't seem to like having a variable passed through it, and seems to just print out every combination when called. This is the shell script:

#!/bin/bash
# Creates 10,000 lines of the bandit24pass and every possible combination
# Of 4 digits pin

USER="UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ"

PASS=$( echo {1,2,3,4,5,6,7,8,9}{1,2,3,4,5,6,7,8,9}{1,2,3,4,5,6,7,8,9}{1,2,3,4,5,6,7,8,9} | awk '{print $I}' )

for I in {1..10000};
do
        echo "$USER $PASS"
done

I though $I would translate to $1 for the first run of the loop, and increment upwards through each iteration. Any help would be greatly appreciated.

Upvotes: 1

Views: 2159

Answers (2)

oguz ismail
oguz ismail

Reputation: 50805

I though $I would translate to $1 for the first run of the loop, and increment upwards through each iteration.

No, command substitutions are expanded once; like, when you do foo=$(echo), foo is an empty line, not a reference to echo.

This whole task could be achieved by a single call to printf btw.

printf 'UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ %s\n' {1111..9999}

Upvotes: 3

Digvijay S
Digvijay S

Reputation: 2715

Tyr this

$echo $user
UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ
$for i in {1000..9999}; do echo $user $i; done;

Upvotes: 1

Related Questions