Bugtraq mailing list archives

Re: HP Secure Web Console


From: merlyn () STONEHENGE COM (Randal L. Schwartz)
Date: Mon, 6 Dec 1999 10:04:34 -0800


"GNSS" == GNSS Research Division <osiris () gnss com> writes:

GNSS> #!/bin/perl
GNSS> #
GNSS> # swc_crypt_test
GNSS> #
GNSS> # Syntax: swc_crypt_test [option] [word]
GNSS> #
GNSS> # encrypt example: swc_crypt_test -e abcd
GNSS> # output: VUTS
GNSS> #
GNSS> # decrypt example: swc_crypt_test -d VUTS
GNSS> # output: ABCD
GNSS> #

GNSS> if(!$ARGV[0]) { &usage; } if($ARGV[0] ne "-e" && $ARGV[0] ne "-d") { &usage; }

GNSS> if($ARGV[0] eq "-e") {
GNSS> $string=$ARGV[1];
GNSS> $string=~s/(.*)/\u\U$1/g;

That doesn't make sense.  Do you mean:

        $string = uc $string;

there?

GNSS> $string=~y/A-Za-z/S-ZA-za-m/;

This also doesn't make sense.  You have 52 things on the left,
and 79 things on the right in the order of:

  STUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyzabcdefghijklm

If you meant to do a modified caesar rotate where A becomes S, that'd be:

    $string =~ y/A-Za-z/S-ZA-Rs-za-r/;

Of course, the second half of that would never trigger, since you just
uppercased everything, so you could simply combine the two steps with:

    $string =~ y/A-Za-z/S-ZA-RS-ZA-R/;

GNSS> $output = reverse $string; print $output;
GNSS> }

GNSS> if($ARGV[0] eq "-d") {
GNSS> $string=$ARGV[1]; $string=~y/S-ZA-za-m/A-Za-z/;

Ditto here.... perhaps you want:

    $string =~ y/S-ZA-Rs-za-r/A-Za-z/;

GNSS> $string=~s/(.*)/\l\L$1/g;

And again, if you want to lowercase everything, use:

  $string = lc $string;

And the combination move would be:

    $string =~ y/S-ZA-Rs-za-r/a-za-z/;

GNSS> $output = reverse $string; print $output; }

GNSS> sub usage {
GNSS> print "\nUsage: poor_crypt [option] [word]\n";
GNSS> print "\n-e encrypts the supplied string";
GNSS> print "\n-d decrypts the supplied string\n";
GNSS> print "\n***Note: your string MUST be in uppercase.\n";
GNSS> exit;
GNSS> }


--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn () stonehenge com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Current thread: