-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlecture 21-1(url, cgi, get pin).py
54 lines (41 loc) · 1.22 KB
/
lecture 21-1(url, cgi, get pin).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
#import urllib.request module
#create an empty string to put number in
#browse url, read, and save contents as variable
#use while loop to keep put number, until it gets 4 digit code
#if statement to select what we needed
#
#use <form method="get" action="secret_vault.cgi">
#url += add on the values of each variable
import urllib.request
page = ""
num4 = 0
num3 = 0
num2 = 0
num1 = 0
while True:
url= "http://cgi.soic.indiana.edu/~bdemares/secret_vault.cgi?"
url += "groupname=Group+10&num1="+str(num1)+"&num2="+str(num2)+"&num3="+str(num3)+"&num4="+str(num4)
print(num1, num2, num3, num4)
web_page = urllib.request.urlopen(url)
lines = web_page.read().decode(errors="replace")
web_page.close()
if "Wrong" not in lines:
break
#could also use range to automately put numbers in
if num4 != 9:
num4 +=1
else:
num4 = 0
if num3 != 9:
num3 +=1
else:
num3 = 0
if num2 != 9:
num2 +=1
else:
num2 = 0
if num1 != 9:
num1 +=1
else:
num1 = 0
print(lines)