1.加入开机自启,将脚本写入startup的路径中
2.shell自主根据官方文档修改
3.隐藏CMD窗口静默无打扰
警告
严禁用于非法用途!本代码只供研究学习使用!需要自行参悟,无法直接运行,请遵守所在地法律法规。产生任何后果与本站无关
import os
import winreg
importsubprocess
import wmi
import getpass
import sys
from flask import Flask, render_template, request, jsonify
def DnsDef():
wmiService = wmi.WMI()
colNicConfigs = wmiService.Win32_NetworkAdapterConfiguration(IPEnabled=True)
if len(colNicConfigs) < 1:
print("没有找到可用的网络适配器")
exit()
objNicConfig = colNicConfigs[0]
arrDNSServers = ['127.0.0.1']
returnValue = objNicConfig.SetDNSServerSearchOrder(DNSServerSearchOrder=arrDNSServers)
if returnValue[0] == 0:
print("修改成功")
else:
print("修改失败")
username = getpass.getuser()
## 系统盘符名称
syspath = os.getenv("SystemDrive")
## 自启动目录
startupPath = os.path.join(os.getenv("SystemDrive"),r"\users",getpass.getuser(),r"AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup")
link_path = startupPath + "/safednstool.bat"
current_directory = os.getcwd()
yuju1="safednstool.exe"
#print (current_directory)
#print (yuju1)
with open(link_path,'w')as output:
output.write("{cd1}{cd}\n{shel}\n".format(cd1="cd ",cd=current_directory ,shel=yuju1))
DnsDef()
shell="dnsproxy.exe -l 127.0.0.1 -p 53 -u 加密dns地址 -f 8.8.8.8:53 -v -o log.txt"
res = subprocess.call(shell, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
发表回复