-
Notifications
You must be signed in to change notification settings - Fork 2
/
enigpy.py
executable file
·105 lines (86 loc) · 4.04 KB
/
enigpy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#local
import cracker
#global
import os.path
import itertools
import multiprocessing
from datetime import datetime
def listener(q):
'''listens for messages on the q, writes to file. '''
f = open("all.txt", 'a') # all that pass the limit set during exhaustion, currently at 0.04
b42 = open("b42.txt", 'a') # IC > 0.042
beeest = open("beeest.txt", 'a') # IC > 0.045
start=datetime.now()
f.write("START: "+format(start, '%H:%M:%S')+"\n\n")
f.flush()
while 1:
m = q.get()
if m == 'kill':
f.write("STOP: "+format(datetime.now(), '%H:%M:%S')+"\nRUN TIME: "+str(datetime.now()-start)+"\nEND\n\n\n")
print ("STOP: "+format(datetime.now(), '%H:%M:%S')+"\nRUN TIME: "+str(datetime.now()-start))
f.flush()
break
mscore = float(m.split(';')[0])
f.write(str(m) + '\n')
f.flush()
if (mscore > 0.042):
if (mscore > 0.045):
beeest.write(str(m) + '\n')
beeest.flush()
print ("BEST EEEEY")
else:
b42.write(str(m) + '\n')
b42.flush()
print ("42 EEEEY")
f.close()
b42.close()
beeest.close()
#b41.close()
if __name__ == "__main__":
'''
cracker.simpleTest("WTGPLT","MUUQJZVQLORVMCOLYKXEPMCDCWGHNTQVMEHGECOEULBULBOCZPGBIXIFWCYXZKZKLYAEVCJDGXJZQKQGVXSORRQNZMATPZDOEXITXFIUVJFIZUAYLIJWVVGFYXGRDQKAGUUWBNUUOUXQQUCXKUXPTYUIIXPAYXRLTZPZQRNLOPAODDUSVFWMILZEOBVOPIPWHXVYADCORXPIIEUZVTXBRJRECTGLCPKQAJDAMI")
cracker.hillTest("WTGPLT","MUUQJZVQLORVMCOLYKXEPMCDCWGHNTQVMEHGECOEULBULBOCZPGBIXIFWCYXZKZKLYAEVCJDGXJZQKQGVXSORRQNZMATPZDOEXITXFIUVJFIZUAYLIJWVVGFYXGRDQKAGUUWBNUUOUXQQUCXKUXPTYUIIXPAYXRLTZPZQRNLOPAODDUSVFWMILZEOBVOPIPWHXVYADCORXPIIEUZVTXBRJRECTGLCPKQAJDAMI")
'''
'''
print ("test")
scrambled="KYYUGIWKSEYPQDFYPIJNTGNDIAHNBROXDIKEKPTMOUHBEJRRJPVBAOCUZRDFSAZDCNUNNMRPCCMCHJBWSTIKZIREBBVJQAXZARIYVANIJVOLDNBUMXXFNZVRQEGOYXEVVNMPWEBSKEUTJJOKPBKLHIYWGNFFPXKIEWSNTLMDKYIDMOFPTDFJAZOHVVQETNIPVZGTUMYJCMSEAKTYELPZUNHEYFCLAADYPEEXMHQMVAVZZDOIMGLERBBLATHQJIYCBSUPVVTRADCRDDSTYIXYFEAFZYLNZZDPNNXXZJNRCWEXMTYRJOIAOEKNRXGXPNMTDGKFZDSYHMUJAPOBGANCRCZTMEPXESDZTTJZGNGQRMKNCZNAFMDAXXTJSRTAZTZKRTOXHAHTNPEVNAAVUZMHLPXLMSTWELSOBCTMBKGCJKMDPDQQGCZHMIOCGRPDJEZTYVDQGNPUKCGKFFWMNKWPSCLENWHUEYCLYVHZNKNVSCZXUXDPZBDPSYODLQRLCGHARLFMMTPOCUMOQLGJJAVXHZZVBFLXHNNEJXS"
scorer_tri=ngram_score('grams/german_trigrams1941.txt')
crackerTest=cracker(scrambled,scorer_tri)
crackerTest.testHillClimb()
'''
print("Entering the castle of Aaaaaaaaaaaaaaaaaargh")
walzennumbers = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII"]
#jobs = []
print ("Logical cores available %d" % multiprocessing.cpu_count())
noteating=1
print ("Cores NOT being eaten omnomnom %d" % noteating)
manager = multiprocessing.Manager()
q = manager.Queue()
pool = multiprocessing.Pool(multiprocessing.cpu_count()-noteating) #use logical cores
watcher = pool.apply_async(listener, (q,))
jobs = []
#if we're doing initial exhaustion or we already have generated
initialExhaustion=False
if (initialExhaustion):
for subset in itertools.permutations(walzennumbers, 3):
job = pool.apply_async(cracker.initial_exhaustion, (subset,q))
#p=multiprocessing.Process(target=multi7, args=(subset,))
#jobs.append(p)
#p.start()
jobs.append(job)
else:
if os.path.exists("RESULTS/best.txt"):
#best_input = open("RESULTS/best.txt", 'r').read().split('\n')
with open("RESULTS/best.txt", 'r') as best:
for subset in best:
#print (subset)
#print ("1")
job = pool.apply_async(cracker.initial_exhaustion_grunds, (subset,q))
jobs.append(job)
else:
print ("Result file not found!")
for job in jobs:
job.get()
q.put('kill')
pool.close()
pool.join()