File access redirection
gdb, 108 chars

star
b open if !(int)strcmp(((char**)$esp)[1],"orange.txt")
comm
set((char**)$esp)[1]="green.txt"
c
end
c
q


Save as the file redirect and run like this:

gdb -x redirect &lt;program you want to redirect&gt;


Works on x86 (linux at least, and probably Windows/Mac also).  Here's what the lines do:

star = start gets to the beginning of main (needed so open is defined for the next step).

b open if... = break if we're calling open on orange.txt

comm = command the code up to the next end is executed when the breakpoint fires.

set ((char*))... = replace the open argument with green.txt

c=continue

q=quit