Message Board -  Archive

[ Login ] [ Create Account ]
[ Board List ] [ View Board ] [ Post Reply ]
  Author  Subject: Perl Script for July 2004's Command-Line Corner
Archive  

Posted on 07-08-2004 03:09 p.m. ET  reply

Original Poster: Jym Williams Zavada

At the July 2004, it was pointed out that Mike's shell script was a
security risk on a multi-user system, because the PHRASE would show up in the
process table with the ps command. Here is a perl script you can use to avoid
the problem:

#!/usr/bin/perl -w

use strict;

# Uncomment your preferred method (ONLY ONE!):
my $cmd = "md5sum | cut -b 1-30 | xxd -r -p | uuencode -m - | sed -ne'2p'";

#my $cmd = "md5sum | cut -b 1-30 | xxd -r -p | uuencode - ";
# $cmd .= "| sed -ne'2p' | cut -b 2-21";

#my $cmd = "md5sum | "
# $cmd .= "perl -pe 's/...$//;";
# $cmd .= "s/../chr(33+hex($&)\%94)/ge;";
# $cmd .= "s/[~`]//g'";

print "Enter phrase: ";

system("stty -echo");

my $PHRASE = <STDIN>;

system("stty echo");

print "
";

chomp($PHRASE);

open(FH, "|$cmd") or die "Cannot run $cmd: $!
";

print FH $PHRASE;

close(FH);

< Previous 1 Next >

Site Contents