-
Notifications
You must be signed in to change notification settings - Fork 0
/
hotel-rio-karlsruhe.ps1
80 lines (68 loc) · 2.24 KB
/
hotel-rio-karlsruhe.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#Requires -Version 5.1
# hotel-rio-karlsruhe.ps1 Login script
# Save file, open powershell, launch:
# .\hotel-rio-karlsruhe.ps1
enum State {
unknown
alreadyloggedin = 1
success = 2
failure = 4
}
$global:cookies = $null
function Get-TimeStamp {
return "{0:yyyy-MM-dd}T{0:HH:mm:ss}" -f (Get-Date)
}
function Invoke-Login {
try {
$r = Invoke-WebRequest "https://server.frederix-hotspot.de/" `
-UserAgent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" `
-Headers @{
'Referer' = 'https://server.frederix-hotspot.de/?auth=free&pageID=page-0'
} `
-SessionVariable cookies `
-MaximumRedirection 42 `
-UseBasicParsing
if (-not -not ($r.Content -like "*Login successful*")) {
return [State]::alreadyloggedin
}
} catch { }
try {
$r = Invoke-WebRequest "https://server.frederix-hotspot.de/?auth=free&pageID=page-0" `
-UserAgent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" `
-Headers @{
'Referer' = 'https://server.frederix-hotspot.de/'
} `
-Method "POST" `
-Body @{
'auth' = 'free';
'lp-screen-size' = '1040%3A1920%3A2160%3A3840';
'submit-login' = 'Anmeldung'
} `
-SessionVariable cookies `
-MaximumRedirection 42 `
-UseBasicParsing
if ($r.Content -like "*Login successful*") {
return [State]::success
}
} catch { }
return [State]::failure
}
function Invoke-TestRequest {
try {
$r = Invoke-WebRequest "https://serverless.industries/robots.txt" `
-UserAgent "Wifi Portal Login Powershell Script" `
-MaximumRedirection 42 `
-UseBasicParsing
return -not -not ($r.Content -like "*User-Agent:*")
} catch {
return $false
}
}
Write-Host "[$(Get-TimeStamp)] Starting"
while ($true) {
if (-not (Invoke-TestRequest)) {
Write-Host "[$(Get-TimeStamp)] Login"
Invoke-Login
}
Start-Sleep -Seconds 5
}