This is a little nonsense I just wrote after reading the Wikipedia entry for Ouroboros. Turns out this kind of programs already have a name too, Quine.
In this case it’s a Python script that uses InlineEgg to generate an ELF32 binary that generates a Python script that uses InlineEgg to generate an ELF32 binary that generates a Python script that uses InlineEgg to… well, you get the point. 🙂
Yeah, I know this is not really about computer security, but what the hell. It’s got Python and shellcode somewhere anyway.
#!/usr/bin/python from sys import argv, stdout from inlineegg.inlineegg import InlineEgg, Linuxx86Syscall from inlineegg.exelib import Elf32Program script = open(argv[0], 'r').read() egg = InlineEgg(Linuxx86Syscall) egg.write(1, script, len(script)) egg.exit(0) prg = Elf32Program() prg.arch = prg.ARCH_I386 prg.addCode(str(egg)) stdout.write(prg.bytes()) |