Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: One-liner to rule them all...

by davido (Cardinal)
on Jul 11, 2012 at 16:00 UTC ( [id://981178]=note: print w/replies, xml ) Need Help??


in reply to Re^2: One-liner to rule them all...
in thread One-liner to rule them all...

I'm assuming that you're going to set up your one-liner such that the target string is held in @ARGV (A special variable documented in perlvar). That's one simple possibility. So $ARGV[0] will hold the first string passed on the command line. To bind your transliteration operator to $ARGV[0] you use the =~ operator like this: $ARGV[0] =~ tr/a-z/x-za-w/.

Now $ARGV[0] holds the transliterated string, and all you need to do is pass it to system, just as you would pass any parameter to any function.

If your target string contains whitespace you will have to wrap it in quotes that your shell respects.

I still don't understand why this is useful. It's not really a form of security, and if the goal is to hide keystrokes, it is easy to unravel. Plus any system call will still show up in the process list.


Dave

Replies are listed 'Best First'.
Re^4: One-liner to rule them all...
by fosskers (Initiate) on Jul 14, 2012 at 01:10 UTC

    Forgive my tardy reply.
    I've got it to this:
    perl -e "system(mystring =~ tr/a-z/x-za-w/r)"
    Where `mystring` is a hard-coded string.
    So I have a working solution, but is there anyway to obfuscate it further?
    To answer your question, I should have been honest from the beginning. I wanted this one-liner to do something cheeky... it's in a section of the README of the software I'm working on, as a treat for the dedicated reader.

      ...I should have been honest from the beginning.

      Yes, people volunteering help appreciate honesty in return. If you had told me from the beginning that you were working on an obfu, I wouldn't have been opposed, though I would have given you the recommendation that it's now taken a series of responses to finally get to: Learn Perl first. Learn to get your script to do what you want it to do without the complications of obfuscation. Once you get it all figured out from a functionality standpoint, then go ahead and play with obfuscating it on your own time.

      Good luck with your endeavour.


      Dave

      Well, then maybe you should have picked something a bit less trivial than ROT... if any of us saw your work, it'd be cracked by now.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://981178]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-26 08:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found