CONfidance 2015 CTF Teaser – Power level Writeup (Crypto 50)

For this task we were given this C File and asked to decrypt this

8,223,137,2,42,8,28,186,97,114,42,74,163,238,163,23,121,2,74,158,163,23,135,2,193,158,2,62,2,184,44,20,2,137,217,196,62,249,159,137,44,111,106,111,217,50,106,111,2,62,196,217,137,2,20,106,146,111,151 

in the C file we can see the following code

unsigned int a,b,c,d,v;

unsigned int f(unsigned int x)
{
	return a*x*x*x + b*x*x + c*x + d;
}

int main(int ac, unsigned char**av)
{
	unsigned char *plaintext;
	int i, len;
	plaintext = av[1];
	a = (unsigned int)plaintext[0];
	b = (unsigned int)plaintext[1];
	c = (unsigned int)plaintext[2];
	d = (unsigned int)plaintext[3];
	len = strlen(plaintext);
	for(i=0;i<len;i++)
	{
		v = f(plaintext[i]);
		v = e[v%1000](plaintext[i]) ^ (v%251);
		printf("%u ",v);
	}
	return 0;
}

the program takes the plaintext as argument and then applies a polynomial function f() to every letter combined with some sort of elementary arithmetic operation .
Continue reading