Last active
October 29, 2023 19:37
-
-
Save Malix-off/ce2bacf00a046a0a59dc064d0119f36c to your computer and use it in GitHub Desktop.
ESSCA Budapest - Auto Wifi Auth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GitHub Gists | |
*/ | |
# Environment | |
*env* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$actionRootPath = $PSScriptRoot | |
$actionPath = Join-Path -Path $actionRootPath -ChildPath "login.ps1" | |
Write-Output $actionRootPath | |
Write-Output $actionPath | |
$taskName = "Login to ESSCA_BUDAPEST" | |
$taskDescription = "When connected to the 'ESSCA_BUDAPEST' network, run the according ps1 script to post the rest authentication request" | |
$CIMTriggerClass = Get-CimClass -ClassName MSFT_TaskEventTrigger -Namespace Root/Microsoft/Windows/TaskScheduler:MSFT_TaskEventTrigger | |
$taskTrigger = New-CimInstance -CimClass $CIMTriggerClass -ClientOnly | |
$taskTrigger.Enabled = $true | |
$taskTrigger.ExecutionTimeLimit = "PT1M" | |
$taskTrigger.Repetition = "MSFT_TaskRepetitionPattern" | |
$taskTrigger.Subscription = "<QueryList><Query Id='0' Path='Microsoft-Windows-NetworkProfile/Operational'><Select Path='Microsoft-Windows-NetworkProfile/Operational'>*[System[Provider[@Name='Microsoft-Windows-NetworkProfile'] and EventID=10000]]</Select></Query></QueryList>" | |
$taskSettings = New-ScheduledTaskSettingsSet -MultipleInstances "IgnoreNew" -RunOnlyIfNetworkAvailable -NetworkName "ESSCA_BUDAPEST" -StartWhenAvailable -AllowStartIfOnBatteries -Compatibility "Win8" -ExecutionTimeLimit 00:01:00 | |
if ($args[0] -eq "EFREI") { | |
$taskTrigger.EndBoundary = "2023-12-15T22:00:00+02:00" | |
$taskSettings.DeleteExpiredTaskAfter = "PT0S" | |
} | |
Register-ScheduledTask -TaskName $taskName -Action $taskAction -Description $taskDescription -Settings $taskSettings -Trigger $taskTrigger | |
Pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"LOGIN": "REPLACE_THIS_TEXT_WITH_YOUR_LOGIN", | |
"PASSWORD": "REPLACE_THIS_TEXT_WITH_YOUR_PASSWORD" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load Env | |
$env = Get-Content -Path 'env.json' -Raw | ConvertFrom-Json | |
$Host.UI.RawUI.WindowTitle = "ESSCA Budapest - Auto Wifi Auth" | |
# Construct Headers | |
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" | |
$headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0") | |
$headers.Add("Accept", "application/json, text/javascript, */*; q=0.01") | |
$headers.Add("Accept-Language", "fr,fr-FR;q=0.5") | |
$headers.Add("Accept-Encoding", "gzip, deflate, br") | |
$headers.Add("Content-Type", "application/x-www-form-urlencoded") | |
$headers.Add("X-Requested-With", "XMLHttpRequest") | |
$headers.Add("Origin", "https://controller.access.network") | |
$headers.Add("DNT", "1") | |
$headers.Add("Referer", "https://controller.access.network/102/portal/") | |
$headers.Add("Sec-Fetch-Dest", "empty") | |
$headers.Add("Sec-Fetch-Mode", "cors") | |
$headers.Add("Sec-Fetch-Site", "same-origin") | |
# Construct Body | |
$body = "action=authenticate&login=$($env.LOGIN)&password=$($env.PASSWORD)&policy_accept=false&private_policy_accept=false&from_ajax=true&wispr_mode=false" | |
# Rest Post | |
Invoke-RestMethod 'https://controller.access.network/portal_api.php' -Method 'POST' -Headers $headers -Body $body | |
# TODO: auth error handling | |
Pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment