数据分析
1. packet
密码破解
1. cc
逆向分析
1. 欢乐时光
XXTEA
cpp
#include<stdio.h>
#include<stdint.h>
#define DELTA 0x9e3779b9
#define MX (((z>>5^y<<2)+(y>>3^z<<4))^((sum^y)+(key[(p&3)^e]^z)))
void btea(unsigned int* v, int n, unsigned int const key[4])
{
unsigned int y, z, sum;
unsigned p, rounds, e;
if (n > 1)
{
rounds = 32; //这里可以说是预定义值,n=2是rounds=32
sum = 0;
z = v[n - 1];
do
{
sum += DELTA;
e = (sum >> 2) & 3;
for (p = 0; p < n - 1; p++) //注意这里的p是从0~n-1
{
y = v[p + 1];
z = v[p] += MX;
}
y = v[0];
z = v[n - 1] += MX; //这里的MX中传入的p=n-1
} while (--rounds);
}
else if (n < -1)
{
n = -n;
rounds = 415 / n + 114;
sum = rounds * DELTA;
y = v[0];
do
{
e = (sum >> 2) & 3;
for (p = n - 1; p > 0; p--) //注意这里的p是从n-1~0,和上面是反过来的
{
z = v[p - 1];
y = v[p] -= MX;
}
z = v[n - 1];
y = v[0] -= MX; //这里的MX中传入的 p=0
sum -= DELTA;
} while (--rounds);
}
}
int main()
{
int enc[] = { 0x480AC20C, 0xCE9037F2, 0x8C212018, 0x0E92A18D, 0xA4035274, 0x2473AAB1, 0xA9EFDB58, 0xA52CC5C8,
0xE432CB51, 0xD04E9223, 0x6FD07093, 0 };
int key[4] = {
0x79696755, 0x67346F6C, 0x69231231, 0x5F674231
};
int n = 11;
btea(enc,-n, key);
printf("%s", enc);
return 0;
}
2. rc4
动调得到