MD5脚本总结

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/re_psyche/article/details/82800521

首先声明一下,这也是相当于给自己做了一个脚本库,可能格式会不太严谨,大家随手一看
(1)题目:小明常用密码是hash 是5bc76f3f319865431dcab801bbce47a1 现在 他只知道明文密码的前四位是xjnu
中间是66****88 后三位是ctf 请帮他算出 明文密码是啥
flag{明文}

脚本:

#coding: utf-8

import hashlib
dic = '0123456789qazwsxedcrfvtgbyhnujmikolp'
for a in dic:
  for b in dic:
    for c in dic:
	for d in dic:
               t = 'xjnu'+'66'+str(a)+str(b)+str(c)+str(d)+'88'+'ctf'
               md5 = hashlib.md5(t).hexdigest()
	       #print t
               if md5[:32] == '5bc76f3f319865431dcab801bbce47a1':
                   print t

费纳姆密码:

#--encoding:utf-8--
table = {'A':'1000001','N':'1001110',
         'B':'1000010','O':'1001111',
         'C':'1000011','P':'1010000',
         'D':'1000100','Q':'1010001',
         'E':'1000101','R':'1010010',
         'F':'1000110','S':'1010011',
         'G':'1000111','T':'1010100',
         'H':'1001000','U':'1010101',
         'I':'1001001','V':'1010110',
         'J':'1001010','W':'1010111',
         'K':'1001011','X':'1011000',
         'L':'1001100','Y':'1011001',
         'M':'1001101','Z':'1011010'}
key_list=[]  
value_list=[]  
for key,value in table.items():  
    key_list.append(key)  
    value_list.append(value)
#print key_list, value_list
def get_key_of_value(value):  
    if value in value_list:  
        get_value_index = value_list.index(value)
        #print type(key_list[get_value_index])
        return key_list[get_value_index]  
    else:  
        print "你要查询的值%s不存在" %get_value  
def how_to(a,b):
    if a in ['0','1'] and b in ['0','1']:
        if a == '1' and b == '1':
            return '0'
        elif a == '0' and b == '0':
            return '0'
        else:
            return '1'
    else:
        return 0
def bin_turn(arg):
    binstring = ''
    for i in arg:
        binstring += table[i]
    return binstring
def encrypt(plain,key):
    binkey = bin_turn(key)
    binplain = bin_turn(plain)
    chiper = ''
    if len(binplain)==len(binkey):
        for i in range(0,len(binplain)):
            chiper += how_to(binkey[i],binplain[i])
            #print
        return chiper
    else:
        return 0
def decrypt(chiper,key):
    binkey = bin_turn(key)
    plain = ''
    if len(chiper)==len(binkey):
        for i in range(0,len(chiper)):
            plain += how_to(binkey[i],chiper[i])
            #print binkey[i]
        #print plain
        return plain
    else:
        return 0  
key = 'WELCOMETOCFF'
chiper = '000000000000000000000000000000000000000000000000000101110000110001000000101000000001'
binplain = decrypt(chiper,key)
#print type(binplain)
plain = ''
for i in xrange(0,len(binplain),7):
    plain += str(get_key_of_value(binplain[i:i+7]))
print plain

以后再碰到,持续更新。。。。

猜你喜欢

转载自blog.csdn.net/re_psyche/article/details/82800521
MD5