返回

FDP配置外置更新器(源码公开)

只是一个小东西而已

目录

# 外置FDP配置更新器(Python版本)

经过测试可以使用(请使用python3.8.10进行运行)

使用了HTTP BASIC验证来进行验证防护,当然了还有HWID验证时间戳验证私有浏览器UA验证完整性验证内存解压什么的,但是都太复杂了呜呜呜

点下我呀
 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
import os
import requests
from urllib3.util import Retry
from requests.adapters import HTTPAdapter
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QPushButton, QMessageBox
from PyQt5.QtCore import Qt

USERNAME = 'tRd#D9l6XVY5GFQUQDDN'
PASSWORD = 'c!rY5iMUv8c4jGT1u0nH'

session = requests.Session()
retry = Retry(total=5, backoff_factor=0.1, status_forcelist=[500, 502, 503, 504])
adapter = HTTPAdapter(max_retries=retry)
session.mount('https://', adapter)

class MainWindow(QMainWindow):
    def __init__(self=None):
        super().__init__()
        self.setWindowTitle('FDP配置文件在线更新')
        self.setGeometry(0, 0, 300, 150)
        self.setFixedSize(300, 150)
        qtRectangle = self.frameGeometry()
        centerPoint = QApplication.desktop().availableGeometry().center()
        qtRectangle.moveCenter(centerPoint)
        self.move(qtRectangle.topLeft())
        self.setWindowIcon(QIcon('avatar.jpg'))
        author_label = QLabel(self)
        author_label.setText("<a href='https://blog.xpdbk.com'>© LEl_FENG</a>")
        author_label.setOpenExternalLinks(True)
        author_label.setAlignment(Qt.AlignRight)
        author_label.setGeometry(200, 10, 90, 20)
        welcome_label = QLabel(self)
        welcome_label.setText('<h2>欢迎使用OVO</h2>')
        welcome_label.setAlignment(Qt.AlignLeft)
        welcome_label.setGeometry(10, 10, 150, 30)
        label = QLabel(self)
        label.setText('开始更新FDP配置')
        label.move(100, 50)
        button = QPushButton('更新配置文件', self)
        button.move(100, 90)
        button.clicked.connect(self.download_confirmation)

    def download_confirmation(self):
        reply = QMessageBox.question(self, '确认下载', '确定要更新配置文件吗,可能会覆盖你的配置文件', QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
        if reply == QMessageBox.Yes:
            configs_dir = os.path.join('.minecraft', 'versions', 'FDP', 'FDPCLIENT-1.8', 'configs')
            for file in os.listdir(configs_dir):
                if file.endswith('.json'):
                    os.remove(os.path.join(configs_dir, file))
            download_all_jsons('https://config-pass.lel-feng.workers.dev/fite.txt')

def download_json(url, save_path):
    response = session.get(url, auth=(USERNAME, PASSWORD))
    with open(save_path, 'wb') as out_file:
        out_file.write(response.content)

def download_all_jsons(url):
    response = session.get(url, auth=(USERNAME, PASSWORD))
    if response.status_code == 200:
        content = response.content.decode('utf-8')
        json_urls = [line.strip() for line in content.split('\n') if line.strip()]
        for json_url in json_urls:
            if json_url.endswith('.json'):
                json_filename = os.path.basename(json_url)
                save_path = os.path.join('.minecraft', 'versions', 'FDP', 'FDPCLIENT-1.8', 'configs', json_filename).replace('/', '\\')
                download_json(json_url, save_path)

if __name__ == '__main__':
    app = QApplication([])
    window = MainWindow()
    window.show()
    app.exec_()

# 服务端是什么

CloudFlare Worker的反代脚本

点下我呀
 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
addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
  // 设置 HTTP 基本身份验证的用户名和密码
  const USERNAME = 'tRd#D9l6XVY5GFQUQDDN'
  const PASSWORD = 'c!rY5iMUv8c4jGT1u0nH'

  // 检查请求是否包含正确的身份验证凭据
  const authHeader = request.headers.get('Authorization')
  if (!authHeader || !checkAuth(authHeader,USERNAME,PASSWORD)) {
    return new Response('Unauthorized', {
      status: 401,
      headers: {
        'WWW-Authenticate': 'Basic realm="Access to the requested resource"'
      }
    })
  }

  // 设置源服务器的 URL
  const originUrl = new URL(request.url)
  originUrl.hostname = 'wjgl.pages.dev'
  originUrl.pathname = new URL(request.url).pathname

  // 使用更新后的 URL 创建新请求
  const newRequest = new Request(originUrl, request)

  // 从源服务器获取响应
  const response = await fetch(newRequest)

  // 将响应返回给客户端
  return response
}

