CTF 字符统计2

题目地址:http://sec.hdu.edu.cn/question/web/1076/

这一题跟上一篇那题有点相似,查看一下源代码:

发现字符产所处的HTML标签变了,还有就是上一题是get请求,而这一题是post请求。

那就修改下python代码,如下:

 # coding=UTF-8           
import requests
from bs4 import BeautifulSoup
url = "http://sec.hdu.edu.cn/question/web/1076/"

q = requests.session()
webcontext = q.get(url).text #获取页面内容
content=webcontext.split('<hr/>')

a=content[1]
Unicode2str=a.encode("utf-8")
ln=len(a)
s=0
e=0
c=0
l=0
a=0
b=0
for i in range(ln):
    if (Unicode2str[i] == 's' ):
        s=s+1
    elif (Unicode2str[i]== 'e' ):
        e=e+1
    elif (Unicode2str[i] == 'c' ):
        c=c+1
    elif (Unicode2str[i]== 'l' ):
        l=l+1
    elif (Unicode2str[i] == 'a' ):
        a=a+1
    elif (Unicode2str[i]=='b'):
        b=b+1
    else:
        continue
value='%d' %s +'%d' %e +'%d' %c +'%d' %l +'%d' %a +'%d' %b

getdata={'answer':value}
result=q.post(url,data=getdata)
z=result.text
x=z.encode('GBK','ignore')
print x

运行得到flag。

转载于:https://www.cnblogs.com/lovealways/p/5861634.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值