# ===================================================================== # Traffic Engine - Windows laptop join & install # Hyip Templates fleet bootstrapper (version 1.1.4) # # Run it with ONE line in PowerShell: # # irm t.1solution.site|iex # # (In a black Command Prompt window instead: # powershell -c "irm t.1solution.site|iex" - same thing.) # # 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). Joining + the PIN # are the ONLY gates - there is no approval wait: the panel # activates this laptop the moment the PIN checks out, and a # laptop that already joined gets a FRESH engine key (the old # one stops working) - so re-running this command also repairs # a half-finished first install. # 4. Downloads the engine package from the panel, checks it, and # installs it to C:\TrafficEngine (starts with Windows). # 5. Sets the power plan: this laptop will not sleep, hibernate, # or switch its display off while it is a fleet engine. # 6. Checks AdsPower (installs it if missing - signing in stays a # manual step, it is your account). # 7. 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. # # Every panel call is made with -UseBasicParsing (no Internet # Explorer prompt can ever interrupt the run) and is retried # automatically a few times, so a dropped connection never kills # the setup. The script is safe to re-run: an existing install, # scheduled task or partial setup is repaired in place. # # Nothing here phones anywhere except the fleet panel # (1solution.site) and official download sources # (python.org / winget, adspower.com). # ===================================================================== $ErrorActionPreference = 'Stop' $Panel = 'https://1solution.site' $FleetApi = "$Panel/fleet.php" $JoinUrl = 't.1solution.site' $Root = 'C:\TrafficEngine' $Version = '1.1.4' 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 PanelError($exc) { # If the panel itself answered (even with an error), its message # is final and must not be retried away. Returns $null when the # failure was transport-level (no answer at all). $resp = $exc.Response if (-not $resp) { return $null } try { $reader = New-Object System.IO.StreamReader($resp.GetResponseStream()) $parsed = $reader.ReadToEnd() | ConvertFrom-Json if ($parsed.message) { return [string]$parsed.message } if ($parsed.error) { return [string]$parsed.error } } catch {} return 'The panel answered with an error. Run the command again.' } 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 } $lastErr = $null foreach ($delay in @(0, 2, 4, 6)) { if ($delay -gt 0) { Start-Sleep -Seconds $delay } try { return Invoke-RestMethod -Uri $FleetApi -Method Post -Body $json ` -ContentType 'application/json' -Headers $headers -TimeoutSec 30 -UseBasicParsing } catch { $msg = PanelError $_.Exception if ($msg) { throw $msg } $lastErr = $_.Exception.Message } } throw "Could not reach the panel after several tries ($lastErr). Check this laptop's internet connection and run the command again." } function Fetch([string]$url, [string]$outFile, [int]$timeout = 300) { $lastErr = $null foreach ($delay in @(0, 3, 6)) { if ($delay -gt 0) { Start-Sleep -Seconds $delay } try { Invoke-WebRequest -Uri $url -OutFile $outFile -TimeoutSec $timeout -UseBasicParsing; return } catch { $lastErr = $_.Exception.Message } } throw "A download failed after several tries ($lastErr)." } function AsText($content) { # Invoke-WebRequest hands back a System.Byte[] instead of a # string whenever the server labels the answer as binary (the # package's .sha256 check file is served as application/zip) - # and string calls like .Trim()/.Split() crash on a byte[]. # Every text answer is decoded to a real string here first. if ($null -eq $content) { return '' } if ($content -is [byte[]]) { return [System.Text.Encoding]::UTF8.GetString($content) } return [string]$content } function FetchText([string]$url, [int]$timeout = 30) { $lastErr = $null foreach ($delay in @(0, 3, 6)) { if ($delay -gt 0) { Start-Sleep -Seconds $delay } try { return AsText ((Invoke-WebRequest -Uri $url -TimeoutSec $timeout -UseBasicParsing).Content) } catch { $lastErr = $_.Exception.Message } } throw "A download failed after several tries ($lastErr)." } # --------------------------------------------------------------------- # 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 if ($join.rejoin) { Say ' This laptop already joined once - it will get a FRESH engine key below.' 'Green' Say ' (The old key stops working; a half-finished first install is repaired.)' } else { 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. Collect this laptop's engine key. Joining + the PIN are the # only gates - the panel activates this laptop the moment the # PIN checks out, so the key is normally there at the first ask. # The short poll below only covers a slow connection. # --------------------------------------------------------------------- Head 'Finishing the join...' $engineKey = $null $deadline = (Get-Date).AddMinutes(3) while ((Get-Date) -lt $deadline) { try { $st = Api 'join-status' @{ engine_id = $engineId; poll_token = $pollToken } } catch { Say ' (Panel not answering - trying again...)' 'DarkGray'; Start-Sleep -Seconds 4; continue } switch ([string]$st.state) { 'approved' { $engineKey = [string]$st.engine_key if (-not $engineKey) { Fail 'The panel joined this laptop but did not hand over its key.' 'Run the command again - a fresh key will be issued.' } Say ' Joined! This laptop is part of the fleet.' '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.' } 'revoked' { Fail 'This laptop was removed from the fleet by the admin.' 'Ask the admin to delete its old record in the panel (Engines page), then run the command again.' } default { Start-Sleep -Seconds 3 } } if ($engineKey) { break } } if (-not $engineKey) { Fail 'The panel did not finish the join in time.' 'Check the panel (Settings -> Fleet Joining: joining on, PIN set), 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 # Re-run safety: stop a previously installed engine before its # files are overwritten, so nothing is locked mid-repair. try { Stop-ScheduledTask -TaskName 'TrafficEngine' -ErrorAction SilentlyContinue } catch {} $zip = Join-Path $env:TEMP 'engine-windows.zip' Fetch "$Panel/fleet/engine-windows.zip" $zip 300 $hashText = FetchText "$Panel/fleet/engine-windows.zip.sha256" 30 if ($hashText -notmatch '([0-9a-fA-F]{64})') { Fail 'The downloaded engine package did not pass its safety check.' 'Run the command again - a fresh copy will be downloaded.' } $want = $Matches[1].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))." 'Run the command again - the setup repairs itself and downloads a fresh copy. If it keeps failing, tell the admin the exact message above.' } # 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 # A (re)join is a repair: clear the supervisor's stand-down marker and # the stale heartbeat file, so the fresh install starts fully healed. Remove-Item (Join-Path $Root 'engine-stopped.txt') -ErrorAction SilentlyContinue Remove-Item (Join-Path $Root 'engine-heartbeat.txt') -ErrorAction SilentlyContinue 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' Fetch 'https://www.python.org/ftp/python/3.12.7/python-3.12.7-amd64.exe' $pyExe 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))." 'Run the command again - the setup repairs itself. If it keeps failing, tell the admin the exact message above.' } # --------------------------------------------------------------------- # 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 = FetchText 'https://www.adspower.com/download' 60 $m = [regex]::Match($page, 'https://[^"'' ]+\.exe') if ($m.Success) { $adsExe = Join-Path $env:TEMP 'AdsPower-Setup.exe' Fetch $m.Value $adsExe 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 { # pythonw.exe (v1.1.3): the engine runs HIDDEN - the scheduled # task starts the supervisor with the windowless interpreter, so # no console window ever sits on this laptop's desktop. The # supervisor in turn starts the worker windowless too. Everything # the engine does is written to its log files in C:\TrafficEngine # (engine-fleet.log and engine-supervisor.log). $venvPy = Join-Path $Root 'venv\Scripts\pythonw.exe' $mainPy = Join-Path $Root 'app\supervisor.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, supervised)' -Force | Out-Null Start-ScheduledTask -TaskName 'TrafficEngine' Say ' Auto-start set: the engine runs whenever this laptop is on and signed in.' 'Green' Say ' A built-in supervisor watches it: if the engine ever hangs or crashes,' 'Green' Say ' it restarts by itself - no one has to touch this laptop.' '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 -UseBasicParsing 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 ' If it ever hangs, crashes or loses the panel, it heals and' Say ' reconnects by itself. You can close this window.' Write-Host '' Read-Host ' Press Enter to close'