3
A Ken Thompson virus is a virus that infects your compiler and other programs. Since it infects all your tools, you can not detect it without using tools from before the virus was introduced.
Your will create a prototype for inserting the Ken Thompson virus into code. The goal of this virus will be to allow you to (fake) destroy any computer running a program infected with it.
Inserting a Ken Thompson virus is defined as follows. Start with an input program P. Your program will output a modified program Q that works as follows:
- If the input to
QisaNouIQ5xKvUfdZVzo0Xs, it will outputBOOM(in a real Ken Thompson virus, this would actually do something bad, but since it this is a fake virus, outputingBOOMis done instead). - For any other input to
Q, run programPwith that input- If the output of
Pis valid source code in the language you are using, insert the Ken Thompson virus into it and thenQwill output the resulting infected program. - Otherwise, the output of
Qis just the output ofP.
- If the output of
You will write a program that takes P's code as input and produces Q's code as output.
You can use either a currently (at the time of this post) existing programming language, or a subset of one, for this challenge. (The idea is that language you are using would be the target language of some self-compiling compiler, but this is not required.) Since you want to be as subtle as possible, the shortest code (in bytes) wins!
Sandbox entry is here: https://codegolf.meta.stackexchange.com/a/12710/16842
– PyRulez – 2017-06-04T22:10:03.8533
Voting to close as asking for malicous code is never a good idea. https://codegolf.meta.stackexchange.com/q/4829/15599
– Level River St – 2017-06-04T22:45:41.2501I'm voting to close this question as off-topic because I agree with @LevelRiverSt, this is malicious. – NoOneIsHere – 2017-06-04T22:54:41.567
6@NoOneIsHere @LevelRiverSt This is clearly not malicious.
Insert a simulated Ken Thompson virus into a program,The goal of this virus will be to allow you to (fake) destroy any computer. All the "virus" does is printBOOM. There is absolutely nothing malicious. – MD XF – 2017-06-05T03:22:15.923@MDXF ok, VTRO-ing. I guess I didn't read the question well. – NoOneIsHere – 2017-06-05T05:03:42.623
The program
Ponly ever has one input? – Jonathan Allan – 2017-06-05T06:33:08.9306I don't understand why this is downvoted. Seems like a quine variant that may actually be interesting for once. – feersum – 2017-06-05T08:23:53.260
An answer with a compiler doesn't actually seem to be valid though, since a compiler's output is in a different language than the source code it gets as input. – feersum – 2017-06-05T08:25:19.543
Here i do not write virus – RosLuP – 2017-06-05T12:41:16.910
2@MDXF The OP's intention is not malicious, but in theory at least, code submitted here could be used to create a virus. The possibility of that happening is extremely remote, but if it did happen it would bring this site into serious disrepute. That's why I say: asking for malicious code is never a good idea. Per the question I linked, Martin, Peter and a majority of voters at the time tended to agree. – Level River St – 2017-06-05T20:27:55.730
@JonathanAllan yes – PyRulez – 2017-06-05T21:06:31.340
1@LevelRiverSt or they could just create a virus themselves. All code on this site is so obfuscated that it's easier to start from scratch. – PyRulez – 2017-06-05T21:08:40.133
@RosLuP it's a simulated virus, not a real one. – PyRulez – 2017-06-05T21:25:47.743
@LevelRiverSt if anything, the algorithm I posted is more dangerous than any code posted. – PyRulez – 2017-06-05T21:27:24.257
@Jonathan Allan, you could use a subset of Jelly – PyRulez – 2017-06-05T21:36:26.070
Must it be a program, or a function will work? Must it take the compiled in bytecode program? (I think) This is quite trivial in some programming language. – user202729 – 2017-06-06T14:54:02.633
@user202729 a function is fine. It must process source code in it's only language (so if you inserting the virus into assembly, you must publish your program in assembly). – PyRulez – 2017-06-06T19:24:29.873
@feersum this challenge "assumes" that you are writing the code in the target language of the compiler – PyRulez – 2017-06-06T19:25:38.643
1I'd argue the question is asking for such a minor component of a malicious task, that it's not malicious in itself. We're tasked with writing a separate pre-compiler that injects source code. The challenging parts. infecting a machine, injecting this pre-compiler into an existing compiled compiler, and circumventing OS-level security controls, far outweigh this task in complexity. – Hand-E-Food – 2017-06-09T00:42:48.337
How is the input
Pprovided to the program and how should the outputQbe delivered? – Hand-E-Food – 2017-06-09T00:45:13.880