SPUG:help with good passwords

Adam Monsen adamm at wazamatta.com
Tue May 20 23:01:28 CDT 2003


Rewrote a more usable version. Here it is:

#!/usr/bin/perl -w
use strict;

use Inline C => Config => LIBS => '-lcrack';
use Inline C => <<'END_C';
   #include <crack.h>
   /* Returns explanation if the password check failed,
    * else returns NULL */
   char *test_pw(const char *pw, const char *dict_path)
   {
     return FascistCheck(pw, dict_path);
   }
END_C

my $reason = test_pw($ARGV[0], "/usr/lib/cracklib_dict");

if ($reason) {
   print "BAD PASSWORD; $reason\n"
} else {
   print "Password was OK!\n";
}



Adam Monsen wrote:
[...]
> #!/usr/bin/perl -w
> use strict;
> 
> use Inline C => Config => LIBS => '-lcrack';
> use Inline C => <<'END_C';
>   #include <crack.h>
>   void test_pw(const char *pw, const char *dict_path)
>   {
>     char *msg;
>     msg = FascistCheck(pw, dict_path);
>     if (msg)
>       printf("MSG: %s\n", msg);
>     else
>       printf("Password accepted.\n");
>     return 0;

Oops, can't return from a void function. Pretend that never happened.

>   }
> END_C
> 
> # intentionally designed to work only on my box.
> # don't really use this.
> test_pw("foo", "/usr/lib/cracklib_dict");
[...]




More information about the spug-list mailing list