-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSafeHacker
More file actions
executable file
·42 lines (31 loc) · 753 Bytes
/
SafeHacker
File metadata and controls
executable file
·42 lines (31 loc) · 753 Bytes
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import random
import sys
# Convience variables
if len(sys.argv)>=3:
StartNumber=int(sys.argv[1])
EndNumber=int(sys.argv[2])
else:
print("Need a starting and ending number")
sys.exit(0)
# Get combination
combination=random.randint(StartNumber,EndNumber)
counter=0
# Build trial list
number=StartNumber
NumberList=[]
while number<EndNumber+1:
NumberList.append(number)
number+=1
# Try to guess combination
done=False
while not done:
trial=random.randint(0,len(NumberList)-1)
guess=NumberList[trial]
if guess==combination:
done=True
else:
NumberList.pop(trial)
counter+=1
print("Combination found:",trial,"It took ",counter,"tries.")