[Chugalug] silly perl one liner to randomize passwords

Alex Smith (K4RNT) shadowhunter at gmail.com
Thu Mar 6 00:45:14 UTC 2014


I know that it can be condensed into one statement, but what you just
posted takes a HUGE load off my brain.

Thanks for putting that up. :)

" ' With the first link, the chain is forged. The first speech censured,
the first thought forbidden, the first freedom denied, chains us all
irrevocably.' Those words were uttered by Judge Aaron Satie as wisdom and
warning... The first time any man's freedom is trodden on we’re all
damaged." - Jean-Luc Picard, quoting Judge Aaron Satie, Star Trek: TNG
episode "The Drumhead"
- Alex Smith
- Dulles Technology Corridor (Chantilly/Ashburn/Dulles), Virginia USA


On Wed, Mar 5, 2014 at 7:17 PM, Dan Lyke <danlyke at flutterby.com> wrote:

> On Wed, 05 Mar 2014 18:46:07 -0500
> Rod <rod-lists at epbfi.com> wrote:
> > I remember the perl script to decode dvd's. It was a popular end tag
> > on emails.
> > damn perl is some black magic.
>
> Not gonna deny that Perl is some black magic, but if you format it and
> unwrap the "-p":
>
>
> # Reads 4x the argument count as base 64 bytes, substitutes out any
> # non \w ([A-Za-z_0-9]) chars, returns the count bytes as random.
>
> sub r
> {
>    $l=shift;
>
>    # Open the filehandle "R" as the pipe of base64 encoding
>    # reading from /dev/urandom
>
>    open(R,"base64 /dev/urandom|")||die$!;
>    sysread(R,$R,$l*4);
>    close(R);
>
>    $R=~s/[^\w]//g;
>    substr($R,0,$l)
>
>    # return is assumed. People doing this in my code will be thrashed.
> }
>
>
> # '-p' puts an assumed
> #     while (<>) { ... print $_; }
> # around your '-e' argument. 'while (<>)' is shorthand for
> # 'while we can read a line from the file into $_'
>
> while (<>)
> {
>   # Split the passwd line into an array based on ':' as a separator
>   @P=split/:/;
>
>   # If the password field [1] is '$6'
>   if($P[1]=~/\$6/)
>   {
>      # $s is 8 random bytes, $p is 16 random bytes
>      $s=&r(8);
>      $p=&r(16);
>
>      # Replace the password with $p, salted with $r
>
>      $P[1]=crypt($p,"\$6\$$s");
>
>      # rebuild the new password line
>      $_=join(":", at P);
>   }
>   print $_;
> }
>
>
> See? Nothin' to it.
>
> Dan
> _______________________________________________
> Chugalug mailing list
> Chugalug at chugalug.org
> http://chugalug.org/cgi-bin/mailman/listinfo/chugalug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://chugalug.org/pipermail/chugalug/attachments/20140305/ed063229/attachment.html>


More information about the Chugalug mailing list