Skip to content
Projects

About

Quines demonstrating self-propagation

Other Projects

How these counts are measured

Measured star growth

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

Quine - Compiler Original Sin

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.

Contents

  1. Self-Producing Program (Quine): Program that outputs its own source code
  2. "Trojanized" Quine: Self-producing program that inject purposeful modifications
  3. Obfuscated "Trojan" Quine: Simple obfuscation to hide the injected modifications

Code Examples

1. Basic Quine (quine.c)

gcc quine.c -o quine
./quine

2. Fortran Quine (fort_quine.f90)

gfortran fort_quine.f90 -o fort_quine
./fort_quine

3. Trojanized Quine (trojan_quine.c)

Demonstrates payload injection by replacing the word "right" with "wrong" in its output.

gcc trojan_quine.c -o trojan_quine
./trojan_quine

4. Obfuscated Trojan Quine (obfuscated_trojan_quine.c)

gcc obfuscated_trojan_quine.c -o obfuscated_trojan_quine
./obfuscated_trojan_quine

Testing the Examples

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

Explore related projects

Loading…