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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值