Proxy Violator - C# - Disable GPO Enforced Proxy Server without Administrative Permissions
Disables GPO enforced proxy server, even if the GPO locks the GUI
Target Audience
- Networking / Security professionals
- System Admins
- The curious
Concepts Covered
- Connecting to and manipulating the registry
- A *Glaring* hole in the Windows GPO implementation
Introduction
First of all, let me say that the use of this program can violate any terms of service or usage policies that are in place at your organization. Please seek permission prior to use, and use this program for testing/proof-of-concept only.
Background
This program was written to demonstrate that even in a Windows domain where Internet Explorer settings are locked down with a GPO, even a basic user ('users' group) can override the GPO setting that forces the use of a proxy server. This can be useful if you are on a public computer that uses a proxy server to filter URLs. This program cannot bypass filtering that uses WCCP or the like to redirect Web traffic at the gateway.
Using the Code
This code is really very simple. All that is required, is that you change a registry setting in the HKEY_CURRENT_USER
hive. (ntuser.dat in the user's profile) All users have the rights to write to this hive, as it stores only the logged in user's settings. This holds true even if the GUI settings are inaccessible due to GPO lock down. Since there is so little code required, I have included the whole application's source:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace proxyViolater
{
public partial class Form1 : Form
{
bool alert = false;
public Form1()
{
InitializeComponent();
checkProxy();
alert = true;
}
//check the state of the proxy settings
//
//
private void checkProxy()
{
//check the registry for the 'ProxyEnable' value
RegistryKey proxy = Registry.CurrentUser.OpenSubKey(
"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
//the possible values are 1 - enabled, or 0 - disabled
int enabled = int.Parse(proxy.GetValue("ProxyEnable").ToString());
//update the GUI
if (enabled == 1)
{
lblStatus.ForeColor = Color.Red;
lblStatus.Text = "Enabled";
}
else
{
lblStatus.ForeColor = Color.Green;
lblStatus.Text = "Disabled";
}
}
//Enable the proxy server
//
//
private void btnEnable_Click(object sender, EventArgs e)
{
//connect to the registry and enable the proxy
RegistryKey cUser = Registry.CurrentUser.OpenSubKey(
"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
cUser.SetValue("ProxyEnable", 1);
checkProxy();
}
//Disable the proxy server
//
//
private void btnDisable_Click(object sender, EventArgs e)
{
//connect to the registry and disable the proxy
RegistryKey cUser = Registry.CurrentUser.OpenSubKey(
"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
cUser.SetValue("ProxyEnable", 0);
checkProxy();
}
//Monitor the label that is update on proxy change
//
//
private void lblStatus_TextChanged(object sender, EventArgs e)
{
//alert the user to restart the browser after every proxy change event.
if (alert)
{
MessageBox.Show("Please restart all open browsers for
proxy change to take effect.");
}
}
//Check for proxy changes every 5 seconds
//
//
private void timer1_Tick(object sender, EventArgs e)
{
//check to see if the GPO refresh interval has changed the setting back
checkProxy();
}
}
}
Points of Interest
It seems like a pretty big hole to me. Let me know if any of you can think of a workaround that would block this behavior using integrated Windows or Active Directory methods.
History
- 25th March, 2008 - Initial post