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
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top