Click here to Skip to main content
Click here to Skip to main content

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

, 25 Mar 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
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

License

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

Share

About the Author

xExTxCx

United States United States
No Biography provided

Comments and Discussions

 
GeneralMy vote of 1 Pinmembersarah-gee-7-Jan-09 2:37 
GeneralRe: My vote of 1 PinmemberxExTxCx2-Jul-09 10:15 
Generalchange proxy settings without having to restart IE PinmemberHoàng Lê Minh24-Sep-08 20:07 
GeneralNot a security hole. Pinmembertalley25-Mar-08 14:38 
GeneralRe: Not a security hole. PinmemberxExTxCx25-Mar-08 15:00 
GeneralRe: Not a security hole. Pinmembertalley25-Mar-08 15:28 
GeneralRe: Not a security hole. PinmemberxExTxCx25-Mar-08 15:47 
GeneralRe: Not a security hole. Pinmembertalley26-Mar-08 12:47 
QuestionRegistry value change??? PinmemberTom Maloney25-Mar-08 12:02 
AnswerRe: Registry value change??? PinmemberxExTxCx25-Mar-08 12:09 
GeneralRe: Registry value change??? PinmemberRMan3268325-Mar-08 12:19 
GeneralRe: Registry value change??? PinmemberxExTxCx25-Mar-08 12:22 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150414.1 | Last Updated 25 Mar 2008
Article Copyright 2008 by xExTxCx
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid