5 ms·
Code that will only execute once
- kylek 12y agoMy first thought (from a sysadmin view, and only reading the title ;) ) is - firstboot scripts that only run once? The question sounds like they're looking for something a little more malicious I guess?...
- vezzy-fnord 12y agoActually, bootscripts would probably count. The authors here mean code that can only run once and will unconditionally fail if it is executed more than once (such as #!/bin/rm), but a few of the examples can only be run once per session, which bootscripts would likely fit in.
- drdeadringer 12y agoFor an easter egg and bonus points: Somehow involve Inspector Gadget's boss -- reading the instructions to you, a dot-picture, the sound of a muffled explosion in a trash can, whatever. "This script will self destruct in five seconds."
- vog 12y agoWhy being so cautious? You can do it mission impossible style ... destroying the whole computer on which the message was displayed - with a white, thick and nasty smoke.
- rokhayakebe 12y ago1) Create a file unlink.php in your php environment 2) Paste this in it <?php unlink('unlink.php'); 3) Visit unlink.php on your browser
- hueving 12y agoAny php file with the following should work. <?php unlink(__FILE__);
- leepowers 12y agoWith short open tags enabled the example can be simplified further as <?unlink(__FILE__);
- MattBearman 12y agoIt's been a couple of years since I programmed in PHP, but I'm pretty sure if it's the EOF you don't even need the final semicolon, so: <?unlink(__FILE__)
- dylz 12y agoShort tags (other than echo <?=) are no longer on by d efault
- deleted 12y ago[deleted]
- erikano 12y ago>Visit unlink.php on your browser Better yet, make it an executable script starting with the line: #!/usr/bin/php -q
- call 12y agoThis sort of reminded me of Phillip K. Dick's art book Agrippa [1], which was given a limited release on a floppy disk that would corrupt itself after its contents are displayed on a computer. [1] https://en.wikipedia.org/wiki/Agrippa_%28A_Book_of_the_Dead%29 https://en.wikipedia.org/wiki/Agrippa_%28A_Book_of_the_Dead%...
- herokusaki 12y agoYou mean William Gibson's. Note how despite the author's intentions (or perhaps because of them) "pirated text of the poem was released the next day on MindVox."
- schoen 12y agoI was a bit obsessed with that poem (and the fact that it leaked!) in high school. I still think it was well-done and love the theme of "the mechanism".
- carrotleads 12y agoexe's can store their own resources and that includes binary files. Store a child exe within a parent exe. When parent exe is run first, it should extract child exe, run it, do whetever it wants and quit. Child exe's job is to see if parent exe has finished execution. Can be done by searching for windown handle or string. When parent exe is no longer running, child exe should delete parent and quit. Satisfies the requirement that parent exe's code will only run once if there is only one distribtion of exe.
- codeflo 12y agoOn POSIX systems, this challenge is trivial because you can unlink ("delete") an executable while it's running. The file is then actually deleted once the program exits. On Window, you can muck around with child processes that delete their parent. Perhaps more interestingly, you could try to abuse Software Restriction Policies [1]. In theory, you should be able to blacklist your own executable (by hash), so that it can't run ever again. This would also block any copy of the file that you might have kept. [1] http://technet.microsoft.com/en-us/library/bb457006.aspx http://technet.microsoft.com/en-us/library/bb457006.aspx
- ingenieros 12y agoIs this challenge being sponsored by Monsanto?
- cousin_it 12y agoThis reminded me of the ~ATH ("till death") programming language from the webcomic Homestuck: http://www.mspaintadventures.com/?s=6&p=003925 http://www.mspaintadventures.com/?s=6&p=003925
- afternooner 12y agoI could argue that if you work for the DOD, it's entirely possible that all your code will only execute once. Sadly, I do work for a government agency, but my code only runs once because of mismanagement... :(
- faster 12y agoBack in the 80's the group I worked with got a VAX with VMS. Files are versioned in VMS, and you can delete specific versions. So we used that to prank each other for a while, editing someone's login script and deleting the newest version so they couldn't send the same prank back to you.
- FatalLogic 12y agoDamaging the 'environment' was allowed, so it's disappointing not to see any code that tries to disable or destroy the hardware by: * Overheating or overvolting the CPU, GPU or other components * Erasing boot firmware or boot settings stored in flash memory (and rebooting) I know there are protection mechanisms, which may be impossible to circumvent, but you can try...
- maaku 12y agoThere was the HCL (halt-and-catch-fire) opcode as a submission...
- FatalLogic 12y agoThat opcode promises so much, but delivers so little :/
- sly_g 12y agopity it's closed. in perl in would be: unlink $0
- ColinCera 12y agoI thought this was going to be an article about software demos.
- jim_lawless 12y agoIn Windows, the program should check for the presence of a unique, global atom via GlobalFindAtom(). If present, terminate. If not present, create the atom with GlobalAddAtom() and continue the initial execution of the program.
- known 12y agohttps://en.wikipedia.org/wiki/Singleton_pattern https://en.wikipedia.org/wiki/Singleton_pattern