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

  • 百米

实验吧CTF题库-编程(部分)_第1张图片

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

实验吧CTF题库-编程(部分)_第2张图片

  • 找素数

实验吧CTF题库-编程(部分)_第3张图片

利用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

实验吧CTF题库-编程(部分)_第4张图片

 

转载于:https://www.cnblogs.com/sch01ar/p/8206929.html

你可能感兴趣的:(实验吧CTF题库-编程(部分))