Post

Generate List of Possible Usernames with given names

Generate List of Possible Usernames with given names

Quick dirty bash script that generate list of possible usernames based on given full name

Example of accepted full name :

  • John Jammond
  • John.Jammond
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash

# Check for help flag or incorrect number of arguments
if [[ $1 == "-h" || $# != 2 ]]; then
    echo "Usage: namegen names-file output-file"
    exit 1
fi

# Check if output file already exists
if [ -f $2 ]; then
    echo "[!] $2 file already exists."
    exit 1
fi

# Read each line in the input file
cat $1 | while read line; do
    # Auto-format if input is in firstname.lastname format
    if [[ $line == *.* ]]; then
        line=$(echo $line | sed 's/\./ /g')
    fi
    
    firstname=$(echo $line | cut -d ' ' -f1 | tr '[:upper:]' '[:lower:]')
    lastname=$(echo $line | cut -d ' ' -f2 | tr '[:upper:]' '[:lower:]')

    echo "$firstname
$lastname
$firstname.$lastname
$(echo $firstname | cut -c1).$lastname
$(echo $firstname | cut -c1)-$lastname
$firstname$lastname
$firstname-$lastname
$(echo $firstname | cut -c1-3)$(echo $lastname | cut -c1-3)
$(echo $firstname | cut -c1-3).$(echo $lastname | cut -c1-3)
$(echo $firstname | cut -c1)$lastname
$lastname$firstname
$lastname-$firstname
$lastname.$firstname
$lastname$(echo $firstname | cut -c1)
$lastname-$(echo $firstname | cut -c1)
$lastname.$(echo $firstname | cut -c1)" >> $2
done

echo "[+] Wordlist generated and saved to $2"

  • All name will be convert to lowercase

Example Usage :

test-users

1
2
John.Ham
john doe

running the script

1
namegen test-users test-result

test-result

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
john
ham
john.ham
j.ham
j-ham
johnham
john-ham
johham
joh.ham
jham
hamjohn
ham-john
ham.john
hamj
ham-j
ham.j
john
doe
john.doe
j.doe
j-doe
johndoe
john-doe
johdoe
joh.doe
jdoe
doejohn
doe-john
doe.john
doej
doe-j
doe.j

Linking to the tool

1
sudo ln -s /path/to/tool/namegen.sh /usr/local/bin/namegen
This post is licensed under CC BY 4.0 by the author.