Skip to content

Instantly share code, notes, and snippets.

@maxnasonov
Forked from p0w3rsh3ll/Proxy.ps1
Last active December 13, 2016 22:15
Show Gist options
  • Save maxnasonov/a0010aaad069f0b4628c to your computer and use it in GitHub Desktop.
Save maxnasonov/a0010aaad069f0b4628c to your computer and use it in GitHub Desktop.
# Define a proxy
Configuration Proxy {
$whitelist = '*.google.com;*.example.com;192.168.*;127.*;localhost'
$prefix_hex = [String]::Format("{0:X}", [Convert]::ToUint32($prefix.tochararray()[0]))
$suffix_hex = [String]::Format("{0:X}", [Convert]::ToUint32($suffix.tochararray()[0]))
$proxy_url = "proxy.example.com:3128"
$proxy_url_length = '{0:X}' -f $proxy_url.length
$proxy_url_hex = StringToHex -string $proxy_url
$whitelist_hex = StringToHex -string $whitelist
$whitelist_length = '{0:X}' -f $whitelist.length
$proxy_settings = "46000000030000000b000000$($proxy_url_length)000000$($proxy_url_hex)$($whitelist_length)000000$($whitelist_hex)000000000000000000000000000000000000000000000000000000000000000000000000"
Registry ProxyPerMachinePolicy
{
Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings'
ValueName = 'ProxySettingsPerUser'
Ensure = 'Present'
ValueData = '0'
ValueType = 'Dword'
Force = $true
}
Registry ProxyPerMachineDefaultConnectionSettings
{
Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections'
ValueName = 'DefaultConnectionSettings'
Ensure = 'Present'
ValueType = 'Binary'
ValueData = $proxy_settings
Force = $true
}
Registry ProxyPerMachineSavedLegacySettings
{
Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections'
ValueName = 'SavedLegacySettings'
Ensure = 'Present'
ValueType = 'Binary'
ValueData = $proxy_settings
Force = $true
}
Registry ProxyPerMachineWinHttPSettings
{
Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections'
ValueName = 'WinHttPSettings'
Ensure = 'Absent'
Force = $true
}
Registry ProxyPerMachineProxyEnable
{
Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings'
ValueName = 'ProxyEnable'
Ensure = 'Present'
ValueData = '1'
ValueType = 'Dword'
Force = $true
}
Registry ProxyPerMachineProxyServer
{
Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings'
ValueName = 'ProxyServer'
Ensure = 'Present'
ValueData = $proxy_url
ValueType = 'String'
Force = $true
}
Registry ProxyPerMachineProxyOverride
{
Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings'
ValueName = 'ProxyOverride'
Ensure = 'Present'
Force = $true
ValueData = $whitelist
ValueType = 'String'
}
Registry ProxyPerMachineAutoConfigURL
{
Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings'
ValueName = 'AutoConfigURL'
Ensure = 'Absent'
Force = $true
}
Registry ProxyPerMachineLockAutoConfig
{
Key = 'HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Internet Explorer\Control Panel'
ValueName = 'Autoconfig'
Ensure = 'Present'
ValueData = '1'
ValueType = 'Dword'
Force = $true
}
Registry ProxyPerMachineLockProxy
{
Key = 'HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Internet Explorer\Control Panel'
ValueName = 'Proxy'
Ensure = 'Present'
ValueData = '1'
ValueType = 'Dword'
Force = $true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment