This repository contains code examples demonstrating concepts from Ken Thompson's 1984 Turing Award lecture Reflections on Trusting Trust. These quines illustrate the ideas behind self-propagating code. Thompson shared the concept of a self-propagating compiler backdoor that could survive indefinitely without leaving evidence in the source code.
- Self-Producing Program (Quine): Program that outputs its own source code
- "Trojanized" Quine: Self-producing program that inject purposeful modifications
- Obfuscated "Trojan" Quine: Simple obfuscation to hide the injected modifications
gcc quine.c -o quine ./quine
gfortran fort_quine.f90 -o fort_quine ./fort_quine
Demonstrates payload injection by replacing the word "right" with "wrong" in its output.
gcc trojan_quine.c -o trojan_quine ./trojan_quine
gcc obfuscated_trojan_quine.c -o obfuscated_trojan_quine ./obfuscated_trojan_quine
Verify that the quines work correctly by comparing their output to their source:
# Test basic quine ./quine > output.c diff quine.c output.c # Test trojan quine (will show differences due to "right" -> "wrong" replacement) ./trojan_quine > trojan_output.c diff trojan_quine.c trojan_output.c