代码如下:

#!/usr/bin/env python
# coding=utf-8

def slice(s,size):
    return [s[i:i+size] for i in range(0,len(s),size)]
#print slice("abcdefghijklmnop",4)
#['abcd'.'efgh','ijkl','mnop']

def xor(a,b):
    return "".join([chr(ord(a[i]) ^ ord(b[i%len(b)])) for i in xrange(len(a))])
#print xor('AAAABBBB','11112222')
#pppppppp

def f(L,n):
    ans = ""
    for i in range(len(L)):
        ans += chr((ord(L[i]) + n) % 256)
    return ans

def decrypt(cipher,rounds):
    assert len(cipher) == 8
    r = cipher[4:]
    l = cipher[:4]
    tmp = l
    l = r
    r = tmp
    for n in reversed(range(1,rounds + 1)):
        tmp = l
        l = r
        r = xor(tmp,f(r,n))
    return l + r

cipher = "dd67ca82d358f0c8479e118addcec2f8ce086c0f6f239f9b66d7226a38c68198dbd777f366fb9fd83b60d11109be174759c75ea56a4866c2"
cipher = slice(cipher.decode("hex"),8)

for i in range(1000):
    plain = decrypt(cipher[0],i)
    if plain.find("h4ck1t") >= 0:
        print "rounds = ",i
        rounds = i

flag = ""
for c in cipher:
    flag += decrypt(c,rounds)
print flag