Extracting the passwords from a multiple file wordlist (sed & grep).
M@LIK uses Windows, so his command will not work for you. For instance, ''type'' is like ''cat'' on Windows, whereas in most unix shells ''type'' shows how a command will be interpreted by the shell. And you're right, the ''cut -c9-'' probably isn't portable. Although sed -r 's/\W+[0-9]+\W+//' is a lot cleaner than sed 's/^[ ]*[1234567890]*[ ]//' if bsd sed supports that syntax.

Speaking of sed, your sed isn't different because it's older, your sed is different because it's bsd sed and not gnu sed. As you learn how to use more console utils, you'll find that the bsd variants of pretty much everything do not have even half of the options their gnu counterparts have. But, now knowing that you're on OS X, my commands probably won't work for you either.

To answer your questions,

Quote:So if I get this straight your finding every regular file in a directory

No, in a directory and all its subdirectories. If all of your files are in one directory then you wouldn't need to use 'find' in my example; I only did that because you used grep -r. In your original example, if all of your files are in one directory then you don't need to do a recursive grep, you would just do grep *. And the same goes for M@LIK as well; he wouldn't need to do 'type *.* | sed', he could just do 'sed *.*' or whatever. It's the Windows equivalent of UUoC.

Quote:sed your identifying the correct lines and replacing that with a backreference \1.

Correct. We match only the portion of the line we care about, i.e. everything after pass=. Then we print just the match that we care about. \1 is the first grouping, \2 the second, so on and so forth.

Quote:'{}' tells sed what file we're working on and I don't get the last \...

That's all part of the ''find'' command. I later modified the command to use xargs instead which is much faster when dealing with large groups of files. What I had before with using ''find -exec'' may not apply on bsd find, I can't remember.

Quote:While sorting, I wouldn't use -k1 since the output file will contain some white space in front of the numbers.

-b tells sort that whitespace doesn't matter

So -- if all your files are in one directory and you don't actually need to recursively search, and you're pretty sure that 'pass=' will always be lower case, we can clean up my command a bit. I have no idea if it will work with bsd sed, but this will probably help out some gnu users.

sed -rn 's/^pass=(.*)$/\1/p' * | sort | uniq -c | sort -bnrk 1 | sed -r 's/\W+[0-9]+\W+//'

Happy learning Smile

Messages In This Thread
RE: Extracting the passwords from a multiple file wordlist (sed & grep). - by epixoip - 06-14-2012, 08:54 PM