Ejemplo n.º 1
0
                        line = line.strip("\r").strip("\n")
                        if sscript and line.find(".") and line.split(".")[-1] == sscript:
                            queue.put(line) 
                        elif not sscript:
                            queue.put(line)
    else:
        with open(sdir) as dirfile:
            for line in dirfile:
                line = line.strip("\r").strip("\n")
                if sscript and line.find(".") and line.split(".")[-1] == sscript:
                    queue.put(line) 
                elif not sscript:
                    queue.put(line)
    ######################################################
    #shouhu_pro & jindu_pro
    shouhu = ThreadGetKey()
    shouhu.setDaemon(True)
    shouhu.start()

    # maxloading = queue.qsize()
    # view_loading = Loading(maxloading)
    # view_loading.start()

    #########################################################
    #lines start!
    for i in range(10):
        a = finder(site,smode,logging_file)
        a.start()
        threads.append(a)
    for j in threads:
        j.join()
Ejemplo n.º 2
0
def crackHash (algorithm, hashvalue=None, hashfile=None, savepath=None):
	global CRAKERS
	global queue
	global threads
	global hashresults
	global ishashcracked
	global nowcracking
	
	# Cracked hashes will be stored here
	crackedhashes = []
	
	# Is the hash cracked?
	cracked = False
	
	# Only one of the two possible inputs can be setted.
	if (not hashvalue and not hashfile) or (hashvalue and hashfile):
		return False
	
	# hashestocrack depends on the input value
	hashestocrack = None
	if hashvalue:
		hashestocrack = [ hashvalue ]
	else:
		try:
			hashestocrack = open (hashfile, "r")
		except:
			print "\nIt is not possible to read input file (%s)\n" % (hashfile)
			return cracked
	
	
	# Try to crack all the hashes...
	for activehash in hashestocrack:
		hashresults = []
		threads = []
		ishashcracked = "0"
		# Standarize the hash
		activehash = activehash.strip()
		nowcracking = activehash
		if algorithm not in [JUNIPER, LDAP_MD5, LDAP_SHA1]:
			activehash = activehash.lower()
		
		# Initial message
		print "\nCracking hash-------------> %s\n" % (activehash)

		# Each loop starts for a different start point to try to avoid IP filtered
		begin = randint(0, len(CRAKERS)-1)
		queue = Queue.Queue()
		queue.queue.clear()
		for i in range(len(CRAKERS)):
			queue.put(i)
		# maxloading = queue.qsize()
		# view_loading = Loading(maxloading)
		# view_loading.start()

		line = len(CRAKERS)
		if ismsvcrt == 1 :
			shouhu = ThreadGetKey()
			shouhu.setDaemon(True)
			shouhu.start()
		
		for i in range(line):
			a = START_CRACKER(begin,algorithm,activehash,savepath)
			a.start()
			threads.append(a)
		for j in threads:
			j.join()
		# Store the result/s for later...
		if hashresults:
			# With some hash types, it is possible to have more than one result,
			# Repited results are deleted and a single string is constructed.
			resultlist = []
			for r in hashresults:
				#if r.split()[-1] not in resultlist:
					#resultlist.append (r.split()[-1])
				if r not in resultlist:
					resultlist.append (r)
					
			finalresult = ""
			if len(resultlist) > 1:
				finalresult = ', '.join (resultlist)
			else:
				finalresult = resultlist[0]
			
			# Valid results are stored
			crackedhashes.append ( (activehash, finalresult) )
	
	
	# Loop is finished. File can need to be closed
	if hashfile:
		try:
			hashestocrack.close ()
		except:
			pass
		
	# Show a resume of all the cracked hashes
	print "\nThe following hashes were cracked:\n----------------------------------\n"
	print crackedhashes and "\n".join ("%s -> %s" % (hashvalue, result.strip()) for hashvalue, result in crackedhashes) or "NO HASH WAS CRACKED."
	return cracked