Fork me on GitHub

As old as good: One Time Passwords 5

People frequently ask me what I am doing typing on my Palm right before logging in one of my remote systems. The answer is quite simple: “generating my next password”. People always seem puzzled by that answer… Maybe I am just too old to have had only telnet sessions available to remote connections (that was the time before SSH took over)... or maybe I am just too paranoid regarding the access to my systems… Anyway, I like One Time Passwords, and here is an article I can refer to when I get asked again ;-)

One Time Passwords are just that: passwords that are good for one time use. They never repeat and once used you can throw it away securely. They were quite common when the authentication was done in clear text (so that any man-in-the-middle could steal your passwords), back in the r-tools age (rcp, rsh, rlogin, rexec, etc). After the SSH-related tools took over, providing easy tunneling and remote access, MITM attacks were of much concern, so OTPs became less relevant. What a shame, for they even have a couple of standards for those!

But there’s still room for OTPs… Question: Is it easier to deploy a MITM attack or a keylogger? That’s right… We are always connecting to our remote systems in public terminals (well… at least I am – right now typing from the hospital computer), and a keylogger is so easily installed in one of those terminals, even remotely, that no one would ever get close to deploy a refined MITM attack just to steal someone’s password. One would just install a keylogger! All the security SSH provides would just be gone by then. That’s why I use SSH to connect to my remote machines, but use OTPs to authenticate myself.

It’s so easy to deploy it. In Debian you’ll find packages opie-server and libpam-opie and those are the only things you’ll need on the server side (besides SSH, obviously). OPIE means “One-time Passwords In Everything”, and combined with PAM, one can really use it everywhere.

After installing it, you’ll have to generate the password file for your account:


spectra@home:~$ opiepasswd -c
Adding spectra:
Only use this method from the console; NEVER from remote. If you are using
telnet, xterm, or a dial-in, type ^C now or exit with no password.
Then run opiepasswd without the -c parameter.
Using MD5 to compute responses.
Enter new secret pass phrase:
Again new secret pass phrase:

ID spectra OTP key is 499 ho6484
HAVE COOK LOLA AIRY NEIL ROAM

The pass phrase will be used to generate the passwords in a step before your login. Please, try not to forget it (specially if you’re following this article and playing with some remote system at the same time). Now you can edit /etc/pam.d/ssh file (or its equivalent in non-Debian systems) to require that kind of authentication. Mine just looks like this:


# /etc/pam.d/ssh
auth       required     pam_env.so
auth       required     pam_env.so envfile=/etc/default/locale
auth       required     pam_opie.so

First two lines are unrelated and just load the environment variables. Last line is where the fun is. Please, note two things: (1) I removed references to pam_unix.so, which is what would ask for my “real” password, that I want to disable (no login is allowed with that password). And (2), I declared it as required, meaning that failing it will keep one out of the system.

We are not ready yet! SSH will work by now, but will not present you the OTP challenge. Probably you could still login, but you’d have to remember which is the current password (Trust me, you would not!). To get the challenge you’ll need to enable it – in /etc/ssh/sshd_config change the following line:


ChallengeResponseAuthentication yes

That’s it. Now to login to your remote machine, that’s what will usually happen:


spectra@hospital:~$ ssh home
otp-md5 498 ho6484 ext, Response:
spectra@home:~$

Voilà! It asks for password #498. By default, it starts with 500 passwords and goes down from that. Password #498 were asked, so the next will be #497. After that, #498 is not useable anymore, and #496 is not useable yet. You can generate a list of those passwords (let’s say 10), print it and keep it in your pocket. This is the command you’d use for that:


spectra@home:~$ opiekey -n 10 498 ho6484
Using the MD5 algorithm to compute response.
Reminder: Don't use opiekey from telnet or dial-in sessions.
Sorry, but you don't seem to be on the console or a secure terminal.
Warning: Continuing could disclose your secret pass phrase to an attacker!
Enter secret pass phrase:
489: CALM INTO WEEK APS LOON VIE
490: HASH GYM RAID GOSH HOYT DUAL
491: BELL GIN RIFT HELM GUY BUNK
492: HEBE OBOE SUP LEG LULU LANG
493: HOYT JOT ASK JOG GIBE BETH
494: NASH MOOT HIND YEAH  YAP CARL
495: MATE OF BARD LAVA LEAK AHOY
496: TAB BAG KEY GILT AVID VEAL
497: MOLE FORM NIB LEER ROSS HAVE
498: SING WERE OVEN SOD VEIN NIBS

That is not so secure, since you can loose the paper and be doomed… Luckily there are lots of small softwares that does this generation for you. Some you can use from your Palm or from some J2ME-enabled phone (such as N95). Some your can use from another (trusted) computer. Some are even online, written in javascript!

There are at least one other side-benefit of using OPIE as above: You can give away your user password (even root password – OK, probably not a Good ThingTM), that the system would still be secure, since it only allows SSH authentications via OPIE! If the session is started with a username whose opiepasswd was not activated (first step… scroll back to the beginning of the article), SSH will greet you with a bogus challenge… only “opie-activated users” will be allowed to login with the above configuration.

Easy enough, isn’t it? Now, next time you see me typing on my Palm before opening an SSH connection you’ll know what I am doing… ;-)

Oficina no Consegi 2008 4

Ontem estive em Brasília para uma oficina de streaming de vídeo no Consegi 2008. A oficina foi excelente, com boa participação apesar de termos uma sala pequena e computadores não preparados.

A oficina foi ministrada como uma palestra, com introdução de Karinna Bueno, apresentação básica sobre Streaming a cargo do VJ Pixel, e estudo de dois casos, o da TVSL, a meu cargo e o da transmissão de um evento da ONU (utilizando software não-livre em parte), a cargo do Fabrício Tamusiunas do NIC.br.

Depois de um breve intervalo, comecei com alguns demos (uma vez que os computadores não haviam sido preparados, deixei de lado o hands-on) utilizando a versão 0.5.2 do Flumotion. (Essa é uma versão de desenvolvimento, o que trouxe alguns problemas, mas nada que não fosse superado facilmente… Agora tenho de tentar reproduzir o que ocorreu para ver se encontro o problema… mas isso é outra história…) Infelizmente o tempo agiu contra nós e não pude chegar nos demos mais interessantes, que são aqueles em que envolvo programação em Ruby com pipelines GStreamer… Vou ver se gravo um video desse demo para postar aqui.

Enquanto isso, a parte mais “formal” com a apresentação do caso da TVSL, pode ser encontrada aqui. Não há grandes diferenças em relação à palestra do Debian Day, uma vez que o caso é o mesmo… mas vale a pena dar uma olhadinha.

A todos que nos agüentaram quase a tarde inteira lá no Consegi, muito obrigado. Se tiverem dúvidas, perguntas, podem postar aqui mesmo.

Roteiro do Cibercrime 5

Gostei da brincadeira do Alexandre Oliva e resolvi criar o meu próprio roteiro de uma situação de violação do Projeto de Lei Azeredo, só que dessa vez falando a respeito do artigo que considero mais problemático no famigerado projeto, o 285-B:

Obter ou transferir, sem autorização ou em desconformidade com autorização do legítimo titular da rede de computadores, dispositivo de comunicação ou sistema informatizado, protegidos por expressa restrição de acesso, dado ou informação neles disponível

A estorinha é entre Alice e Bob, ambos repórteres de um grande jornal da capital:

Alice: Olha só o que achei no site do Senador Edward Comstock… (aponta para Bob a tela de seu laptop). isto é um escândalo! Primeira página a caminho…

Bob: Cuidado… você leu as restrições de acesso?

A: Mas que restrições de acesso? Está público, na Internet.

B: Sim, mas você não pode sair por aí copiando coisas públicas dos sites dos outros sem ler as restrições de acesso…

A: Que bobagem… e onde estão as tais “restrições”?

B: Olha lá… no rodapé da página…

A: Hm… “Restrição de Acesso: O conteúdo desse site pode ser livremente citado desde que em um contexto favorável ao autor. Citá-lo de outra forma constitui violação desta restrição conforme o artigo 285-B da Lei nº 1.847.033/2008 (Lei do Cibercrime).”. Que que isso quer dizer?

B: Que você só pode publicar esse escândalo se esse contexto for favorável ao autor… Adeus primeira página.

A: Eu vou citar de qualquer forma. Não seria uma boa repórter se deixasse passar uma primeira página dessas!

B: Olha….

(Transição com uma tela escura escrito “Algum tempo depois…” e uma música de suspense.)

(Doze policiais entram na redação do jornal com escopetas em punho e cercam a mesa de Alice.)

Policial: Tenho um mandado de prisão temporária para a Srta. Alice Bliss Foote, por crime baseado na Lei nº 1.847.033/2008. Onde ela está?

Bob: Não sei, não veio trabalhar hoje, e não avisou a ninguém.

Policial: Revistem a redação. Os informantes disseram que ela está aqui em algum lugar.

(Bob cochichando para outro dos colegas da redação): Ela fugiu hoje… Disseram que viriam buscá-la… Deve estar a meio caminho do Uruguai a essa altura…

(colega de redação cochichando para Bob): Graças a Deus.

(Câmera vai se distanciando, vozes desencontradas na redação continuam a falar e os policiais continuam revirando tudo).

(Fade Out com um letreiro: “O Grande Irmão está observando”).

Palestra no Debian Day 0

Hoje, aniversário do Debian, estamos de novo fazendo o Debian Day para comemorá-lo. Em Porto Alegre ele está acontecendo no Serpro. Em alguns minutos estarei fazendo uma palestra sobre Streaming com Theora, que será transmitida ao vivo pela TV Software Livre.

Devo acrescentar o arquivo da palestra aqui logo depois de ministrá-la, e deixarei aberto os comentários caso alguma dúvida não seja resolvida no ato.

Update 2008-08-17 00:50:00: Estou anexando o arquivo da palestra. Quanto à pipeline que estávamos tentando fazer funcionar… esqueci de colocar os queues eis ela pronta:


bash$ gst-launch-0.10 videotestsrc ! queue ! tee name=t ! fakesink t. ! queue ! ximagesink

Update 2008-08-27 18:36:00: O pessoal publicou o torrent do video da palestra. Mais informações no site do Debian-RS.