oj Rapid Typing

import bs4
import requests
import urllib2
import time
import base64
session=requests.Session()
response=session.get('http://oj.blue-whale.me:23331/captcha.php')
soup=bs4.BeautifulSoup(response.text)
s=soup.find('img') #get the img tag

#print s
#we get s,but the type of s is class
#print s['src']
#use [] get the tag's attributes
#use .string get the text between<tag>and</tag>
#get tag's attributes
src=s['src']
#get text of the photo
photo=src.split(',',1)[1]
#decode the photo
photo=base64.b64decode(photo)
#show photo
#print photo
# we take <text></text>,sort by x
text=photo.split("<line",1)[0]
text=text.split(">",1)[1]
text=text.split("</text>")
#print text

#get char and x pos
ans={}
for chars in text:
    print chars
    length=len(chars)
    if length<3:
        break
    char=chars[length-1]
    ch=chars.split()
    x=ch[1].split('"')[1]
    x=int(x)
    ans[x]=char
    print length,char,ch[1],x,ans[x]
ans=sorted(ans.iteritems(), key=lambda d:d[0], reverse =False )
print ans
url='http://oj.blue-whale.me:23331/captcha.php?code='
s=''
#print type(ans)
#after sorted ,type(ans)=list??
for ch in ans:
    s=s+ch[1]
url=url+s
flag=session.get(url)
print flag.text

lunix系统下中文支持没有配出来,注释的时候直接用英语了,直接翻译过来就行。。。唉,英语渣的痛谁都懂

flag{svg_C4P7cHa_n0t_$ecUr3}

原文地址:https://www.cnblogs.com/superxuezhazha/p/6111210.html