Commit 0ea3e409 authored by drits-carbon's avatar drits-carbon

adding capscii

parent 1fcb19e2
#!/usr/bin/env python2
# author: deadc0de6
# UYB VWT KFJ ZPO TW BHM FYE O A
# I F G P K P K S J O L
# M LLQ CVE E X BVA T OZP XZK TVJ
# I M C H W B L Z B P
# I TPN AXD FDQ JUK CAK GMR J
# KJO NF NAW ULD QLC SRI YTC FPO
# M N Q O A E F L Q M U
# XOD I VJK EJX XDQ L QSE X N TAP
# H E Q W O T W W X Q K
# KMV DWS KYA WFK S ZCT ERN KGE
one = [
['X', 'X', ' '],
[' ', 'X', ' '],
[' ', 'X', ' '],
[' ', 'X', ' '],
['X', 'X', 'X']
]
two = [
['X', 'X', 'X'],
[' ', ' ', 'X'],
['X', 'X', 'X'],
['X', ' ', ' '],
['X', 'X', 'X']
]
three = [
['X', 'X', 'X'],
[' ', ' ', 'X'],
['X', 'X', 'X'],
[' ', ' ', 'X'],
['X', 'X', 'X']
]
four = [
['X', ' ', 'X'],
['X', ' ', 'X'],
['X', 'X', 'X'],
[' ', ' ', 'X'],
[' ', ' ', 'X']
]
five = [
['X', 'X', 'X'],
['X', ' ', ' '],
['X', 'X', 'X'],
[' ', ' ', 'X'],
['X', 'X', 'X']
]
six = [
['X', 'X', 'X'],
['X', ' ', ' '],
['X', 'X', 'X'],
['X', ' ', 'X'],
['X', 'X', 'X']
]
seven = [
['X', 'X', 'X'],
[' ', ' ', 'X'],
[' ', ' ', 'X'],
[' ', ' ', 'X'],
[' ', ' ', 'X']
]
eight = [
['X', 'X', 'X'],
['X', ' ', 'X'],
['X', 'X', 'X'],
['X', ' ', 'X'],
['X', 'X', 'X']
]
nine = [
['X', 'X', 'X'],
['X', ' ', 'X'],
['X', 'X', 'X'],
[' ', ' ', 'X'],
['X', 'X', 'X']
]
zero = [
['X', 'X', 'X'],
['X', ' ', 'X'],
['X', ' ', 'X'],
['X', ' ', 'X'],
['X', 'X', 'X']
]
plus = [
[' ', ' ', ' '],
[' ', 'X', ' '],
['X', 'X', 'X'],
[' ', 'X', ' '],
[' ', ' ', ' ']
]
minus = [
[' ', ' ', ' '],
[' ', ' ', ' '],
['X', 'X', 'X'],
[' ', ' ', ' '],
[' ', ' ', ' ']
]
mult = [
[' ', ' ', ' '],
[' ', ' ', ' '],
[' ', 'X', ' '],
[' ', ' ', ' '],
[' ', ' ', ' ']
]
import requests
URL = 'http://capscii.insomni.hack/start'
TOTEST = {'0':zero, '1':one, '2':two, '3':three, '4':four, '5':five,
'6':six, '7':seven, '8':eight, '9':nine,
'+':plus, '-':minus, '*':mult}
def comparetwo(x, y):
if len(x) != len(y):
print 'oops'
return False
for i in range(len(x)):
if not x[i] == y[i]:
return False
return True
def compare(number):
for k, v in TOTEST.iteritems():
c = comparetwo(number, v)
if c:
return str(k)
def doit(s, txt=None):
content = txt
if txt == None:
f = s.get(URL)
content = f.text
fields = content.split('<br>')
# fix first one (dirty)
f0 = fields[0]
idx = f0.index('">')
fields[0] = f0[idx+2:]
# fix last one
fields = fields[:-1]
new = []
for entry in fields:
l = list(entry)
l2 = [ 'X' if x != u' ' else ' ' for x in l]
if l2 == []:
continue
new.append(l2)
#print '\n'.join([str(x) for x in new])
#print '------------------------'
calc = ''
while True:
numb = []
for i in new:
numb.append(i[0:3])
calc += '%s' % (compare(numb))
#print calc
adapt = []
for i in new:
x = i[5:]
if x == []:
continue
adapt.append(x)
new = adapt
#print '\n'.join([str(x) for x in new])
#print '------------------------'
if new == []:
break
#print calc
soluce = eval(calc)
print soluce
#print cookie
g = s.post(URL, data = {'sol':str(soluce)})
print g.text
return g.text
s = requests.Session()
newtxt = None
for i in range(50):
txt = doit(s, txt=newtxt)
newtxt = txt
x = s.get(URL)
print x.text
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment