-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource.py
More file actions
161 lines (148 loc) · 4.28 KB
/
source.py
File metadata and controls
161 lines (148 loc) · 4.28 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
from __future__ import print_function
import threading
import sys
import os
import shlex
import Queue
import time
from subprocess import Popen, PIPE
from optparse import OptionParser
#Global Variables
queue = queue.Queue()
printQueue = queue.Queue()
t = []
timeRemaining = 0
fileCount = 0
found = False
#Options
parser = OptionParser()
parser.add_option("-u", "--update",
action="store_false", dest="update", default=True,
help="use to update program")
parser.add_option("-i", "--input",
action="store", dest="input", default=True,
help="the .dmg file (must be in same directory)")
(options, args) = parser.parse_args()
#Main Thread
class MyThread(threading.Thread):
def __init__(self, queue, printQueue):
threading.Thread.__init__(self)
self.queue = queue
self.printQueue = printQueue
#thread.daemon = True
#thread.start()
def run(self):
while not self.queue.empty():
passphrase = str(self.queue.get())
args = shlex.split("hdiutil verify " + options.input + " -passphrase " + passphrase)
proc = Popen(args, stdout=PIPE, stderr=PIPE)
out, err = proc.communicate()
self.queue.task_done()
if "checksum" in err:
print('password found: ' + passphrase)
passwordSave = open("PASSWORD IN HERE.txt", "w")
passwordSave.write(passphrase)
passwordSave.close()
global found
found = True
return
else:
result = str(self.queue.qsize()) + "\tFailed\t" + passphrase
self.printQueue.put(result)
def stop(self):
self.stopped = True
#Time remaining thread
class timerThread(threading.Thread):
def __init__(self,queue,printQueue):
threading.Thread.__init__(self)
self.queue = queue
self.printQueue = printQueue
#thread.daemon = True
#thread.start()
def run(self):
global timeRemaining
time.sleep(1)
while True:
start = queue.qsize()
time.sleep(5)
end = queue.qsize()
try:
timeRemaining = (end / (start - end)) / 12 + 5
except ZeroDivisonError:
raise
time.sleep(10)
def stop(self):
self.stopped = True
def main():
load_file_into_queue()
try:
for i in range(4):
thread = MyThread(queue, printQueue)
t.append(thread)
thread = timerThread(queue,printQueue)
t.append(thread)
for thread in t:
thread.setDaemon(True)
thread.start()
print("Minutes Remaining\tQueue\tStatus\tPassphrase")
while not queue.empty():
sys.stdout.write("\r ")
sys.stdout.write("\r"+str(timeRemaining) + "\t\t\t"+ printQueue.get())
sys.stdout.flush()
if found == True:
raise KeyboardInterrupt
except KeyboardInterrupt:
print("\nclosing threads... ")
for thread in t:
if thread.isAlive():
thread.stop()
print("Exiting Program.")
return
except:
print("Fuck, a thread unable to start")
print(sys.exc_info()[0])
if(queue.empty()):
with open("passphrase" + str(fileCount), 'r') as original: data = original.read()
with open('passphrase' + str(fileCount), 'w') as modified: modified.write("FILECOMPLETED\n" + data)
def load_file_into_queue():
nextFile = False
global fileCount
while os.path.isfile('passphrase' + str(fileCount)):
f = open("passphrase" + str(fileCount), 'r')
for line in f:
check = line.rstrip()
if not "FILECOMPLETED" in check:
queue.put(line.rstrip())
else:
nextFile = True
break
f.close()
if nextFile == True:
fileCount +=1
nextFile = False
else:
print("Unable to detect passphrase file. \nThis program uses strict file names. Please name your passphrase files as:\n\tpassphrase0\n\tpassphrase1\n\tetc...")
return
print("ERROR: No more unchecked files")
os._exit(1)
if __name__ == '__main__':
if not options.update:
print("Updating program...")
args = shlex.split("curl -o source.py https://raw.githubusercontent.com/alfanhui/dmgCracker/master/source.py")
proc = Popen(args, stdouß=PIPE, stderr=PIPE)
print("program updated.")
os._exit(1)
if options.input:
if os.path.isfile("PASSWORD IN HERE.txt"):
print("Did you know the password may have been found?")
raw_input("please check your folder!")
print("if it is a mistake, please remove it..")
os._exit(1)
found = False
start = time.time()
main()
end = time.time()
print("Time taken to complete: ", (end - start)/60 , " minutes..")
else:
print("use -i / --input to specify .dmg filename")
os._exit(1)