Skip to content

Instantly share code, notes, and snippets.

@H3XDaemon
Created November 5, 2023 06:14
Show Gist options
  • Save H3XDaemon/8b67993dd74ec73cceb1b59f609bd691 to your computer and use it in GitHub Desktop.
Save H3XDaemon/8b67993dd74ec73cceb1b59f609bd691 to your computer and use it in GitHub Desktop.
A PowerShell script for modifying the TTL value on Windows systems to bypass mobile hotspot sharing restrictions.
# Get the ID and security principal of the current user account
$myWindowsID = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$myWindowsPrincipal = New-Object System.Security.Principal.WindowsPrincipal($myWindowsID)
# Get the security principal for the Administrator role
$adminRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator
# Check to see if we are currently running "as Administrator"
if ($myWindowsPrincipal.IsInRole($adminRole))
{
# We are running "as Administrator" - so change the title and background color to indicate this
$Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + " (Elevated)"
$Host.UI.RawUI.BackgroundColor = "Black"
clear-host
}
else
{
# We are not running "as Administrator" - so relaunch as administrator
# Create a new process object that starts PowerShell
$newProcess = New-Object System.Diagnostics.ProcessStartInfo "PowerShell";
# Specify the current script path and name as a parameter
$newProcess.Arguments = $myInvocation.MyCommand.Definition;
# Indicate that the process should be elevated
$newProcess.Verb = "runas";
# Start the new process
[System.Diagnostics.Process]::Start($newProcess);
# Exit from the current, unelevated, process
exit
}
# Display the menu
function Display-Menu {
cls
Write-Host "==============================="
Write-Host 'Tethering Limit Bypass'
Write-Host "==============================="
Write-Host "1: Display IPv4 Protocol Configuration"
Write-Host "2: Display IPv6 Protocol Configuration"
Write-Host "3: Set IPv4 and IPv6 Packet TTL to 65"
Write-Host "4: Custom IPv4 and IPv6 Packet TTL"
Write-Host "5: Reset IPv4 and IPv6 Packet TTL"
Write-Host "6: Exit"
}
# Display the protocol configuration
function Display-Protocol {
param (
[string]$Protocol
)
try {
Invoke-Expression ("Get-Net" + $Protocol + "Protocol | Format-List")
} catch {
Write-Host "Error: $_"
}
Read-Host "Press Enter to continue"
}
# Set the TTL
function Set-TTL {
param (
[int]$TTL
)
if ($TTL -lt 1 -or $TTL -gt 255) {
Write-Host "Invalid TTL value. Please enter a value between 1 and 255."
Read-Host "Press Enter to continue"
return
}
Write-Host "Running commands with administrative privileges..."
netsh int ipv4 set glob defaultcurhoplimit=$TTL
netsh int ipv6 set glob defaultcurhoplimit=$TTL
Write-Host "Verifying Packet TTL..."
$current_ttl = (Get-NetIPv4Protocol).DefaultHopLimit
if ($current_ttl -eq $TTL) {
Write-Host "Packet TTL has been set to $TTL successfully."
} else {
Write-Host "Failed to set Packet TTL. Please run this script as an administrator."
}
Read-Host "Press Enter to continue"
}
# Main loop
do {
Display-Menu
$choice = Read-Host "Enter your choice"
switch ($choice) {
'1' { Display-Protocol "IPv4" }
'2' { Display-Protocol "IPv6" }
'3' { Set-TTL 65 }
'4' {
$ttl = Read-Host "Enter your custom TTL value"
if ($ttl -match '^\d+$') {
$ttl = [int]$ttl
if ($ttl -ge 1 -and $ttl -le 255) {
Set-TTL $ttl
} else {
Write-Host "Invalid input. Please enter a numeric value between 1 and 255."
Read-Host "Press Enter to continue"
}
} else {
Write-Host "Invalid input. Please enter a numeric value."
Read-Host "Press Enter to continue"
}
}
'5' { Set-TTL 128 }
'6' { exit }
default { Write-Host "Invalid option" }
}
} while ($true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment