Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I'm not sure I understand the question when read with the title. If you're looking to mask the password when entered on the command line, use Term::Readkey.

Your script with the Term::Readkey stuff inserted - I check to see if you have it installed first. Not sure if it is a core module. If not, then just install it, not a big deal.

use strict; use warnings; use Win32::OLE; use Data::Dumper; # use Term::ReadKey my $HAVE_Term_ReadKey = eval { require Term::ReadKey; Term::ReadKey->import; 1 }; ## specify EFT connection information. If the eftadmin password change +s, it needs to be changed here as well. our $domain='OurDomain\\'; our $pass; our $user; CONNECTION: { print "Account ID? "; chomp (my $s_id=<STDIN>); $user=$domain . $s_id; print " Using $user to authenticate.\n"; print "Password? "; if ($HAVE_Term_ReadKey) { ReadMode(2) } chomp (my $pass=<STDIN>); if ($HAVE_Term_ReadKey) { ReadMode(0) } print "\n Password: $pass\n"; print " CONNECTING TO APP ...\n"; print " CONNECTED TO APP ...\n"; $pass = undef; print "Password: $pass\n" }

The script outputs:

VinsWorldcom@C:\Users\VinsWorldcom\tmp> test Account ID? vinsworldcom Using OurDomain\vinsworldcom to authenticate. Password? Password: My_Password CONNECTING TO APP ... CONNECTED TO APP ... Use of uninitialized value $pass in concatenation (.) or string at C:\ +Users\VinsWorldcom\tmp\test.pl line 34, <STDIN> line 2. Password: VinsWorldcom@C:\Users\VinsWorldcom\tmp>

Notice the "Password?" prompt has no text next to it as the ReadMode(2) call turns off echo so you don't see the user typing their password. It does get saved to $pass however. But also notice the "Use of uninitialized ..." error after "CONNECT..." because we set $pass to 'undef' and then print it - just so you see it has been "erased" after using it to authenticate.

Are you concerned that people will be snooping the memory of the computer you are running the script on while you're running the script - and thus need the obfuscation of the $pass variable immediately?


In reply to Re: Masking Windows Passwords by VinsWorldcom
in thread Masking Windows Passwords by nimdokk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2021-12-02 17:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (23 votes). Check out past polls.

    Notices?