|
|
|
@ -28,6 +28,7 @@ def xorRepeating():
|
|
|
|
|
def xorBrutePrompt():
|
|
|
|
|
isfile = (raw_input('f for file; for string:') == 'f')
|
|
|
|
|
maxresults = input('How many top hits? ')
|
|
|
|
|
keylength = input('Maximum key length in bytes: ')
|
|
|
|
|
if isfile:
|
|
|
|
|
path = raw_input('path: ')
|
|
|
|
|
path = path.strip()
|
|
|
|
@ -36,7 +37,7 @@ def xorBrutePrompt():
|
|
|
|
|
contents = file.readlines()
|
|
|
|
|
contents = [line.strip() for line in contents]
|
|
|
|
|
for code in contents:
|
|
|
|
|
recursiveResult = xorSingleBrute(code, maxresults, 1)
|
|
|
|
|
recursiveResult = xorSingleBrute(code, maxresults, keylength)
|
|
|
|
|
#nach Punkten aufsteigend sortieren:
|
|
|
|
|
sortedList = sorted(recursiveResult.items(), key=operator.itemgetter(1))[-maxresults:]
|
|
|
|
|
#Liste in maximalwert dieser als Tupel anhaengen:
|
|
|
|
@ -50,7 +51,7 @@ def xorBrutePrompt():
|
|
|
|
|
print(i[0])
|
|
|
|
|
else:
|
|
|
|
|
encoded = raw_input('Input your Hex String: ')
|
|
|
|
|
result = xorSingleBrute(encoded, maxresults, 1)
|
|
|
|
|
result = xorSingleBrute(encoded, maxresults, keylength)
|
|
|
|
|
sortedResults = sorted(result.items(), key=operator.itemgetter(1))[-maxresults:]
|
|
|
|
|
for i, j in sortedResults:
|
|
|
|
|
print(i)
|
|
|
|
@ -138,6 +139,18 @@ def translate(inputString, inputType, outputType):
|
|
|
|
|
result = chr(inputString)
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
def string2bin(input):
|
|
|
|
|
return ''.join(format(ord(x), 'b').zfill(8) for x in input)
|
|
|
|
|
|
|
|
|
|
def hammingDistance(string1, string2):
|
|
|
|
|
diffs = 0
|
|
|
|
|
bin1 = string2bin(string1)
|
|
|
|
|
bin2 = string2bin(string2)
|
|
|
|
|
for b1, b2 in zip(bin1, bin2):
|
|
|
|
|
if b1 != b2:
|
|
|
|
|
diffs += 1
|
|
|
|
|
return diffs
|
|
|
|
|
|
|
|
|
|
def urlEncoder():
|
|
|
|
|
input = raw_input('Pleae input your String: ')
|
|
|
|
|
print(urllib.quote_plus(input))
|
|
|
|
@ -148,6 +161,21 @@ def reverser():
|
|
|
|
|
|
|
|
|
|
def base64prompt():
|
|
|
|
|
b64regex = '^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$'
|
|
|
|
|
isfile = (raw_input('f for file, s for string: ') == 'f')
|
|
|
|
|
if isfile:
|
|
|
|
|
path = raw_input('Path: ')
|
|
|
|
|
path = path.strip()
|
|
|
|
|
outputPath = raw_input('Output file: ')
|
|
|
|
|
with open(path, 'r') as file:
|
|
|
|
|
contents = file.read()
|
|
|
|
|
file.close()
|
|
|
|
|
#contents = [line.strip() for line in contents]
|
|
|
|
|
decoded = base64.b64decode(contents)
|
|
|
|
|
with open(outputPath, 'w') as outfile:
|
|
|
|
|
#for line in contents:
|
|
|
|
|
outfile.write(decoded)
|
|
|
|
|
outfile.close()
|
|
|
|
|
else:
|
|
|
|
|
inputString = raw_input('Please input your string: ')
|
|
|
|
|
if (re.match(b64regex, inputString)):
|
|
|
|
|
print(base64.b64decode(inputString))
|
|
|
|
|