Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU |
David Kramer wrote: > > On Friday 22 August 2003 09:33 am, Derek Martin wrote: > > On Fri, Aug 22, 2003 at 02:12:27AM -0400, David Kramer wrote: > > > I once knew the magic incantations for being able to verify a passwd by > > > passing the salt from the encrypted password and the unencrypted password > to > > > crypt() to see if you got a string matching the encrypted password. I'm > > > trying to write a small test program to do this, but I am not getting the > > > encrypted string back. > > > > Can we see the code where you set up the salt and call the function? > > I pass them on the command line so I can play with it until I see it work. > > #define _XOPEN_SOURCE > #include <unistd.h> > > int main(int argc, char* argv[]) > { > char* encrypted; > > encrypted=crypt(argv[1],argv[2]); > > if(encrypted) > { > printf("crypt(%s,%s)='%s'\n",argv[1],argv[2],encrypted); > } > else > { > printf("crypt failed.\n"); > } > > } > > cc -o cryptprint -lcrypt cryptprint.c > > Note: This is a MODIFIED version of my encrypted password, but I used the real > thing: > > [david at uni crypt]$ sudo grep david /etc/shadow > david:$1$FOOWOmC8$FOOldOczYfmtvz5PsXyY5/:12023:0:99999:7::: > > [david at uni crypt]$ ./cryptprint '$1$FOOWOmC8$' 'FOOldOczYfmtvz5PsXyY5/' > crypt($1$FOOWOmC8$,FOOldOczYfmtvz5PsXyY5/)='bmSTpBK8h2lrE' > > [david at uni crypt]$ ./cryptprint '$1$FOOWOmC8$' 'myrealpassword' > crypt($1$xTxWOmC8$,myrealpassword)='FOO/XEaUQQYMU' > > What comes out doesn't seem to match anything. > > Nothing wrong with your program. The args to crypt() are (const char* key, const char* salt). key first, then salt. Try ./cryptprint 'myrealpassword' '$1$FOOWOmC8$' and see if that doesn't give you the right answer. John
BLU is a member of BostonUserGroups | |
We also thank MIT for the use of their facilities. |