Difference between revisions of "Linux crypt"
From Teknologisk videncenter
(Created page with "<source lang=c> #include <stdio.h> #define _XOPEN_SOURCE →See feature_test_macros(7): #include <unistd.h> //#define _GNU_SOURCE #include <crypt.h> int main( void )...") |
m |
||
(2 intermediate revisions by the same user not shown) | |||
Line 8: | Line 8: | ||
int main( void ) { | int main( void ) { | ||
char *tp; | char *tp; | ||
− | |||
tp = crypt("cisco","$1$uUpN"); | tp = crypt("cisco","$1$uUpN"); | ||
if ( tp == 0 ) { | if ( tp == 0 ) { | ||
Line 19: | 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 | ||
Line 29: | Line 29: | ||
enable secret 5 $1$uUpN$JSmJL9.bdbLHahGFx.BLe/ | enable secret 5 $1$uUpN$JSmJL9.bdbLHahGFx.BLe/ | ||
</source> | </source> | ||
− | [[Category:Linux]][[Category:Cisco]] | + | [[Category:Linux]][[Category:Cisco]][[Category:C]] |
Latest revision as of 06: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/