function checkAuth(authHeader, username, password) {
  // 解码身份验证头
  const [type, credentials] = authHeader.split(' ')
  if (type !== 'Basic') return false
  const decodedCredentials = atob(credentials)
  
  // 检查提供的凭据是否与预期的用户名和密码匹配
  return decodedCredentials === `${username}:${password}`
}

# Go语言版本

Golang1.20.7

点下我呀
  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
package main

import (
	"io"
	"net/http"
	"os"
	"path/filepath"
	"strings"
	"time"

	"github.com/andlabs/ui"
)

var (
	mainwin *ui.Window
)

func setupUI() {
	mainwin = ui.NewWindow("FDP配置文件在线更新", 300, 150, false)
	mainwin.OnClosing(func(*ui.Window) bool {
		ui.Quit()
		return true
	})
	ui.OnShouldQuit(func() bool {
		mainwin.Destroy()
		return true
	})

	vbox := ui.NewVerticalBox()
	vbox.SetPadded(true)

	hbox := ui.NewHorizontalBox()
	hbox.SetPadded(true)
	vbox.Append(hbox, false)

	welcomeLabel := ui.NewLabel("欢迎使用OVO")
	hbox.Append(welcomeLabel, false)

	updateLabel := ui.NewLabel("开始更新FDP配置")
	vbox.Append(updateLabel, false)

	button := ui.NewButton("更新配置文件")
	button.OnClicked(func(*ui.Button) {
		downloadConfirmation()
	})
	vbox.Append(button, false)

	mainwin.SetChild(vbox)
	mainwin.SetMargined(true)
}

func downloadConfirmation() {
	window := ui.NewWindow("确认下载", 100, 50, false)
	box := ui.NewVerticalBox()
	box.SetPadded(true)
	box.Append(ui.NewLabel("确定要更新配置文件吗,可能会覆盖你的配置文件"), false)
	hbox := ui.NewHorizontalBox()
	hbox.SetPadded(true)
	box.Append(hbox, false)
	buttonYes := ui.NewButton("Yes")
	buttonYes.OnClicked(func(*ui.Button) {
		window.Destroy()
		configsDir := filepath.Join(".minecraft", "versions", "FDP", "FDPCLIENT-1.8", "configs")
		files, _ := os.ReadDir(configsDir)
		for _, file := range files {
			if strings.HasSuffix(file.Name(), ".json") {
				os.Remove(filepath.Join(configsDir, file.Name()))
			}
		}
		downloadAllJSONs("https://tr7mur567m8r6573n67.xpdbk.com/fite.txt")
	})
	hbox.Append(buttonYes, true)
	buttonNo := ui.NewButton("No")
	buttonNo.OnClicked(func(*ui.Button) {
		window.Destroy()
	})
	hbox.Append(buttonNo, true)
	window.SetChild(box)
	window.Show()
}

func downloadAllJSONs(url string) {
	resp, err := http.Get(url)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}

	jsonURLs := strings.Split(string(body), "\n")
	for _, jsonURL := range jsonURLs {
		jsonURL = strings.TrimSpace(jsonURL)
		if strings.HasSuffix(jsonURL, ".json") {
			jsonFilename := filepath.Base(jsonURL)
			savePath := filepath.Join(".minecraft", "versions", "FDP", "FDPCLIENT-1.8", "configs", jsonFilename)
			downloadJSON(jsonURL, savePath)
		}
	}
	time.AfterFunc(100*time.Second, func() { os.Exit(0) })
}

func downloadJSON(url string, savePath string) {
	resp, err := http.Get(url)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	outFile, err := os.Create(savePath)
	if err != nil {
		panic(err)
	}
	defer outFile.Close()

	io.Copy(outFile, resp.Body)
}

func main() {
	ui.Main(setupUI)
}