Difference between revisions of "Linux crypt"

From Teknologisk videncenter
Jump to: navigation, search
m
m
Line 18: Line 18:
 
}
 
}
 
</source>
 
</source>
When run:
+
Remember to compile with ''-lcrypt''
 +
*When run:
 
<source lang=bash>
 
<source lang=bash>
 
a:~/bin$ gcc crypt.c -o crypt -lcrypt
 
a:~/bin$ gcc crypt.c -o crypt -lcrypt

Revision as of 07:55, 29 September 2019

#include <stdio.h>
#define _XOPEN_SOURCE       /* See feature_test_macros(7) */
#include <unistd.h>
//#define _GNU_SOURCE
#include <crypt.h>

int main( void ) {
        char *tp;
        tp = crypt("cisco","$1$uUpN");
        if ( tp == 0 ) {
                perror("Av: ");
                return(0);
        }
        printf("%s\n",tp);

        return(0);
}

Remember to compile with -lcrypt

  • When run:
a:~/bin$ gcc crypt.c -o crypt -lcrypt
a:~/bin$ ./crypt
$1$uUpN$JSmJL9.bdbLHahGFx.BLe/

Running config from a Cisco router with password cisco:

enable secret 5 $1$uUpN$JSmJL9.bdbLHahGFx.BLe/