Quais são os caracteres permitidos para uma senha?

4

Eu estou pedindo o tipo de caracteres suportados por senhas de usuários (o comando passwd precisamente)

Os espaços são permitidos? Caracteres NULL (\ 0)? um subconjunto de ASCII ou mais?

Se espaços são permitidos eu preciso escapar deles?

    
por Sylvain Pineau 15.10.2014 / 18:14

1 resposta

3

Baseado em testes:

  • passwd é tratado como o fim da senha.
  • Espaços são permitidos. Embora não seja mostrado na saída abaixo, usando Ctrl V , eu pude usar Enter , Esc e outras chaves em uma senha.
$ pwgen 10 1
Pohhei8sai 
$ passwd 
Changing password for muru.
(current) UNIX password: 
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
$ printf 'Pohhei8sai\n
$ printf 'testing 1\nUuxohv\a9moo\nUuxohv\a9moo\n' | passwd
Changing password for muru.
(current) UNIX password: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
\b\n
$ pwgen 10 1
Pohhei8sai 
$ passwd 
Changing password for muru.
(current) UNIX password: 
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
$ printf 'Pohhei8sai\n
$ printf 'testing 1\nUuxohv\a9moo\nUuxohv\a9moo\n' | passwd
Changing password for muru.
(current) UNIX password: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
\b\n%pre%\b' | passwd Changing password for muru. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: No password supplied Enter new UNIX password: Retype new UNIX password: passwd: Authentication token manipulation error passwd: password unchanged $ pwgen 10 1 Uuxohv9moo $ printf 'Pohhei8sai\nUuxohvmoo\nUuxohvmoo\n' | passwd Changing password for muru. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: Bad: new password is too simple Enter new UNIX password: Retype new UNIX password: passwd: Authentication token manipulation error passwd: password unchanged $ printf 'Pohhei8sai\nUuxohv9moo\nUuxohv9moo\n' | passwd Changing password for muru. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully $ printf 'Uuxohv9moo\ntesting 1\ntesting 1' | passwd Changing password for muru. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
\b' | passwd Changing password for muru. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: No password supplied Enter new UNIX password: Retype new UNIX password: passwd: Authentication token manipulation error passwd: password unchanged $ pwgen 10 1 Uuxohv9moo $ printf 'Pohhei8sai\nUuxohvmoo\nUuxohvmoo\n' | passwd Changing password for muru. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: Bad: new password is too simple Enter new UNIX password: Retype new UNIX password: passwd: Authentication token manipulation error passwd: password unchanged $ printf 'Pohhei8sai\nUuxohv9moo\nUuxohv9moo\n' | passwd Changing password for muru. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully $ printf 'Uuxohv9moo\ntesting 1\ntesting 1' | passwd Changing password for muru. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully

De minha leitura de a fonte , a% O comandogetpass usa a função (obsoleta) read -s , que se comporta bem muito parecido com %code% (e marca o final da string de senha com %code% ). Não restringe os caracteres utilizáveis, além de algumas verificações de reutilização e complexidade. %code% não pode ser usado, pois é tratado como o marcador de fim de string normal em strings C, mas praticamente qualquer outra coisa pode, como o sino:

%pre%     
por muru 15.10.2014 / 18:39