in reply to Protecting passwords in source

Here is a little background on what i need. Im working with hp-ux where everyone and their brother has superuser privilegus. so their is no way to stop someone from getting in the code and seeing the password If it was hardcoded In. I just wondering if their was a way to have the code encrypt and decrypt the password. I know it would still would be easy to get the password but I just need the password to be hidden.

Replies are listed 'Best First'.
Re^2: Protecting passwords in source
by samtregar (Abbot) on Jul 20, 2005 at 01:46 UTC
    So you're working on a system where people you don't trust have root? You're basically screwed. Since they have root there's nothing they can't do. For example, suppose you succeed in hiding the password in your script - what's to stop your adversary from making a copy of your script and changing it to do whatever she wants, using your password?

    I suggest you find a different machine to work on or convince the powers that be to restrict access to root.

    -sam

Re^2: Protecting passwords in source
by Pied (Monk) on Jul 20, 2005 at 01:40 UTC
    just do a rot13, and get some little obfu, ie dont call it $passwd nor its (de)cypher function &decypher...
    Or/and write the password in hexa instead of Ascii, or mix everything...
    Eventually, put this pass and decypher code in a file called ".. " (with the trailing space) which will be called from your script.
    Mixing all of this can be really enough for a beginner admin...

    Eventually, use some Acme::Bleach or Acme::Morse or stuff like that...

    All this is useless against a smart user but should really do the job but remember: if you have a
    decypher($passwd);
    They will immediately do a
    print decypher($passwd);


    At least I would ^^

    P!
Re^2: Protecting passwords in source
by simonm (Vicar) on Jul 20, 2005 at 01:34 UTC
    As long as you know it's just obfuscated, not really protected, there are a lot of techniques you could use.

    Rot13 might work (tr[a-z][m-za-l]), or you could try unpacking it to a string of hex digits and then packing it back when you're ready to use it.