Python/2.7 simple coding(+ c++)

hackthis Coding 1~2

qkqhxla1 2015. 2. 12. 20:04

https://www.hackthis.co.uk


level 1.

# -*- encoding: cp949 -*-
import urllib2,re
req = urllib2.Request('https://www.hackthis.co.uk/levels/coding/1')
req.add_header('cookie','PHPSESSID=쿠키')
word = re.findall('<textarea>(.*?)',urllib2.urlopen(req).read())[0].split(', ')
word.sort()
answer = ', '.join(word)

req = urllib2.Request('https://www.hackthis.co.uk/levels/coding/1','answer='+answer)
req.add_header('cookie','PHPSESSID=쿠키')
print urllib2.urlopen(req).read()


level 2.

# -*- encoding: cp949 -*-
import urllib2,re
req = urllib2.Request('https://www.hackthis.co.uk/levels/coding/2')
req.add_header('cookie','PHPSESSID=hoa3pnqd3ql3glfeia5q9t3715')
s = re.findall('<textarea>(.*?)</textarea>',urllib2.urlopen(req).read())[0].split(',')
answer = ''.join(map(lambda x:chr(94 - (int(x)-32) + 32) if x!=' ' else ' ',s))
print answer

req = urllib2.Request('https://www.hackthis.co.uk/levels/coding/2','answer='+answer)
req.add_header('cookie','PHPSESSID=hoa3pnqd3ql3glfeia5q9t3715')
print urllib2.urlopen(req).read()

 

2번같은경우 어떻게 암호화된건지 해석하는게 더 어려웠던 것 같다.