bf.py (2062B)
1 import sys 2 import collections 3 from collections import Counter 4 5 #token_freq = ["e","t","o","a","i","n","s","h","r","l","u","d","y","m","w","g","f","c","b","p","k","v","j","x","z","q"] 6 7 #n_t_freq = [5,20,15,1,9,14,19,8,18,12,21,4,25,13,23,7,6,3,2,16,11,22,10,24,26,17] 8 9 words = [' i ',' a ', 'about ', 'all ', 'also ', 'and ', ' as ', 'at ', ' be ', 'because ', 'but ', 'by ', 'can ', 'come ', 'could ', 'day ', ' do ', 'even ', 'find ', 'first ', 'for ', 'from ', 'get ', 'give ', 'go ', 'have ', 'he ', 'her ', 'here ', 'him ', ' his ', ' how ', ' if ', 'in ', 'into ', ' it ', ' its ', 'just ', 'know ', 'like ', 'look ', 'make ', 'man ', 'many ', 'me ', 'more ', 'my ', 'new ', ' no ', ' not ', 'now ', ' of ', ' on ', 'one ', 'only ', ' or ', 'other ', ' our ', ' out ', 'people ', ' say ', ' see ', 'she ', ' so ', 'some ', 'take ', 'tell ', 'than ', 'that ', 'the ', 'their ', 'them ', 'then ', 'there ', 'these ', 'they ', 'thing ', 'think ', 'this ', 'those ', 'time ', ' to ', 'two ', ' up ', ' use ', 'very ', 'want ', ' way ', ' we ', 'well ', 'what ', 'when ', 'which ', 'who ', 'will ', 'with ', 'would ', 'year ', 'you ', 'your '] 10 11 alphabet_doubled = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] 12 13 def crack(): 14 for value in range(1,27): 15 value = -(value + 1) 16 de_text = "" 17 for character in en_text: 18 count = 0 19 for alph_car in alphabet_doubled[:26]: 20 count = count + 1 21 if alph_car == character: 22 de_text = de_text + alphabet_doubled[count+value+26] 23 break 24 elif count >= 26: 25 de_text = de_text + character 26 if any(word in de_text for word in words): 27 print("\n",-value-1,":",de_text,"\n") 28 else: 29 print(-value-1,":",de_text) 30 31 if(len(sys.argv) >1): 32 en_text = sys.argv[1].lower() 33 counts=Counter(en_text) 34 try: 35 crack() 36 except: 37 print("Terminated.") 38 else: 39 print("Usage: python bf.py [EN_TEXT]") 40 print("Example: python bf.py 'lipps'") 41 exit(0)