|
|
|
@ -1,8 +1,43 @@
|
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
import sys, string, types, hashlib, base64, re, urllib
|
|
|
|
|
import sys, string, types, hashlib, base64, re, urllib, binascii
|
|
|
|
|
import operator
|
|
|
|
|
from collections import Counter
|
|
|
|
|
|
|
|
|
|
LOWER_LETTERS = [chr(x) for x in range(97, 123)]
|
|
|
|
|
UPPER_LETTERS = [chr(x) for x in range(65, 91)]
|
|
|
|
|
COMMON_LETTERS = 'ETAOIN SHRDLU'
|
|
|
|
|
|
|
|
|
|
def xorSingleBrute(encoded='', keybytes=1):
|
|
|
|
|
resultList = dict()
|
|
|
|
|
if(encoded == ''):
|
|
|
|
|
encoded = raw_input('Input your Hex String:')
|
|
|
|
|
for xor_key in range(0, 2**(keybytes*8)):
|
|
|
|
|
decoded = '';
|
|
|
|
|
for i, j in zip(encoded[::2], encoded[1::2]):
|
|
|
|
|
decoded += ''.join(chr(int(i+j, 16) ^ xor_key))
|
|
|
|
|
#if (all(c in string.printable for c in decoded)):
|
|
|
|
|
#if isHumanReadable(decoded):
|
|
|
|
|
#print(xor_key, decoded)
|
|
|
|
|
resultList[decoded] = commonCounter(decoded)
|
|
|
|
|
sortedResults = sorted(resultList.items(), key=operator.itemgetter(1))
|
|
|
|
|
|
|
|
|
|
for result, key in sortedResults[-20:]:
|
|
|
|
|
#if (all(c in string.printable for c in result)):
|
|
|
|
|
print(result)
|
|
|
|
|
|
|
|
|
|
def commonCounter(inputString, limit=7):
|
|
|
|
|
countObj = Counter(inputString.upper())
|
|
|
|
|
common = countObj & Counter(COMMON_LETTERS)
|
|
|
|
|
return sum(common.values())
|
|
|
|
|
|
|
|
|
|
def fixedxor(string1 = '', string2 = ''):
|
|
|
|
|
if(string1 == ''):
|
|
|
|
|
string1 = raw_input("Please input your first hex string: ")
|
|
|
|
|
string2 = raw_input("Please input your second hex string: ")
|
|
|
|
|
hex1 = int(string1, 16)
|
|
|
|
|
hex2 = int(string2, 16)
|
|
|
|
|
result = hex1 ^ hex2
|
|
|
|
|
print(hex(result))
|
|
|
|
|
|
|
|
|
|
def rot(inputString, amount):
|
|
|
|
|
outputString = ""
|
|
|
|
@ -135,19 +170,29 @@ print("3: Translation")
|
|
|
|
|
print("4: Base64 Encoder/Decoder")
|
|
|
|
|
print("5: String Reverser")
|
|
|
|
|
print("6: URL Encoder")
|
|
|
|
|
choice = input("Please make a selection: ")
|
|
|
|
|
if (choice == 1):
|
|
|
|
|
print("7: Fixed XOR")
|
|
|
|
|
print("8: XOR Bruteforce Single Byte ")
|
|
|
|
|
choice = raw_input("Please make a selection: ")
|
|
|
|
|
if (choice == "1"):
|
|
|
|
|
rotPrompt()
|
|
|
|
|
elif (choice == 2):
|
|
|
|
|
elif (choice == "2"):
|
|
|
|
|
hashPrompt()
|
|
|
|
|
elif (choice == 3):
|
|
|
|
|
elif (choice == "3"):
|
|
|
|
|
translatePrompt()
|
|
|
|
|
elif(choice == 4):
|
|
|
|
|
elif(choice == "4"):
|
|
|
|
|
base64prompt()
|
|
|
|
|
elif(choice == 5):
|
|
|
|
|
elif(choice == "5"):
|
|
|
|
|
reverser()
|
|
|
|
|
elif(choice == 6):
|
|
|
|
|
elif(choice == "6"):
|
|
|
|
|
urlEncoder()
|
|
|
|
|
elif(choice[0] == "7"):
|
|
|
|
|
if(len(choice) > 1):
|
|
|
|
|
argList = choice.split(" ")
|
|
|
|
|
fixedxor(argList[1], argList[2])
|
|
|
|
|
else:
|
|
|
|
|
fixedxor()
|
|
|
|
|
elif(choice == "8"):
|
|
|
|
|
xorSingleBrute()
|
|
|
|
|
|
|
|
|
|
print("Thank you for flying with PankiCrypt Airlines!")
|
|
|
|
|
|
|
|
|
|