1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
   | """ # -*- coding: utf-8 -*- # @Author: dr0n1 # @Date:   2024/11/27 # @link: https://www.dr0n.top/ """
  import subprocess import requests import os import re from time import sleep
  token = "icqxxx"
 
 
  def search(token):     url = "https://apiterminator.ichunqiu.com/xxx"     headers = {"user-agent": "Mozilla/5.0"}     url = url + "?token=" + token     data = requests.get(url, headers=headers).json()     return data
 
 
  def download(file_url, title):     headers = {"user-agent": "Mozilla/5.0"}     res = requests.get(file_url, headers=headers)     os.makedirs('download', exist_ok=True)     zip_path = f'download/{title}.zip'
      with open(zip_path, 'wb') as f:         f.write(res.content)
      if os.name == 'nt':         subprocess.run(['powershell', 'Expand-Archive', '-Path', zip_path, '-DestinationPath', f'download/{title}', '-Force'])     else:         subprocess.run(['unzip', '-o', zip_path, '-d', f'download/{title}'])
      print(f"[+]{title}下载解压完成")
 
 
  def run(docker_ip, docker_port, title):     exp_dir = 'exp'     prefix = title.split('-')[0]     for filename in os.listdir(exp_dir):         if filename.startswith(prefix) and filename.endswith('.py'):             file_path = os.path.join(exp_dir, filename)             try:                 process = subprocess.Popen(['python', file_path, docker_ip, str(docker_port)], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)             except FileNotFoundError:                 return None             stdout, stderr = process.communicate()             return stdout
      print(f"[-]{title} 没有对应exp")     os.makedirs('exp', exist_ok=True)     open(f'exp/{prefix}.py', 'w').close()     return None
 
 
  def get_flag(token, question_id, flag):     url = "https://apiterminator.ichunqiu.com/xxx"     url = url + "?token=" + token + "&question_id=" + question_id + "&answer=" + flag     headers = {"user-agent": "Mozilla/5.0"}     res = requests.get(url, headers=headers).json()     return res
 
 
  def rank():     data = {"team_name": "", "industry_id": "", "attribute_id": "", "page_index": 1, "page_size": 10, "k": "BjNQYA0-B2cKewQjUjcBJVdxD3lXPFRmVDRTbgcxXGpVagQ3W25QPVZh", "stamp": 1732941812896, "token": "login:match_1211:e5cedf979df76cda478bde52601c12d7", "rs": "83a994740e198e91d37f1f195a515412"}     url = "http://apiterminator.ichunqiu.com/match/rank/solved"     headers = {"user-agent": "Mozilla/5.0", "SIGN": "xxx"}     res = requests.post(url, headers=headers, data=data).json()     return res
 
  data = search(token) if data['code'] != 0:     print("[-]获取题目信息失败")     exit() for item in data['data']:     question_id = item['question_id']     title = item['title']     score = item['score']     real_score = item['real_score']     file_url = item['file_url']     is_solved = item['is_solved']     solved_number = item['solved_number']     docker_ip = item['docker_ip']     docker_port = item['docker_port']     flag_url = item['flag_url']     attribute = item['attribute']
      if is_solved:         print(f"[+]{title} 已解出")     else:         download(file_url, title)         print(f"[+]正在解决 {title}")         flag = run(docker_ip, docker_port, title)
          match = re.search(r'flag\{.*}', str(flag))         if match:             flag = match.group()             print(f"[+]{title} flag: {flag}")             rsp = get_flag(token, question_id, flag)             code = rsp['code']             message = rsp['message']             if code == 0:                 print(f"[+]{title} 解题成功")                 print(f"[+]{title} 已有{solved_number}次解出")                 print(f"[+]{title} 得分{real_score}")             else:                 print(f"[-]{title} 解题失败")                 print(f"[-]{title} {message}")         else:             print(f"[-]{title} exp运行失败")
      print("---------------------------------------------------")     sleep(1)
  rank = rank() for item in rank['data']['lists']:     team_name = item['team_name']     school = item['school']     total_score = item['total_score']
      print(f"队伍: {team_name} 学校: {school} 总分: {total_score}")
 
 
  |