实验吧CTF题库-编程(部分)

  • 百米

3秒提交答案,数字是随机变化的

利用Python脚本解题

# -*- coding:utf-8 -*-
__author__ = "MuT6 Sch01aR"

import requests
from bs4 import BeautifulSoup
import sys,io

url = "http://ctf5.shiyanbar.com/jia/index.php"
url_check = "http://ctf5.shiyanbar.com/jia/index.php?action=check_pass"
s = requests.session()

respons = s.get(url)

soup = BeautifulSoup(respons.text,features="html.parser")
a = soup.find("div",attrs={"name":"my_expr"}).get_text()
a = a.replace("x","*")

response = s.post(url_check,data={"pass_key":eval(a)})

response.encoding = response.apparent_encoding

soup1 = BeautifulSoup(response.text,features="html.parser")
b = soup1.find("div",attrs={"id":"templatemo_content"})

sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='gb18030')

print(b)

 运行,得到flag

  • 找素数

利用python脚本解题

# -*- coding:utf-8 -*-
__author__ = "MuT6 Sch01aR"

from math import *
a = 367-186
b = 186
c = 0
while True:
    a += b
    for i in range(2,int(sqrt(a))+1):
        if a % i == 0:
            break
        else:
            if i == int(sqrt(a)):
                c += 1
                if c == 151:
                    print("CTF{",a,"}")
                    break
    if c == 151:
        break

 运行,得到flag

 

posted @ 2018-01-05 21:50  Sch01aR#  阅读(1666)  评论(0编辑  收藏  举报