Skip to content
Permalink
Browse files
debugging fully removed, Table working
  • Loading branch information
ross committed Oct 25, 2021
1 parent d5ee84b commit 0abaebb2e81281686a7c697da7e5d35c05d173e7
Showing 1 changed file with 4 additions and 6 deletions.
@@ -20,7 +20,7 @@ def targetHashFunction(value):
return h


def makeGuess(value, i, minLen,maxLen,charset, debug=True):
def makeGuess(value, i, minLen,maxLen,charset, debug=False):
""" Given a value and an index, return a new valid input.
Arguments:
@@ -50,7 +50,7 @@ def makeGuess(value, i, minLen,maxLen,charset, debug=True):



def queryTable(hashValue,table, chainLength, hashFunc=targetHashFunction, guessFunc=makeGuess, minLen=3, maxLen=6, charset=defaultCharset, debug=True):
def queryTable(hashValue,table, chainLength, hashFunc=targetHashFunction, guessFunc=makeGuess, minLen=3, maxLen=6, charset=defaultCharset, debug=False):
"""find a chain that contains an input value that results in the
given hash, in the given table. chainLength limits the search since
there is no point building test chains longer than the ones in the
@@ -85,18 +85,17 @@ def queryTable(hashValue,table, chainLength, hashFunc=targetHashFunction, guessF
h=hashFunc(g)
if debug: out+=f"({g}->{h}) "
if debug: print(out)
print(h)
if h in table:
if debug: print(f"Found hash in chain at position {i}, beginning with {table[h]}")
attempt= rebuildChain(table[h],hashValue, hashFunc, guessFunc, chainLength,minLen, maxLen, charset, debug=True)
attempt= rebuildChain(table[h],hashValue, hashFunc, guessFunc, chainLength,minLen, maxLen, charset, debug=False)
if attempt!=None:
return attempt
if debug: print("No matches found")
return None



def rebuildChain(chain,targetHash, hashFunc, guessFunc, chainLength,minLen, maxLen, charset, debug=True):
def rebuildChain(chain,targetHash, hashFunc, guessFunc, chainLength,minLen, maxLen, charset, debug=False):
""" Recreates a single chain, looking for a target hash.
Arguments:
@@ -145,7 +144,6 @@ def generateTable(chainStarts, hashFunc, guessFunc, chainLength, minLen=3,maxLen
tempHash= targetHashFunction(tempAnswer) # creating a temp hash with the current guess
tempAnswer = makeGuess(tempHash, j, minLen, maxLen, charset) # making a guess using the curennt hash by calling makeGuess with all parameters note: J is how far along in the chain the code is
RainbowTable.update({tempHash: i}) #adds the first guess and last hash a value key pair
print(RainbowTable.keys())
return RainbowTable


0 comments on commit 0abaebb

Please sign in to comment.