random passwords from manpages

2023-04-23T13:45:12Z

Reading StackOverflow, I ran into a command to generate a list of words picked randomly in a wordlist or in a manpage.

I found the idea quite funny and challenged myself to make it a thing.

Find below a script to choose a random manpage on the system and pick randoms words to generate a memorable password :

#!/bin/sh
# Random memorable password from manpages
# license: MIT 
# usage : rdmempw.sh  (default: 6)

# default is 6 words
[[ $1 -gt 0 ]] && w=$1 || w=6

# find a random manpage
manpage="$((apropos -s 1 .; apropos -s 5 .; apropos -s 6 .) |\
	sort -R |\
	awk '{sub("\\(.*|,", "", $1); print $1; exit}')"

man $manpage |\
	tr " " "\n" |\
	sort -Ru |\
	awk -v w="$w" '
	# keep only word at least 4 char long
	/^[[:alnum:][:digit:]]{4,}$/ {
		pw = pw $0
		n++
		if (n > w) { exit }
		pw = pw "-"
	}
	END { print pw }
'

As you can see, "apropos" gives a list of availables manpages. I only use sections 1, 5 and 6 since the others are quite complex.

I use a lot of "sort -R" to randomize the wordlists.

Then, "awk" print the manpage, removing parentheses.

After, I call "man" and "tr" to replace every spaces with newlines so I can randomize with "sort" the wordlist. "awk" is used again to store words long enough in a string. When anough words are picked, we exit and display the password.

=> I've updated my online password generator if you want to try.

I guess it could be faster by using a cache.

Comments?

=> Comments by mail | Mailing list instructions

Proxy Information
Original URL
gemini://si3t.ch/log/2023-04-23-random-passwords-from-manpages.txt
Status Code
Success (20)
Meta
text/plain
Capsule Response Time
490.055699 milliseconds
Gemini-to-HTML Time
0.407722 milliseconds

This content has been proxied by September (3851b).