USTC中科大信息安全競賽——黑客猜奇偶(1.0)

這道題目還是很有意思的,主要是邏輯上的漏洞,因爲你的字符串是可以控制可以修改的,所以把字符串置空。這樣每次就對服務器生成的字符串做MD5,而服務器的MD5是你可以獲取的

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date    : 2017-10-18 21:42:48
# @Author  : csu_vc

import requests
import re
from bs4 import BeautifulSoup

get_url = 'http://hack.lug.ustc.edu.cn/dynamic/3/'
session = requests.session()
html = session.get(get_url).content

soup = BeautifulSoup(html, 'html.parser')
string = soup.find_all("p")[6].get_text().split(':')[1]
print(string)
print(string[-1])

if int(string[-1], 16) % 2 == 0:
    post_url = 'http://hack.lug.ustc.edu.cn/dynamic/3/'
    payload = {'text': '', 'choice': 0, 'submit': '%E6%8F%90%E4%BA%A4'}
    post = session.post(post_url, payload)

else:
    post_url = 'http://hack.lug.ustc.edu.cn/dynamic/3/'
    payload = {'text': '', 'choice': 1, 'submit': '%E6%8F%90%E4%BA%A4'}
    post = session.post(post_url, payload)

for i in range(1,31):
    soup1 = BeautifulSoup(post.text,'html.parser')
    print('這是第'+str(i)+'次')
    print(soup1)
    if (i<30):
        string1=soup1.find_all("p")[13].get_text().split(':')[1]
        print(string1)
        print(string1[-1])
    else:
        string1=soup1.find_all("body")
        print(string1)

    if int(string1[-1], 16) % 2 == 0:
        post_url = 'http://hack.lug.ustc.edu.cn/dynamic/3/'
        payload = {'text': '', 'choice': 0, 'submit': '%E6%8F%90%E4%BA%A4'}
        post = session.post(post_url, payload)

    else:
        post_url = 'http://hack.lug.ustc.edu.cn/dynamic/3/'
        payload = {'text': '', 'choice': 1, 'submit': '%E6%8F%90%E4%BA%A4'}
        post = session.post(post_url, payload)

這裏寫圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章