Beispiel #1
0
def decode_old(data, verbose=False):
    p = PrintCollector()
    data = ''.join([t for t in data.lower() if t in ('a', 'b')])

    for mode in range(2):
        if mode == 0:
            e_array = re.findall(".{5}", data)
        else:
            # 互换 a 和 b
            p.print('-----------------')
            p.print('互换 a 和 b')
            new_data = ''.join(['b' if t == 'a' else 'b' for t in data])
            e_array = re.findall(".{5}", new_data)

        d_string1 = ""
        d_string2 = ""
        for index in e_array:
            for i in range(0, 26):
                if index == first_cipher[i]:
                    d_string1 += alphabet[i]
                if index == second_cipher[i]:
                    d_string2 += alphabet[i]

        p.print("first method: \n" + d_string1)
        p.print("\nsecond method: \n" + d_string2)
    return p.smart_output(verbose=verbose)
Beispiel #2
0
def decode(data, verbose=False):
    p = PrintCollector()
    detect(data, p)
    new_data = list(data)
    result_list = [[]]
    while len(new_data) > 0:
        t = new_data[:2]
        if len(t) < 2 or not (t[0] in string.digits and t[1] in string.digits):
            for x in result_list:
                x.append(t[0])
            new_data = new_data[1:]
            continue
        else:
            new_data = new_data[2:]

        # 因为 i 和 j 共用了一个编码,所以这里遍历所有可能
        special, c = decode_char(int(t[0]), int(t[1]))
        if special:
            tmp_result_list = deepcopy(result_list)
            for x in tmp_result_list:
                x.append('j')
            for x in result_list:
                x.append(c)
            result_list.extend(tmp_result_list)
        else:
            for x in result_list:
                x.append(c)

    new_result_list = []
    for x in result_list:
        x = ''.join(x)
        new_result_list.append(x)
        p.print(x)
    return p.smart_output(verbose=verbose)
Beispiel #3
0
def decode(data, verbose=False):
    p = PrintCollector()
    detect(data, p)
    new_data = list(data)
    result_list = [[]]
    while len(new_data) > 0:
        t = new_data[:2]
        if len(t) < 2 or not (t[0] in string.digits and t[1] in string.digits):
            for x in result_list:
                x.append(t[0])
            new_data = new_data[1:]
            continue
        else:
            new_data = new_data[2:]

        # 因为 i 和 j 共用了一个编码,所以这里遍历所有可能
        special, c = decode_char(int(t[0]), int(t[1]))
        if special:
            tmp_result_list = deepcopy(result_list)
            for x in tmp_result_list:
                x.append('j')
            for x in result_list:
                x.append(c)
            result_list.extend(tmp_result_list)
        else:
            for x in result_list:
                x.append(c)

    new_result_list = []
    for x in result_list:
        x = ''.join(x)
        new_result_list.append(x)
        p.print(x)
    return p.smart_output(verbose=verbose)
Beispiel #4
0
def decode(data, verbose=False):
    p = PrintCollector()
    output = rail_fence_decode(data, verbose=False)
    for t in output:
        for key in range(26):
            d = caesar_decode(t, key)
            p.print(d)

    return p.smart_output(verbose=verbose)
Beispiel #5
0
def decode(data, verbose=False):
    p = PrintCollector()
    data = data.strip()
    split_list = data.split('0')
    data = [sum([int(t) for t in item]) for item in split_list]

    result = ''
    for i in data:
        result += string.ascii_uppercase[i - 1]
    p.print(result)
    return p.smart_output(verbose=verbose)
Beispiel #6
0
def decode(data, verbose=False):
    p = PrintCollector()
    buff = ""
    for i in data:
        if i not in string.ascii_letters:
            buff += i
        elif ord('A') <= ord(i) <= ord('Z'):
            buff += chr((ord(i) - 13 + 26 - ord('A')) % 26 + ord('A'))
        else:
            buff += chr((ord(i) - 13 + 26 - ord('a')) % 26 + ord('a'))
        p.print(buff)

    return p.smart_output(verbose=verbose)
Beispiel #7
0
def decode(data, verbose=True):
    p = PrintCollector()
    for i in range(26):
        key = ''
        for x in data:
            s = ord(x)
            if (s not in range(97, 123)) and (s not in range(65, 91)):
                key = key + chr(s)
            else:
                # print chr(s)
                if s in range(97, 123):
                    if s % 2 == 0:
                        s = s - i
                        if s not in range(97, 123):
                            t = 97 - s
                            t = 123 - t
                            key = key + chr(t)
                        else:
                            key = key + chr(s)
                    else:
                        s = s + i
                        if s not in range(97, 123):
                            t = s - 122 + 96
                            key = key + chr(t)
                        else:
                            key = key + chr(s)
                else:
                    # print chr(s)
                    if s % 2 == 0:
                        s = s - i
                        if s not in range(65, 91):
                            t = 65 - s
                            t = 91 - t
                            key = key + chr(t)
                        else:
                            key = key + chr(s)
                    else:
                        s = s + i
                        if s not in range(65, 91):
                            t = s - 90 + 64
                            key = key + chr(t)
                        else:
                            key = key + chr(s)
        p.print(key)

    return p.smart_output(verbose=verbose)
Beispiel #8
0
def decode(data, verbose=True):
    p = PrintCollector()
    for i in range(26):
        key = ''
        for x in data:
            s = ord(x)
            if (s not in range(97, 123)) and (s not in range(65, 91)):
                key = key + chr(s)
            else:
                # print chr(s)
                if s in range(97, 123):
                    if s % 2 == 0:
                        s = s - i
                        if s not in range(97, 123):
                            t = 97 - s
                            t = 123 - t
                            key = key + chr(t)
                        else:
                            key = key + chr(s)
                    else:
                        s = s + i
                        if s not in range(97, 123):
                            t = s - 122 + 96
                            key = key + chr(t)
                        else:
                            key = key + chr(s)
                else:
                    # print chr(s)
                    if s % 2 == 0:
                        s = s - i
                        if s not in range(65, 91):
                            t = 65 - s
                            t = 91 - t
                            key = key + chr(t)
                        else:
                            key = key + chr(s)
                    else:
                        s = s + i
                        if s not in range(65, 91):
                            t = s - 90 + 64
                            key = key + chr(t)
                        else:
                            key = key + chr(s)
        p.print(key)

    return p.smart_output(verbose=verbose)
Beispiel #9
0
def decode(data, verbose=False):
    p = PrintCollector()
    data = data.replace(' ', '').strip()
    if len(data) % 2 != 0:
        p.print('可能不是9宫格手机键盘编码')
        return p.smart_output(verbose=verbose)
    tmp_data = list(data)
    result = []
    while len(tmp_data) > 0:
        k = ''.join(tmp_data[:2])
        tmp_data = tmp_data[2:]
        v = dict_map.get(k)
        if v is None:
            p.print('可能不是9宫格手机键盘编码')
            return p.smart_output(verbose=verbose)

        result.append(v)

    result = ''.join(result)
    p.print(result)
    return p.smart_output(result, verbose=verbose)
Beispiel #10
0
def decode(e, verbose=False):
    p = PrintCollector()
    # e = 'tn c0afsiwal kes,hwit1r  g,npt  ttessfu}ua u  hmqik e {m,  n huiouosarwCniibecesnren.'
    data = len(e)
    field = []
    for i in range(2, data):
        if data % i == 0:
            field.append(i)

    result = []
    for f in field:
        b = data // f
        r = {x: '' for x in range(b)}
        for i in range(data):
            a = i % b
            r.update({a: r[a] + e[i]})
        d = ''
        for i in range(b):
            d = d + r[i]
        x = '分为\t' + str(f) + '\t' + '栏时,解密结果为: ' + d
        result.append(x)
        p.print(x)

    return p.smart_output(result=result, verbose=verbose)
Beispiel #11
0
def decode(e, verbose=False):
    p = PrintCollector()
    # e = 'tn c0afsiwal kes,hwit1r  g,npt  ttessfu}ua u  hmqik e {m,  n huiouosarwCniibecesnren.'
    data = len(e)
    field = []
    for i in range(2, data):
        if data % i == 0:
            field.append(i)

    result = []
    for f in field:
        b = data // f
        r = {x: '' for x in range(b)}
        for i in range(data):
            a = i % b
            r.update({a: r[a] + e[i]})
        d = ''
        for i in range(b):
            d = d + r[i]
        x = '分为\t' + str(f) + '\t' + '栏时,解密结果为: ' + d
        result.append(x)
        p.print(x)

    return p.smart_output(result=result, verbose=verbose)
Beispiel #12
0
def decode(data, verbose=False):
    p = PrintCollector()
    data = ''.join([t for t in data.lower() if t in ('a', 'b')])

    for mode in range(2):
        if mode == 0:
            # e_array = re.findall(".{5}", data)
            new_data = data
        else:
            # 互换 a 和 b
            p.print('-----------------')
            p.print('互换 a 和 b')
            new_data = ''.join(['b' if t == 'a' else 'b' for t in data])
            # e_array = re.findall(".{5}", new_data)

        decode_method_1(new_data, p)
        decode_method_2(new_data, p)
    return p.smart_output(verbose=verbose)
Beispiel #13
0
def decode(data, verbose=False):
    p = PrintCollector()
    # raw_data = "DEath IS JUST A PaRT oF lIFE, sOMeTHInG wE'RE aLL dESTInED TO dO."
    raw_data = data
    for mode in (0, 1):
        if mode == 0:
            p.print('\n小写为a,大写为b\n')
        else:
            p.print('\n小写为b,大写为a\n')

        new_data = recovery_transformed_bacon_data(p, raw_data, mode)

        # data = 'baabaaabbbabaaabbaaaaaaaaabbabaaaabaaaaa/abaaabaaba/aaabaabbbaabbbaababb'
        # 这种就直接解码
        # data = 'abbab_babbb_baaaa_aaabb'
        decode_method_1(new_data, p)
        decode_method_2(new_data, p)

    return p.smart_output(verbose=verbose)
Beispiel #14
0
def decode(data, verbose=False):
    p = PrintCollector()
    data = ''.join([t for t in data.lower() if t in ('a', 'b')])

    for mode in range(2):
        if mode == 0:
            # e_array = re.findall(".{5}", data)
            new_data = data
        else:
            # 互换 a 和 b
            p.print('-----------------')
            p.print('互换 a 和 b')
            new_data = ''.join(['b' if t == 'a' else 'b' for t in data])
            # e_array = re.findall(".{5}", new_data)

        decode_method_1(new_data, p)
        decode_method_2(new_data, p)
    return p.smart_output(verbose=verbose)
Beispiel #15
0
def decode_all(data, verbose=True):
    p = PrintCollector()
    for key in range(26):
        r = decode(data, key)
        p.print(r)
    return p.smart_output(verbose=verbose)
Beispiel #16
0
def decode_all(data, verbose=True):
    p = PrintCollector()
    for key in range(26):
        r = decode(data, key)
        p.print(r)
    return p.smart_output(verbose=verbose)
Beispiel #17
0
def decode_all(data, verbose=False):
    p = PrintCollector()
    p.print('标准 qwerty 键盘')
    r = decode(data, dict_map1)
    p.print(r)
    p.print('\n从上到下,从左到右')
    r = decode(data, dict_map2)
    p.print(r)
    p.print('\nqwerty 逆序')
    r = decode(data, dict_map3)
    p.print(r)

    return p.smart_output(verbose=verbose)
Beispiel #18
0
def decode_all(data, verbose=False):
    p = PrintCollector()
    p.print('标准 qwerty 键盘')
    r = decode(data, dict_map1)
    p.print(r)
    p.print('\n从上到下,从左到右')
    r = decode(data, dict_map2)
    p.print(r)
    p.print('\nqwerty 逆序')
    r = decode(data, dict_map3)
    p.print(r)

    return p.smart_output(verbose=verbose)
Beispiel #19
0
def decode(data, verbose=False):
    data = quopri.decodestring(data)
    p = PrintCollector()
    # 原始的数据可能是用不同的编码
    try:
        p.print('decode as utf8:')
        p.print(data)
    except:
        pass

    try:
        p.print('decode as gb2312:')
        p.print(data.decode('gb2312'))
    except:
        pass

    return p.smart_output(verbose=verbose)
Beispiel #20
0
def decode(data, verbose=False):
    """
    这个网站的实现中 http://web.chacuo.net/charsetxxencode/
    每60个字符输出一行,然后在开始位置加上1个字符存储长度
    :param verbose:
    :param data:
    :return:
    """
    p = PrintCollector()
    result = []

    data = data.replace('\n', '').replace(' ', '').strip()
    # print(data)
    length = 61
    data_list = []
    while len(data) > 0:
        data_list.append(data[:length])
        data = data[length:]

    for t in data_list:
        length = cipher_letters.index(t[0])
        # print(length)
        result.append(decrypt(t[1:], length, print_output=False))

    # result = [force_bytes(t) for t in result]
    output = b''.join(result)
    print(output)
    try:
        p.print('utf8编码:')
        p.print(output)
    except:
        pass

    try:
        p.print('gb2312编码:')
        p.print(output.decode('gb2312'))
    except:
        pass

    return p.smart_output(verbose=verbose)
Beispiel #21
0
def decode_old(data, verbose=False):
    p = PrintCollector()
    data = ''.join([t for t in data.lower() if t in ('a', 'b')])

    for mode in range(2):
        if mode == 0:
            e_array = re.findall(".{5}", data)
        else:
            # 互换 a 和 b
            p.print('-----------------')
            p.print('互换 a 和 b')
            new_data = ''.join(['b' if t == 'a' else 'b' for t in data])
            e_array = re.findall(".{5}", new_data)

        d_string1 = ""
        d_string2 = ""
        for index in e_array:
            for i in range(0, 26):
                if index == first_cipher[i]:
                    d_string1 += alphabet[i]
                if index == second_cipher[i]:
                    d_string2 += alphabet[i]

        p.print("first method: \n" + d_string1)
        p.print("\nsecond method: \n" + d_string2)
    return p.smart_output(verbose=verbose)
Beispiel #22
0
def decode(data, verbose=False):
    p = PrintCollector()
    data = data.replace(' ', '').strip()
    if len(data) % 2 != 0:
        p.print('可能不是9宫格手机键盘编码')
        return p.smart_output(verbose=verbose)
    tmp_data = list(data)
    result = []
    while len(tmp_data) > 0:
        k = ''.join(tmp_data[:2])
        tmp_data = tmp_data[2:]
        v = dict_map.get(k)
        if v is None:
            p.print('可能不是9宫格手机键盘编码')
            return p.smart_output(verbose=verbose)

        result.append(v)

    result = ''.join(result)
    p.print(result)
    return p.smart_output(result, verbose=verbose)