converted some things to python3, it at least starts up now
This commit is contained in:
		
							parent
							
								
									26371d027f
								
							
						
					
					
						commit
						c15d362011
					
				
							
								
								
									
										56
									
								
								crypttool.py
									
									
									
									
									
								
							
							
						
						
									
										56
									
								
								crypttool.py
									
									
									
									
									
								
							| @ -1,4 +1,4 @@ | ||||
| #!/usr/bin/env python | ||||
| #!/usr/bin/env python3 | ||||
| import sys, string, types, hashlib, base64, re, urllib, binascii | ||||
| import operator | ||||
| from collections import Counter | ||||
| @ -8,8 +8,8 @@ UPPER_LETTERS = [chr(x) for x in range(65, 91)] | ||||
| COMMON_LETTERS = 'ETAOIN SHRDLU' | ||||
| 
 | ||||
| def xorRepeating(): | ||||
|     plain = raw_input('Please input your Plaintext: ') | ||||
|     key = raw_input('Key: ') | ||||
|     plain = input('Please input your Plaintext: ') | ||||
|     key = input('Key: ') | ||||
|     hexkey = list() | ||||
|     i = 0 | ||||
|     for c in key: | ||||
| @ -26,11 +26,11 @@ def xorRepeating(): | ||||
|     print(resultString) | ||||
| 
 | ||||
