How can source code contain "a hidden message" that's unrelated to the language and still compile? [closed]

StackOverflow https://stackoverflow.com/questions/23503162

  •  16-07-2023
  •  | 
  •  

Question

I was reminded by this question on programmers that the Nimda virus literally had the text "Concept Virus(CV) V.5, Copyright(C)2001 R.P.China." built into it's code. How is this possible? Wouldn't it cause a compile time error or at least be optimized out since it doesn't do anything? Is this seen in the dissasembled version of the virus?

Was it helpful?

Solution

It depends on how the virus was developed, but as an example, in assembly, this:

UnusedString DB 'Concept Virus(CV) V.5, Copyright(C)2001 R.P.China.', 0

will embed the string (null terminated) into the object code and executable file. Whether or not the code actually references UnusedString is meaningless to most assemblers (in my experience).

Visual C++ will remove "unused local variables" as part of its dead code optimizations. However, if you assign a value to a variable, but don't otherwise use it, Visual C++ does not consider it "unused", and will leave it in the application. So...

char UnusedString[] = "Concept Virus(CV) V.5, Copyright(C)2001 R.P.China.";

will also result in the same null-terminated string in the application, that is not actually used.

Then there's the header of .exe or .dll files, that can contain a multitude of things. For an example, check out the properties dialog of a Microsoft supplied executable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top