Pipe a word list into crunch

None-yet

Member
Joined
Aug 10, 2020
Messages
78
Reaction score
32
Credits
906
I know crunch can be piped into other program. BUT, can a word list be piped into crunch to have words mixed with crunch output. I will attempt to give an example of what I mean. crunch 20%%(pipe in the names list) ^ -o new-names-list.txt In this example it would produce the end product as 2011Michelle! . Crunch would mix the years with every possibly then run down the list of names and on the end it would generate every special char and then move down the list of names. Can this be done and if so then how? Thanks

Michelle
Kaleigh
Londyn
Jazlene
Natasha
Jennifer
Jessica
Daniela
Arianna
Jacqueline
Emelia
Guadalupe
 


I haven't had much experience using crunch, so I couldn't say offhand.

But if you're literally taking a list of names and pre-pending all of the years between 2000-2099
e.g.
Code:
2000Ashleigh
2001Ashleigh
...
2099Ashleigh
2000Belinda
2001Belinda
etc etc....

Then you could probably do that using a script, which could be written in any scripting, or programming language.

Basically, in pseudo-code (assuming each name is on a single line in the name-list/input file):
Code:
while read name from name-list
{
    for number in 2000 to 2099
        output {number}{name} to output-file
}

And depending on the language you write the script in, you may have some additional steps to perform - e.g. opening and closing files.
But above is basically all you need to do.
Read a name from the name-list, generate numbers and output the number and the name to the output file.

You could do this with virtually any programming language.
 
i've looked at most of the options and haven't seen capability of it accepting any input file .

the only input that i've used is the path to a charset :

-f /path/to/charset.lst charset-name

in my case: /usr/share/crunch/ where charset-name is one of :

hex-lower = [0123456789abcdef]
hex-upper = [0123456789ABCDEF]

etc etc


of course it would be possible to do that in REVERSE i.e feed output of crunch to script.

eg say crunch outputs


Fred
Andy
Chris

then a script could add _2001 to each the above, to a file, run again _2002 erc
 
i've looked at most of the options and haven't seen capability of it accepting any input file .

the only input that i've used is the path to a charset :

-f /path/to/charset.lst charset-name

in my case: /usr/share/crunch/ where charset-name is one of :

hex-lower = [0123456789abcdef]
hex-upper = [0123456789ABCDEF]

etc etc
From looking at the man pages for crunch - I think you may be right! Which means my script suggestion is probably the best way to go for this particular problem.

@None-yet
Here's a quick and dirty python3 script written in a few minutes during my lunch break, that attempts to read the entire input file and generates the required output file.....

NOTE: At the very last minute I noticed what you posted about special characters at the end of the sequence. So I've added code that generates a sequence of special characters and appends one of each of those to the end of each year/name combo too.
e.g.
{year}{name}{special char}


Python:
#!/usr/bin/env python3

def getSpecialCharsInRange(start, end):
    ret=""
    for x in range(start,end+1):
        ret+=chr(x)
    return ret

def main():
    try:
        inputFile = open("name-list", "r")
    except:
        print("ERROR - Input file not found!")
        exit(1)

    try:
        outputFile = open("output-file", "w")
    except:
        print("ERROR - Unable to create output file")
        exit(1)

    # Generate a set of printable special characters
    # assuming UTF-8 as per:
    # https://www.utf8-chartable.de/
    specialchars=""
    specialchars += getSpecialCharsInRange(33,47)
    specialchars += getSpecialCharsInRange(58,64)
    specialchars += getSpecialCharsInRange(91,96)
    specialchars += getSpecialCharsInRange(123,126)
    specialchars += getSpecialCharsInRange(160,255)

    nameList = inputFile.readlines()
    inputFile.close()

    for name in nameList:
        if name and name.strip():
            name = name.replace('\n','').replace('\r','')
            for num in range(2000, 2099+1):
                outputFile.write(str(num)+name+"\n")
                for special in specialchars:
                    outputFile.write(str(num)+name+special+"\n")
  
if __name__ == "__main__":
    main()

Save that as whatever you like and make it executable using chmod +x {filename}
Where {filename} is whatever you called it.

I called it joinYearsAndNames (without the .py extension).

The script uses a shebang - so the shell will automatically invoke the python3 interpreter when the script is ran. Omitting the .py extension makes it seem like a normal terminal command. Especially if you put it somewhere in your path. I have a personal bin/ directory set up in my home directory which has been added to $PATH. Then you don't have to prefix the script name with ./ when you run it!! Otherwise, if it is off your path, run it using ./joinYearsAndNames - or whatever you called it!

As long as you have a file called "input-file" which contains some names - (or you have replaced "input-file" in the script with a path to a file containing a list of names) - then the script will iterate through the names, generate a sequence of numbers and output each number and the current name to the output file "output-file".
And for each year/name combo, it also writes out each one with one of each printable special character at the end.

Again - substitute "output-file" with a path/file-name to suit your needs.

By default the program expects the input and output files to be in the current directory.

I decided to use python rather than shell script, because python performs well and I think it might be faster and more robust than shellscript for this particular application.

I didn't have time to make the script more generic
e.g.
To allow it to accept arguments to define the input and output files. So it simply uses hard-coded paths to the input and output files.

But I have used pythons try/except mechanism to catch problems with the code which opens the input and output files. So it should be fairly robust.

Also, the script reads the entire name-list into memory.
If the name-list is extremely large - you might want to consider reading the input file line by line, or in blocks.
But I'll leave you to make any modifications.

FYI - On my work PC - with your list of 12 names, it generates all of the possible combinations in 0.27 seconds, yielding a 2.1Mb output file containing 154800 lines.
 
Last edited:
I only have one hand at the moment to say thank you. i will play with this. have a good day.
 

Members online


Latest posts

Top