-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent.ps1
More file actions
50 lines (41 loc) · 2.01 KB
/
agent.ps1
File metadata and controls
50 lines (41 loc) · 2.01 KB
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
$ErrorActionPreference = "Stop"
# 启用 TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if (-not $env:u) { exit }
$u = $env:u
$Dir = "$env:USERPROFILE\.quick_proxy"
if (!(Test-Path $Dir)) { New-Item -ItemType Directory -Path $Dir | Out-Null }
Set-Location $Dir
$exePath = "$Dir\sys_node.exe"
if (!(Test-Path $exePath)) {
$zipUrl = "https://github.com/MetaCubeX/mihomo/releases/download/v1.18.1/mihomo-windows-amd64-v1.18.1.zip"
$zipFile = "$Dir\sys_node.zip"
try {
Invoke-WebRequest -Uri $zipUrl -OutFile $zipFile -UseBasicParsing
Expand-Archive $zipFile -DestinationPath $Dir -Force
Remove-Item $zipFile
$exe = Get-ChildItem $Dir -Filter "mihomo*.exe" | Select-Object -First 1
if ($exe) { Rename-Item $exe.FullName "sys_node.exe" }
} catch { exit }
$dlls = @("vcruntime140.dll","msvcp140.dll")
foreach ($dll in $dlls) {
$dllPath = "$Dir\$dll"
if (!(Test-Path $dllPath)) {
$dllUrl = "https://github.com/MetaCubeX/mihomo/releases/download/v1.18.1/$dll"
try { Invoke-WebRequest -Uri $dllUrl -OutFile $dllPath -UseBasicParsing } catch { }
}
}
}
Get-ChildItem $Dir | Unblock-File
$Api = "https://api.v1.mk/sub?target=clash&insert=false&config=https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini.ini&url=$u"
try { Invoke-WebRequest -Uri $Api -OutFile "$Dir\config.yaml" -UseBasicParsing } catch { exit }
$proc = Get-Process sys_node -ErrorAction SilentlyContinue
if ($proc) { $proc | Stop-Process -Force; Start-Sleep -Seconds 1 }
try {
Start-Process -FilePath $exePath -ArgumentList "-f config.yaml" -WindowStyle Hidden
Start-Sleep -Seconds 2
if (Get-Process sys_node -ErrorAction SilentlyContinue) {
Set-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ProxyEnable 1
Set-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ProxyServer "127.0.0.1:7890"
}
} catch { }