-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsolve1.py
More file actions
executable file
·39 lines (28 loc) · 821 Bytes
/
solve1.py
File metadata and controls
executable file
·39 lines (28 loc) · 821 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
#!/usr/bin/env python
import requests
import base64
import json
'''
Script Name: solve1.py
Script Author: Jonathan Tomek
Discussion / Functionality:
Solve challenge1 for The Python Club
Version: 07/22/2013 - 1.0 - Initial release
- 1.1 - Updated for clarity
'''
def challenge(num):
main = 'http://thepythonclub.org:808' + num
# Request Challenge1
url = main + '/challenge' + num
r = requests.get(url)
print 'Question:', r.text
# Obtain the question and then base64 decode
word = r.text.split('"')[1]
answer = base64.b64decode(word)
print 'Solution:', answer
# Submit answer
payload = {'answer': answer}
s = requests.post(url, data=json.dumps(payload))
print 'Response:', s.text
if __name__ == "__main__":
challenge('1')