| def xorBrutePrompt(): | ||||
|     isfile = (raw_input('f for file; for string:') == 'f') | ||||
|     isfile = (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 = input('path: ') | ||||
|         path = path.strip() | ||||
|         results = list() | ||||
|         with open(path, 'r') as file: | ||||
| @ -50,7 +50,7 @@ def xorBrutePrompt(): | ||||
|                 for i in tupel: | ||||
|                     print(i[0]) | ||||
|     else: | ||||
|         encoded = raw_input('Input your Hex String: ') | ||||
|         encoded = input('Input your Hex String: ') | ||||
|         result = xorSingleBrute(encoded, maxresults, keylength) | ||||
|         sortedResults = sorted(result.items(), key=operator.itemgetter(1))[-maxresults:] | ||||
|         for i, j in sortedResults: | ||||
| @ -60,7 +60,7 @@ def xorBrutePrompt(): | ||||
| def xorSingleBrute(encoded='', maxresults=20, keybytes=1): | ||||
|     resultDict = dict() | ||||
|     if(encoded == ''): | ||||
|         isfile = (raw_input('f for file; for string:') == 'f') | ||||
|         isfile = (input('f for file; for string:') == 'f') | ||||
|     for xor_key in range(0, 2**(keybytes*8)): | ||||
|         decoded = ''; | ||||
|         for i, j in zip(encoded[::2], encoded[1::2]): | ||||
| @ -75,8 +75,8 @@ def commonCounter(inputString, limit=7): | ||||
| 
 | ||||
| def fixedxor(string1 = '', string2 = ''): | ||||
|     if(string1 == ''): | ||||
|         string1 = raw_input('Please input your first hex string: ') | ||||
|         string2 = raw_input('Please input your second hex string: ') | ||||
|         string1 = input('Please input your first hex string: ') | ||||
|         string2 = input('Please input your second hex string: ') | ||||
|     hex1 = int(string1, 16) | ||||
|     hex2 = int(string2, 16) | ||||
|     result = hex1 ^ hex2 | ||||
| @ -155,7 +155,7 @@ def zeroWidthString(inputstring): | ||||
|             else: | ||||
|                 resultstring+= u'\u200d' #zero-width joiner | ||||
|     resultstring += '<' | ||||
|     print resultstring | ||||
|     print(resultstring) | ||||
| 
 | ||||
| def resolveZeroWidthString(inputstring): | ||||
|     charfound = False | ||||
| @ -170,7 +170,7 @@ def resolveZeroWidthString(inputstring): | ||||
|     bytelist = split_len(binarystring, 8) | ||||
|     for byte in bytelist: | ||||
|         resultstring += translate(byte, 1, 5) | ||||
|     print resultstring | ||||
|     print(resultstring) | ||||
| 
 | ||||
| def split_len(seq, length): | ||||
|     return [seq[i:i+length] for i in range(0, len(seq), length)] | ||||
| @ -203,20 +203,20 @@ def hammingDistance(string1, string2): | ||||
|     return diffs | ||||
| 
 | ||||
| def urlEncoder(): | ||||
|     input = raw_input('Pleae input your String: ') | ||||
|     input = input('Pleae input your String: ') | ||||
|     print(urllib.quote_plus(input)) | ||||
| 
 | ||||
| def reverser(): | ||||
|     string = raw_input('Please input your string to reverse:') | ||||
|     string = input('Please input your string to reverse:') | ||||
|     print(string[::-1])  | ||||
| 
 | ||||
| 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') | ||||
|     isfile = (input('f for file, s for string: ') == 'f') | ||||
|     if isfile: | ||||
|         path = raw_input('Path: ') | ||||
|         path = input('Path: ') | ||||
|         path = path.strip() | ||||
|         outputPath = raw_input('Output file: ') | ||||
|         outputPath = input('Output file: ') | ||||
|         with open(path, 'r') as file: | ||||
|             contents = file.read() | ||||
|             file.close() | ||||
| @ -227,7 +227,7 @@ def base64prompt(): | ||||
|             outfile.write(decoded) | ||||
|             outfile.close() | ||||
|     else: | ||||
|         inputString = raw_input('Please input your string: ') | ||||
|         inputString = input('Please input your string: ') | ||||
|         if (re.match(b64regex, inputString)): | ||||
|             print(base64.b64decode(inputString)) | ||||
|         else: | ||||
| @ -236,7 +236,7 @@ def base64prompt(): | ||||
| 
 | ||||
| def rotPrompt(): | ||||
|     choice = input('What kind of ROT do you want to perform? 1-25, or all: ') | ||||
|     userInput = raw_input('Please insert a string: ') | ||||
|     userInput = input('Please insert a string: ') | ||||
|     if type(choice) is types.IntType: | ||||
|         print(rot(userInput, choice)) | ||||
|     else: | ||||
| @ -252,20 +252,20 @@ def translatePrompt(): | ||||
|     inputType = input('Please specify input type: ') | ||||
|     outputType = input('Please specify output type: ') | ||||
|     if (inputType == 5): | ||||
|         inputString = raw_input('Please input your strings, seperated by semicolon: ') | ||||
|         inputString = input('Please input your strings, seperated by semicolon: ') | ||||
|     else: | ||||
|         inputString = raw_input('Please input your values, seperated by semicolon: ') | ||||
|         inputString = input('Please input your values, seperated by semicolon: ') | ||||
| 
 | ||||
|     inputList = inputString.split(';') | ||||
|     for entry in inputList: | ||||
|         print(str(translate(entry, inputType, outputType))) | ||||
| 
 | ||||
| def hashPrompt(): | ||||
|     typeChoice = raw_input('Would you like to hash a file or a String? f for file, s for string: ') | ||||
|     typeChoice = input('Would you like to hash a file or a String? f for file, s for string: ') | ||||
|     algoList = hashlib.algorithms_available | ||||
|     for word in algoList: | ||||
|         print(word) | ||||
|     algoChoice = raw_input('Which hashing algorithm? ') | ||||
|     algoChoice = input('Which hashing algorithm? ') | ||||
|     if algoChoice in algoList: | ||||
|         hasher = hashlib.new(algoChoice) | ||||
|     else: | ||||
| @ -273,13 +273,13 @@ def hashPrompt(): | ||||
|         sys.exit(0) | ||||
| 
 | ||||
|     if (typeChoice == 'f'): | ||||
|         filePath = raw_input('Please input a fully qualified path: ') | ||||
|         filePath = input('Please input a fully qualified path: ') | ||||
|         filePath = filePath.strip() | ||||
|         with open(filePath, 'rb') as hashFile: | ||||
|             content = hashFile.read() | ||||
|             hasher.update(content) | ||||
|     else: | ||||
|         inputString = raw_input('Please input a string: ') | ||||
|         inputString = input('Please input a string: ') | ||||
|         hasher.update(inputString)     | ||||
|     print(hasher.hexdigest()) | ||||
| 
 | ||||
| @ -296,7 +296,7 @@ print('8: XOR Bruteforce Single Byte ') | ||||
| print('9: XOR Repeating Key') | ||||
| print('10: Zero-Width String') | ||||
| print('11: Resolve Zero-Width Strings') | ||||
| choice = raw_input('Please make a selection: ') | ||||
| choice = input('Please make a selection: ') | ||||
| if (choice == '1'): | ||||
|     rotPrompt() | ||||
| elif (choice == '2'): | ||||
| @ -321,9 +321,9 @@ elif(choice == '8'): | ||||
| elif(choice == '9'): | ||||
|     xorRepeating() | ||||
| elif(choice == '10'): | ||||
|     i = raw_input('String:') | ||||
|     i = input('String:') | ||||
|     zeroWidthString(i) | ||||
| elif(choice == '11'):  | ||||
|     i = raw_input('String:') | ||||
|     i = input('String:') | ||||
|     resolveZeroWidthString(i) | ||||
| print('Thank you for flying with PankiCrypt Airlines!') | ||||
| print('Thank you for flying with PankiCrypt Airlines!') | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user