Click here to Skip to main content
15,885,767 members
Articles / Programming Languages / C#
Article

Proxy Violator - C# - Disable GPO Enforced Proxy Server without Administrative Permissions

Rate me:
Please Sign up or sign in to vote.
3.62/5 (12 votes)
25 Mar 2008CPOL1 min read 81.1K   1.1K   21   12
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:

C#
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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 1 Pin
sarah-gee-7-Jan-09 1:37
sarah-gee-7-Jan-09 1:37 
GeneralRe: My vote of 1 Pin
xExTxCx2-Jul-09 9:15
xExTxCx2-Jul-09 9:15 
Generalchange proxy settings without having to restart IE Pin
Hoàng Lê Minh24-Sep-08 19:07
Hoàng Lê Minh24-Sep-08 19:07 
GeneralNot a security hole. Pin
talley25-Mar-08 13:38
talley25-Mar-08 13:38 
I recommend reading this article:
Shell policy is not the same as security
http://blogs.msdn.com/oldnewthing/archive/2008/01/31/7337160.aspx[^]

So it is not "A *Glaring* hole in the Windows GPO implementation.".

WBR,
tallicska
GeneralRe: Not a security hole. Pin
xExTxCx25-Mar-08 14:00
xExTxCx25-Mar-08 14:00 
GeneralRe: Not a security hole. Pin
talley25-Mar-08 14:28
talley25-Mar-08 14:28 
GeneralRe: Not a security hole. Pin
xExTxCx25-Mar-08 14:47
xExTxCx25-Mar-08 14:47 
GeneralRe: Not a security hole. Pin
talley26-Mar-08 11:47
talley26-Mar-08 11:47 
QuestionRegistry value change??? Pin
Tom Maloney25-Mar-08 11:02
Tom Maloney25-Mar-08 11:02 
AnswerRe: Registry value change??? Pin
xExTxCx25-Mar-08 11:09
xExTxCx25-Mar-08 11:09 
GeneralRe: Registry value change??? Pin
RMan3268325-Mar-08 11:19
RMan3268325-Mar-08 11:19 
GeneralRe: Registry value change??? Pin
xExTxCx25-Mar-08 11:22
xExTxCx25-Mar-08 11:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.