Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

Your goal is to write a super-secret program which launches another (independent) program. You don't have to provide the payload in your answer, it can be any program name your program will launch.

However, the challenge is to keep this behavior a secret. Upon casual inspection of the code, it should be impossible or very hard to notice that your program actually executes a foreign program. Bonus if this "hidden feature", once discovered, can reasonably be explained away as an unintentional bug. This is why the code has to be as clear as possible, and everything should have an alibi for being there, otherwise someone inspecting your code might become suspicious.

Remember, this is not a code-golf, but an underhanded contest.

  • Your code has to be clear and readable.
  • The causes of the change have to be hidden. Even if discovered, they should look more like bugs than malice.

You should provide an explanation, best in spoiler.

like this

The winner will be selected as the highest voted answer not sooner than 10 days after the first valid answer. Yes, I know it's subjective, but this is the only criteria adequate for underhanded contests.

Voters should value the standard "underhanded" qualities, like how clear the code is and how well hidden the reason is.

I made this competition for compiled languages, but you can also use interpreted languages if you find two different notable interpreters for it.

share|improve this question
    
Usually, underhanded contests specify the "legitimate" task the program should perform. It helps focus the efforts. –  ugoren Nov 20 '12 at 19:23
add comment

2 Answers

Tcl

Simple.

proc main {} {
    set fd [open filenames.txt]
    while {[gets $fd line] ne ""} {
        set other [open $line w]
        puts $other [clock format [clock seconds]]
    }
}
main

Ilmari Karonen is right:
If you supply a filename with a | as first character, it will treat the rest as command. IIRC for Perl it has to be at the end.

share|improve this answer
2  
+1. Ps. The same trick works also in Perl, and in any other language that has a suitable "magic open" feature. –  Ilmari Karonen Aug 2 '13 at 12:25
2  
“IIRC for Perl it has to be at the end.” – Actually it has to be placed according to the intended direction of data transfer. pastebin.com/ZnTr7ezg –  manatwork Aug 2 '13 at 13:15
    
Intresting. I used this "feature" a lot with webmin's custom commands. Need a list of all domains in a dropdown? Use this feature. –  Johannes Kuhn Aug 2 '13 at 15:12
add comment

JavaScript

if(document.location.href = 'http://www.example.com') foo();

"document.loaction.href = 'http;//www.example.com'" sets the page location to "http;//www.example.com" instead of testing for the page location to be "http;//www.example.com".

It's an interpretted language, so here are two interpretters: SpiderMonkey and Google Chrome.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.