3

I have a giant text file of potential passwords that I use for ethical pen-testing. I want to get a bit more variation of my passwords by getting the first letter of a given password to be capitalized. In the past I used

sed -e "s/\b\(.\)/\u\1/g"

and

sed 's/\b\([[:alpha:]]\)\([[:alpha:]]*\)\b/\u\1\L\2/g'

to either cap the first letter (first example), or cap first letter and force the rest to lower case (second example). But now I have a new problem. My source file looks like this:

password
p@ssword
123password
!!123password
!@#000password

I would like the output to be:

Password
P@ssword
123Password
!!123Password
!@#000Ppassword

sed, tr or awk need to be smart enough to look for the first a-z character and capitalize that, instead of focusing on the first character, seeing that it is a number or symbol and moving on without fixing my word.

Is there a way to do that?

1 Answer 1

6

sed will do just fine as it defaults to replace only the fist match if you omit the global modifier:

sed 's/\([[:alpha:]]\)/\U\1/'

But in general you wouldn't do this manually but let the cracking tools do the magic automatically with rules enabled.

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .