首页 > 其他 > 详细

hashlib穷举字典破解md5,sha1

时间:2014-03-24 21:53:19      阅读:660      评论:0      收藏:0      [点我收藏+]
#! /usr/bin/python
# -*- coding: utf-8 -*-
# Filename: crackhash.py 穷举字典破解md5,sha1

import sys,getopt,hashlib

if len(sys.argv) == 1:
	print ‘usage: crackhash.py -t hashtype{md5/sha1} -h hashcode -w wordfile‘
	sys.exit()

opts,args = getopt.getopt(sys.argv[1:],"t:h:w:")
hashtype = ""
hashcode = ""
wordfile = ""

for op,value in opts:
	if op == "-t":
		hashtype = value
	elif op == "-h":
		hashcode = value
	elif op == "-w":
		wordfile = value
	else:
		sys.exit()

w = file(wordfile,‘r‘)

if hashtype =="md5":
	while True:
		line = w.readline()
		if line:
			y = hashlib.md5(line.rstrip()).hexdigest()
			if hashcode == y:
				print "md5(%s)=%s" % (line.rstrip(),y)
				break
		else:
			print ‘NULL‘
			break

if hashtype == "sha1":
	while True:
		line = w.readline()
		if line:
			y = hashlib.sha1(line.rstrip()).hexdigest()
			if hashcode == y:
				print "sha1(%s)=%s" % (line.rstrip(),y)
				break
		else:
			print ‘NULL‘
			break

w.close()
本文章来至源码世界  http://www.ymsky.net/views/34356.shtml

hashlib穷举字典破解md5,sha1,布布扣,bubuko.com

hashlib穷举字典破解md5,sha1

原文:http://blog.csdn.net/long7181226/article/details/21951843

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!