# ===================================================================== # Traffic Engine - Windows laptop join & install # Hyip Templates fleet bootstrapper (version 1.0.0) # # Run it with ONE line in PowerShell: # # irm t.velkaz.com|iex # # What it does, in order: # 1. Asks Windows for admin rights (one Yes click). # 2. Reads this laptop's hardware (name, model, CPU, GPU, RAM, # disks, Windows version) and sends a join request to the panel. # 3. Asks for the fleet PIN (only the admin knows it; it is set in # the panel under Settings -> Fleet Joining). # 4. Waits while the admin approves this laptop in the panel. # 5. Downloads the engine package from the panel, checks it, and # installs it to C:\TrafficEngine (starts with Windows). # 6. Sets the power plan: this laptop will not sleep, hibernate, # or switch its display off while it is a fleet engine. # 7. Checks AdsPower (installs it if missing - signing in stays a # manual step, it is your account). # 8. Runs small self-tests and reports this laptop READY in the # panel. From then on the panel hands it work within its own # limits - CPU/RAM brakes on this laptop always win. # # Nothing here phones anywhere except the fleet panel # (traffic.hyiptemplates.com) and official download sources # (python.org / winget, adspower.com). # ===================================================================== $ErrorActionPreference = 'Stop' $Panel = 'https://traffic.hyiptemplates.com' $FleetApi = "$Panel/fleet.php" $JoinUrl = 't.velkaz.com' $Root = 'C:\TrafficEngine' $Version = '1.0.0' function Say([string]$msg, [string]$color = 'Gray') { Write-Host $msg -ForegroundColor $color } function Head([string]$msg) { Write-Host '' Write-Host " $msg" -ForegroundColor Cyan } function Fail([string]$what, [string]$todo) { Write-Host '' Say " Something stopped the setup." 'Red' Say " What happened: $what" 'Red' Say " What to do: $todo" 'Yellow' Write-Host '' Read-Host ' Press Enter to close' exit 1 } function Api([string]$action, [hashtable]$body, [string]$key = '') { $body['action'] = $action $json = $body | ConvertTo-Json -Depth 6 $headers = @{} if ($key -ne '') { $headers['X-Engine-Key'] = $key } try { return Invoke-RestMethod -Uri $FleetApi -Method Post -Body $json ` -ContentType 'application/json' -Headers $headers -TimeoutSec 30 } catch { $resp = $_.Exception.Response if ($resp) { try { $reader = New-Object System.IO.StreamReader($resp.GetResponseStream()) $parsed = $reader.ReadToEnd() | ConvertFrom-Json if ($parsed.message) { throw [string]$parsed.message } if ($parsed.error) { throw [string]$parsed.error } } catch { if ($_.Exception.Message -and $_.Exception.Message.Length -gt 3 -and $_.Exception.Message -notmatch 'ConvertFrom-Json|StreamReader') { throw } } } throw "Could not reach the panel ($($_.Exception.Message)). Check this laptop's internet connection and run the command again." } } # --------------------------------------------------------------------- # 1. Admin rights (installing a service-like task + power plan needs it) # --------------------------------------------------------------------- $isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent() ).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (-not $isAdmin) { Say ' The setup needs admin rights on this laptop.' 'Yellow' Say ' Windows will ask once - click Yes. The setup then continues by itself.' try { Start-Process powershell -Verb RunAs -ArgumentList "-NoProfile -Command `"irm $JoinUrl|iex`"" } catch { Fail 'Windows did not allow the admin prompt.' 'Right-click PowerShell, choose "Run as administrator", and run the command again.' } exit 0 } Write-Host '' Say ' ============================================================' 'Cyan' Say ' Traffic Engine - joining this laptop to the fleet' 'Cyan' Say ' ============================================================' 'Cyan' # --------------------------------------------------------------------- # 2. Hardware inventory (sent to the panel with the join request) # --------------------------------------------------------------------- Head 'Reading this laptop...' try { $cs = Get-CimInstance Win32_ComputerSystem $cpu = Get-CimInstance Win32_Processor | Select-Object -First 1 $gpus = (Get-CimInstance Win32_VideoController | ForEach-Object { $_.Name }) -join '; ' $os = Get-CimInstance Win32_OperatingSystem $disks = Get-CimInstance Win32_LogicalDisk -Filter 'DriveType=3' | ForEach-Object { '{0} {1} GB ({2} GB free)' -f $_.DeviceID, [math]::Round($_.Size / 1GB), [math]::Round($_.FreeSpace / 1GB) } $machineId = (Get-CimInstance Win32_ComputerSystemProduct).UUID if (-not $machineId -or $machineId -match '^(0+-|F+-|03000200)') { $machineId = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Cryptography').MachineGuid } $info = @{ hostname = $env:COMPUTERNAME manufacturer = [string]$cs.Manufacturer model = [string]$cs.Model cpu = [string]$cpu.Name cpu_cores = [int]$cpu.NumberOfCores cpu_threads = [int]$cpu.NumberOfLogicalProcessors gpu = $gpus ram_gb = [math]::Round($cs.TotalPhysicalMemory / 1GB, 1) disk = ($disks -join ' | ') os = [string]$os.Caption os_version = [string]$os.Version arch = [string]$os.OSArchitecture engine_version = $Version } } catch { Fail "Windows would not share this laptop's hardware details ($($_.Exception.Message))." 'Run the command again; if it keeps failing, tell the admin the exact message above.' } Say " $($info.manufacturer) $($info.model) - $($info.cpu) - $($info.ram_gb) GB RAM" Say " Windows: $($info.os) ($($info.arch))" # --------------------------------------------------------------------- # 3. Join request (the panel's Joining switch must be on) # --------------------------------------------------------------------- Head 'Asking the panel to join...' try { $join = Api 'join-request' @{ machine_id = $machineId; name = $env:COMPUTERNAME; info = $info } } catch { Fail $_.Exception.Message 'If the panel says joining is off, ask the admin to enable it (panel: Settings -> Fleet Joining), then run the command again.' } if (-not $join.ok) { Fail ([string]$join.message) 'Read the message above - it says what is needed.' } $engineId = [int]$join.engine_id $pollToken = [string]$join.poll_token Say ' Join request sent. This laptop is now listed in the panel (Engines page).' 'Green' # --------------------------------------------------------------------- # 4. The fleet PIN (only the admin knows it) # --------------------------------------------------------------------- if ($join.pin_required) { Head 'Fleet PIN' Say ' Type the fleet PIN the admin set in the panel, then press Enter.' Say ' (The PIN will not show while you type - that is normal.)' while ($true) { $secure = Read-Host ' PIN' -AsSecureString $pin = [Runtime.InteropServices.Marshal]::PtrToStringAuto( [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure)) try { $pinRes = Api 'join-pin' @{ engine_id = $engineId; poll_token = $pollToken; pin = $pin } if ($pinRes.ok) { Say ' PIN accepted.' 'Green'; break } Fail 'The panel did not accept the PIN.' 'Run the command again and type the PIN carefully.' } catch { $msg = $_.Exception.Message Say " $msg" 'Red' if ($msg -match 'locked') { Fail 'This join request is locked after too many wrong PIN tries.' 'Run the command again - it starts a fresh request - and type the PIN carefully.' } } } } elseif ($join.pin_verified) { Say ' PIN step already done for this request.' 'Green' } # --------------------------------------------------------------------- # 5. Wait for the admin's approval in the panel # --------------------------------------------------------------------- Head 'Waiting for approval...' Say ' The admin now approves this laptop in the panel (Engines page).' Say ' Leave this window open - setup continues by itself once approved.' $engineKey = $null $deadline = (Get-Date).AddMinutes(30) $waited = 0 while ((Get-Date) -lt $deadline) { Start-Sleep -Seconds 5 $waited += 5 try { $st = Api 'join-status' @{ engine_id = $engineId; poll_token = $pollToken } } catch { Say ' (Panel not answering - still waiting...)' 'DarkGray'; continue } switch ([string]$st.state) { 'approved' { $engineKey = [string]$st.engine_key if (-not $engineKey) { Fail 'The panel approved this laptop but did not hand over its key.' 'Ask the admin to revoke this laptop in the panel and approve it again, then re-run the command.' } Say ' Approved!' 'Green' break } 'rejected' { Fail 'The admin did not approve this laptop.' 'Nothing was installed. If this was a mistake, ask the admin and run the command again.' } 'burned' { Fail 'This join request got locked (too many wrong PIN tries).' 'Run the command again to start a fresh request.' } default { if ($waited % 30 -eq 0) { Say " Still waiting... ($([int]($waited / 60)) min)" 'DarkGray' } } } if ($engineKey) { break } } if (-not $engineKey) { Fail 'Nobody approved this laptop within 30 minutes.' 'Ask the admin to open the panel (Engines page), then run the command again.' } # --------------------------------------------------------------------- # 6. Install the engine package (downloaded from the panel, hash-checked) # --------------------------------------------------------------------- Head 'Installing the engine...' try { New-Item -ItemType Directory -Force -Path $Root | Out-Null $zip = Join-Path $env:TEMP 'engine-windows.zip' Invoke-WebRequest -Uri "$Panel/fleet/engine-windows.zip" -OutFile $zip -TimeoutSec 300 $want = (Invoke-WebRequest -Uri "$Panel/fleet/engine-windows.zip.sha256" -TimeoutSec 30).Content.Trim().Split(' ')[0].ToLower() $got = (Get-FileHash $zip -Algorithm SHA256).Hash.ToLower() if ($want -ne $got) { Fail 'The downloaded engine package did not pass its safety check.' 'Run the command again - a fresh copy will be downloaded.' } Expand-Archive -Path $zip -DestinationPath (Join-Path $Root 'app') -Force Say ' Engine package installed and verified.' 'Green' } catch { Fail "The engine package could not be installed ($($_.Exception.Message))." 'Check the internet connection and run the command again.' } # Engine config: panel address + this laptop's own key. The key is # never shown on screen and the file is locked to admins + SYSTEM. $config = @{ panel_url = $Panel fleet_api = $FleetApi engine_key = $engineKey machine_id = $machineId name = $env:COMPUTERNAME version = $Version } | ConvertTo-Json $configPath = Join-Path $Root 'engine-fleet.json' Set-Content -Path $configPath -Value $config -Encoding UTF8 try { icacls $configPath /inheritance:r /grant:r 'SYSTEM:F' 'Administrators:F' "$($env:USERNAME):F" | Out-Null } catch { Say ' (Could not tighten the config file permissions - continuing.)' 'DarkGray' } # --------------------------------------------------------------------- # 7. Python runtime (the engine is Python; install it if missing) # --------------------------------------------------------------------- Head 'Checking Python...' $py = $null foreach ($cand in @('py', 'python')) { try { $v = & $cand -c "import sys; print(sys.version_info[:2])" 2>$null if ($v -match '\(3, (1[0-9]|[2-9][0-9])\)') { $py = $cand; break } } catch {} } if (-not $py) { Say ' Python is not installed yet - installing it now (official sources only).' $done = $false try { winget install -e --id Python.Python.3.12 --accept-source-agreements --accept-package-agreements --silent | Out-Null $done = $true } catch { $done = $false } if (-not $done) { try { $pyExe = Join-Path $env:TEMP 'python-installer.exe' Invoke-WebRequest -Uri 'https://www.python.org/ftp/python/3.12.7/python-3.12.7-amd64.exe' -OutFile $pyExe -TimeoutSec 600 Start-Process $pyExe -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1 Include_pip=1' -Wait $done = $true } catch { $done = $false } } # Refresh PATH for this session after an install. $env:Path = [Environment]::GetEnvironmentVariable('Path', 'Machine') + ';' + [Environment]::GetEnvironmentVariable('Path', 'User') foreach ($cand in @('py', 'python')) { try { & $cand -c "import sys" 2>$null; if ($LASTEXITCODE -eq 0) { $py = $cand; break } } catch {} } if (-not $py) { Fail 'Python could not be installed automatically.' 'Install Python 3.12 from python.org (tick "Add to PATH"), then run the command again.' } } Say " Python ready ($py)." 'Green' try { & $py -m venv (Join-Path $Root 'venv') $venvPy = Join-Path $Root 'venv\Scripts\python.exe' & $venvPy -m pip install --quiet --upgrade pip & $venvPy -m pip install --quiet -r (Join-Path $Root 'app\requirements.txt') Say ' Engine components installed.' 'Green' } catch { Fail "The engine's components could not be installed ($($_.Exception.Message))." 'Check the internet connection and run the command again.' } # --------------------------------------------------------------------- # 8. Power plan: never sleep, never hibernate, display always on # --------------------------------------------------------------------- Head 'Setting the power plan...' try { powercfg /change standby-timeout-ac 0 | Out-Null powercfg /change standby-timeout-dc 0 | Out-Null powercfg /change monitor-timeout-ac 0 | Out-Null powercfg /change monitor-timeout-dc 0 | Out-Null powercfg /change hibernate-timeout-ac 0 | Out-Null powercfg /change hibernate-timeout-dc 0 | Out-Null powercfg /hibernate off | Out-Null Say ' Power plan set: this laptop will not sleep or switch its display off.' 'Green' } catch { Say ' Warning: the power plan could not be set. The engine still works,' 'Yellow' Say ' but set "Sleep: Never" and "Screen: Never" in Windows Settings.' 'Yellow' } # --------------------------------------------------------------------- # 9. AdsPower (needed for real browsing profiles) # --------------------------------------------------------------------- Head 'Checking AdsPower...' $adsPaths = @( "$env:LOCALAPPDATA\Programs\AdsPower Global", "${env:ProgramFiles}\AdsPower Global", "${env:ProgramFiles(x86)}\AdsPower Global" ) $adsFound = $false foreach ($p in $adsPaths) { if (Test-Path $p) { $adsFound = $true; break } } if (-not $adsFound) { Say ' AdsPower is not installed - getting the official installer from adspower.com...' $installed = $false try { $page = (Invoke-WebRequest -Uri 'https://www.adspower.com/download' -TimeoutSec 60).Content $m = [regex]::Match($page, 'https://[^"'' ]+\.exe') if ($m.Success) { $adsExe = Join-Path $env:TEMP 'AdsPower-Setup.exe' Invoke-WebRequest -Uri $m.Value -OutFile $adsExe -TimeoutSec 900 Start-Process $adsExe -ArgumentList '/S' -Wait $installed = $true } } catch { $installed = $false } if ($installed) { Say ' AdsPower installed.' 'Green' } else { Say ' AdsPower could not be installed automatically.' 'Yellow' Say ' Opening the official download page - install AdsPower from there.' 'Yellow' try { Start-Process 'https://www.adspower.com/download' } catch {} } Say ' IMPORTANT: open AdsPower once and SIGN IN with the fleet account.' 'Yellow' Say ' Signing in is the one step only you can do - the engine cannot' 'Yellow' Say ' browse for real until AdsPower is signed in on this laptop.' 'Yellow' } else { Say ' AdsPower is installed.' 'Green' Say ' If it is not signed in yet, open it once and sign in with the fleet account.' 'Yellow' } # --------------------------------------------------------------------- # 10. Auto-start: a scheduled task runs the engine at every logon # --------------------------------------------------------------------- Head 'Setting up auto-start...' try { $venvPy = Join-Path $Root 'venv\Scripts\python.exe' $mainPy = Join-Path $Root 'app\fleet_main.py' $action = New-ScheduledTaskAction -Execute $venvPy -Argument "`"$mainPy`"" -WorkingDirectory (Join-Path $Root 'app') $trigger = New-ScheduledTaskTrigger -AtLogOn -User $env:USERNAME $settings = New-ScheduledTaskSettingsSet -RestartCount 5 -RestartInterval (New-TimeSpan -Minutes 1) ` -ExecutionTimeLimit (New-TimeSpan -Hours 0) -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries Register-ScheduledTask -TaskName 'TrafficEngine' -Action $action -Trigger $trigger ` -Settings $settings -Description 'Hyip Templates traffic engine (fleet)' -Force | Out-Null Start-ScheduledTask -TaskName 'TrafficEngine' Say ' Auto-start set: the engine runs whenever this laptop is on and signed in.' 'Green' } catch { Fail "Auto-start could not be set ($($_.Exception.Message))." 'Run the command again; if it keeps failing, tell the admin the message above.' } # --------------------------------------------------------------------- # 11. Self-tests: panel link, AdsPower link, one test proxy # --------------------------------------------------------------------- Head 'Running self-tests...' $loadSnap = @{ cpu_pct = 0; ram_pct = 0; running = 0; free_slots = 0 } try { $os2 = Get-CimInstance Win32_OperatingSystem $loadSnap.ram_pct = [math]::Round((1 - ($os2.FreePhysicalMemory / $os2.TotalVisibleMemorySize)) * 100, 1) } catch {} try { $hb = Api 'heartbeat' @{ load = $loadSnap; running = @(); free_slots = 0; version = $Version; selftest = $true } $engineKey if ($hb.ok) { Say ' [OK] Panel link - this laptop is talking to the panel.' 'Green' } } catch { Fail "The engine is installed but the panel link test failed ($($_.Exception.Message))." 'Check the internet connection. The engine keeps retrying by itself once it is running.' } try { $ads = Invoke-RestMethod -Uri 'http://127.0.0.1:50325/status' -TimeoutSec 5 if ($ads.code -eq 0) { Say ' [OK] AdsPower link - the AdsPower app answers on this laptop.' 'Green' } } catch { Say ' [--] AdsPower app is not answering yet - open AdsPower once and sign in;' 'Yellow' Say ' the engine will use it as soon as it is running.' 'Yellow' } if ($hb -and $hb.test_proxy) { $tp = $hb.test_proxy try { $proxyUrl = '' if ($tp.username) { $proxyUrl = '{0}://{1}:{2}@{3}:{4}' -f $tp.ptype, $tp.username, $tp.password, $tp.host, $tp.port } else { $proxyUrl = '{0}://{1}:{2}' -f $tp.ptype, $tp.host, $tp.port } if ($tp.ptype -eq 'socks5') { $proxyUrl = $proxyUrl -replace '^socks5://', 'socks5h://' } $exitIp = & curl.exe -s -m 20 -x $proxyUrl 'https://ifconfig.me/ip' if ($exitIp -match '^\d+\.\d+\.\d+\.\d+$') { Say " [OK] Proxy test - a fleet proxy works from this laptop (exit $exitIp)." 'Green' } else { Say ' [--] The test proxy did not answer from this laptop. The panel' 'Yellow' Say ' will simply hand this laptop other proxies when work comes.' 'Yellow' } } catch { Say ' [--] Proxy test skipped (no answer). Real work will tell more.' 'Yellow' } } # --------------------------------------------------------------------- # 12. Ready # --------------------------------------------------------------------- Write-Host '' Say ' ============================================================' 'Green' Say " READY - $env:COMPUTERNAME is now part of the fleet." 'Green' Say ' ============================================================' 'Green' Say ' This laptop now shows as Ready in the panel (Engines page).' Say ' Work arrives by itself when campaigns run - always within' Say ' this laptop''s own limits and CPU/RAM brakes.' Say ' You can close this window. The engine keeps running.' Write-Host '' Read-Host ' Press Enter to close'