Python/2.7 simple coding(+ c++)

Enigmagroup missions/programming 2

qkqhxla1 2014. 11. 3. 11:21

Objective:
You have 1 second to multiply this random number 30882470 by 4 and submit it


랜덤으로 나타나는 숫자에 대해 4를 곱한 값을 적어서 1초안에 요청을 보내라.


근데 단순히 계산한값만 보내면 안된다. 보낼때 몸체부분을 보면 내가적은 답 뿐만아니라


시간, 어떤 해쉬값도 같이 가기 때문이다.(이게 하나라도 틀리면 인정 안됨.)


정규식에 익숙하지 않아서 더럽게 구분해서 짰다..


import urllib2

req = urllib2.Request('http://www.enigmagroup.org/missions/programming/2/index.php')
req.add_header('cookie','enigmafiedV4=내 쿠키')
read = urllib2.urlopen(req).read()

one = int(read[read.find('random number')+14:read.find('random number')+22]) #첫번째 랜덤한 숫자를 가져옴....
two = int(read[read.find('by')+3:read.find('by')+4]) #두번째 숫자를 가져옴... 근데 뒷부분인 4는 변하지 않으니까 괜히 가져온것 같다..
hash = read[read.find('hash" value="')+13:read.find('hash" value="')+45] #해쉬값을 가져옴..
time = read[read.find('me]" value="')+12:read.find('me]" value="')+22] #시간값을 가져옴..

gob = one*two
req = urllib2.Request('http://www.enigmagroup.org/missions/programming/2/index.php','answer='+str(gob)+'&E%5Bnumber%5D='+str(one)+'&E%5Btime%5D='+str(time)+'&hash='+str(hash)+'&submit=Submit+Answer') #각각 추가해서 보낸다.
req.add_header('cookie','내 쿠키')
print urllib2.urlopen(req).read()


'Python > 2.7 simple coding(+ c++)' 카테고리의 다른 글

Enigmagroup missions/programming 5  (0) 2014.11.05
Enigmagroup missions/programming 3  (0) 2014.11.03
Enigmagroup missions/programming 1  (0) 2014.11.03
wargame.kr pw_crack  (2) 2014.10.06
파이썬챌린지.com 5  (0) 2014.08.16