Among the projects I've been doing lately, this one was a side project I decided to do tonight since school starts up again for me tomorrow.
Recently my school instituted a new filter that blocks just about everything, so during the break I wanted to set up a proxy server, since Tor is specifically banned from the list of applications we're aloud to have on our school issued laptops.
For this reason, I decided to turn an old restored desktop computer of mine into a server, I'd been wanting to put it to good use anyway.
The computer has 4 GBs of RAM and runs Windows 7 x64 for reference.
So I decided to provide you guys with a guide to turning your home computer into a proxy server.
Not only did I want a proxy server, but for ease of access, and just something to do, I wanted a GUI interface to go with it all.
While doing all this, I got a bit caught up and also added a web interface.
The original application I wrote for a windows machine, I don't plan on releasing the code for, however for this tutorial I did come up with some similar code in Python to give you an idea of how I set up the application.
This entire tutorial is based on using Windows, although you can technically institute most of this (aside from the method of setting proxy settings) on most distributions of Linux as well as Mac OSX.
Setting up a Web Interface
The first step in setting up a web interface that will be accessible from outside your Local Area Network, is getting a web development environment such as XAMPP or WAMP. I guess it's really your choice and all, but keep in mind XAMPP is cross-platform, which sometimes makes it the preferred alternative. Regardless though, I have more experience with WAMP, so I went with WAMP on Windows. Just go to their website and install the WAMP server according to your machine specs. Also, you're going to need Visual C++ 2010 SP1 Redistributable Package x86 or x64.
Once you've installed WAMP, navigate to your WAMP directory which is usually something like C:\wamp and file the folder labeled www. This is where you'll want to store the web application we'll be downloading in a moment, and when you put everything online, the index.php/index.html in that directory will be your home page.
Now that you've gotten acquainted with WAMP we're going to need a web application. We could build our own, and it wouldn't really be that complicated, but for those less web development savy people like myself, a great alternative is installing PHProxy.
PHProxy is this neat little web proxy that allows you to bypass restrictions such as filters. When you connect to your home proxy server (if I'm correct) the request to whatever website you're trying to access will actually be sent from your home server, which doesn't have a filter. That's how it allows you to bypass filters on a LAN.
After you've downloaded PHProxy, you need to unzip it, and drag all the files into that www directory, replacing any index.php or index.html/htm file with the index.php file found in PHProxy. To test to see if you've installed it correctly, simply navigate to "http://localhost".
It's really that simple. After you've installed it, you can make any kind of tweaks and modifications you want as long as it conforms to the license provided with PHProxy (which I haven't examined at all). So, modify at your own risk. You should probably keep the bottom PHProxy link visible.
Port Forwarding on your Router
You need to do this. If you want your web application accessible from outside your LAN, this is a must. Port forwarding is a bit different for every router, but you should be able to a bunch of guides for whichever router you have on PortForward. What I did, was forward port 80 and port 443 for HTTP and HTTPS. Once you've done this and WAMP is up and running, you can click the WAMP tray icon, and put your application "online". You might run into a few issues, but those can be resolved by some simple error googling.
To confirm your application is online, visit WhatIsMyIP to grab your IP address. Your home server will be running from that address. So simply navigate to http://yourip on n a machine that's not on your local area network. That's very important. If it is on the same network as you, that won't work.
Putting Your Web Application Online
When Tree came out with his auto-activation method, the use of FreeDNS really prompted this method of uploading your application. You can use freedns to point one of the thousands of subdomains you can get for FREE to your home server's IP address. Just follow these simple steps.
- Make a freedns account, as Tree said, use a valid email.
- After you've logged in, go to the Registry link on the far left.
- Search whatever phrase you want for your domain. For example, you could search "proxy" and use one of the 10 or so proxy domains without buying your own.
- Click on whichever domain you'd link, and an option screen listing type, subdomain, domain, destination, TTL, and wildcard should come up. The only thing you need to do is set your subdomain and your destination.
Your subdomain should be whatever you want it to be, for example, mycoolproxy.proxybiz.net or something. In this case, mycoolproxy would be the subdomain you entered. Here's the really important part though. As the destination you MUST enter the external IP address of your home server. FreeDNS will fill this input box out with your IP address, make sure it's the IP address of your home server and not a laptop you're using. Then simply save your settings and navigate to your site. mycoolproxy.proxybiz.net should direct you to your custom home server proxy home page.
There's many other ways to set up your own domain, none of which I'll go into now. But just google "make my own domain" if you feel like paying for a custom name.
Running a secondary (traditional) proxy
To use the IP address of your home computer as a proxy on, say, Internet Explorer or Google Chrome, you'll need the IP and a port number, and a web application just won't suffice as far as I know.
To set up this second section, I used something called Privoxy. Go to the URL, download Privoxy, and install it.
The only issues I've had with Privoxy are some bugs I've been able to iron out.
After you've downloaded Privoxy, open up the application, and your server should be live. I've had a few problems with it, and you might need to change a certain text file's contents. If you receive an error (which you probably will) just Google the error and you'll see all the answers are the same. Unfortunately I didn't write down the error and don't have time to reproduce it tonight.
So during installation you can set up Privoxy to run at startup (which is probably what you want). After it's open your proxy server is live. As long as port forwarding is turned on, you can use your home proxy server from your web browser by using the IP of your home server and the port 8118
Setting up an Application to do it for Us
As I said before, I wanted a GUI frontend because that's just the kind of guy I am. The original one I wrote wasn't in Python, but for this tutorial I whipped up a quick, working representation. Albeit the code isn't very good (mainly because I don't actually know Python) and it doesn't conform to all the PEP-8 standards. So forgive me for that. But either way, here's the code.
It was written for Python 2.7.3 and uses only imports from the Python standard library.
PHP Code:
import os
import sys
import time
import urllib2
import socket
import ConfigParser
from subprocess import call
from sys import stdout
#Global Variables
ini = ConfigParser.RawConfigParser()
ini_file = 'proxy_config.ini'
server = '127.0.0.1'
port = 8118
address = '%s:%i' % (server, port)
status = 'off'
#Check Status of Proxy
def check_status():
global status
ini.read(ini_file)
status = ini.get('SETTINGS', 'status')
return status
#Read Settings from ini File
def read_info():
global server, port
ini.read(ini_file)
server = ini.get('SETTINGS', 'server')
port = ini.getint('SETTINGS', 'port')
#Prompt User for Settings
def prompt_info():
global server, port, status
server = raw_input('Please enter the IP address of your proxy server: ')
port = int(raw_input('Please enter the port number your proxy server is running on: '))
status = raw_input('Is the proxy server currently on or off (on/off)?: ')
#Write Data to ini File
ini.add_section('SETTINGS')
ini.set('SETTINGS', 'server', server)
ini.set('SETTINGS', 'port', port)
ini.set('SETTINGS', 'status', status)
write_ini()
#Proxy Status Checking
def is_invalid_proxy(proxy):
try:
proxy_handler = urllib2.ProxyHandler({'http': proxy})
opener = urllib2.build_opener(proxy_handler)
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
urllib2.install_opener(opener)
req = urllib2.Request('http://www.google.com')
sock = urllib2.urlopen(req)
except urllib2.HTTPError, e:
stdout.write('Error Code: ', e.code)
return e.code
except Exception, detail:
stdout.write('Error: ', detail)
return True
return False
#Turn Proxy on/off by Writing Info to Registry
def write_registry(bool_value):
if (bool_value):
call('reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f')
call('reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d ' + address + ' /f')
else:
call('reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f')
call('reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /f')
stdout.write('Settings have successfully been written to registry.\n')
#Process to Turn on the Proxy
def turn_on():
global address
read_info()
address = '%s:%i' % (server, port)
#Proxy Check
os.system('title Proxy Configuration')
stdout.write('Connecting to the server %s on the port %i...\n' % (server, port))
time.sleep(2)
if is_invalid_proxy(address):
stdout.write('Unable to connect to home proxy server on %s\n' % address)
else:
stdout.write('Successfully connected to proxy server on %s!\n' % address)
time.sleep(0.5)
stdout.write('Writing settings to registry...\n')
time.sleep(0.5)
write_registry(True)
ini.set('SETTINGS', 'status', 'on')
write_ini()
#Process to Turn off the Proxy
def turn_off():
stdout.write('Writing settings to registry...\n')
time.sleep(0.5)
write_registry(False)
ini.set('SETTINGS', 'status', 'off')
write_ini()
#Write Current Settings to the ini File
def write_ini():
with open(ini_file, 'w') as configfile:
ini.write(configfile)
def __main__():
#Check if ini File Exists
if (os.path.exists(ini_file) == 0):
prompt_info()
#Check if Proxy is on or off
if (check_status() == 'on'):
stdout.write('The proxy is currently on. Turning off the proxy now...\n')
turn_off()
else:
stdout.write('The proxy is currently off. Turning on the proxy now...\n')
turn_on()
__main__()
raw_input('Press any key to exit.')
The code is actually pretty shit and incredibly inefficient, but again, I don't know Python and it was written quick and dirty for the purpose of this tutorial. Any code criticisms and critiques would be appreciated, since though I'm not trying to learn Python at the moment, I'd still love the feedback.
The code essentially works off of an .ini file called proxy_config.ini. Any information should be in the format.
Code:[SETTINGS] server = 127.0.0.1 port = 8118 status = on
Even without an .ini file, the code will create its own, according to your input. The code will then check the proxy server to see if it's open for connection (by making a request to google.com utilizing the proxy server). It will then set proxy settings on a Windows machine to those specified.
It does this through this module
PHP Code:
#Turn Proxy on/off by Writing Info to Registry
def write_registry(bool_value):
if (bool_value):
call('reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f')
call('reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d ' + address + ' /f')
else:
call('reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f')
call('reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /f')
stdout.write('Settings have successfully been written to registry.\n')
Here, you can see the registry values edited to either turn the proxy settings on or off.
That's really what's behind the entire application.
So there you go. That's my guide on turning your home computer into a proxy server and writing an application to connect to this server.
All the code can be found on my Github.
LG, Let me know if you know of a way I can make the entire process more efficient, cool features I can add, or any revisions of my code.
By the way, Artificial, would you consider including syntax highlighting for different languages on here?
Results 1 to 17 of 17
- 01 Apr. 2013 01:08am #1
Turning a Home Computer into a Proxy Server
I don't get tired.
- 01 Apr. 2013 01:11am #2
Note I wouldnt actually use your home computer as a proxy for a live website though, due to uncertainty of power and you could get in trouble for what other users search. Good for learning though.
- 01 Apr. 2013 01:16am #3
- 01 Apr. 2013 02:55am #4
- 01 Apr. 2013 03:01am #5
That is incredibly sexy.
Wasn't there a kid that got suspended or something like that for something similar? I believe I remember reading something about it before.
- 01 Apr. 2013 03:03am #6
- 01 Apr. 2013 03:06am #7
- Join Date
- Apr. 2010
- Location
- When freedom is outlawed only outlaws will be free
- Posts
- 5,113
- Reputation
- 195
- LCash
- 1.77
Lol kids get suspended all the time for proxies and shit, it's no big deal though.
@OP: Why not just use one of the 9001 free proxies out there? Don't use a web-based proxy or Tor, they have tons of IP-based proxies and stuff that you can just configure Firefox to use. (Or chrome, if that's your thing).
- 01 Apr. 2013 03:09am #8
- 01 Apr. 2013 03:09am #9
- 01 Apr. 2013 03:13am #10
I'm curious why you would choose a web proxy over Tor. Tor has always been my go to if I really need a quick anonymity, and it protects you from a lot more as well. Sure there are some FBI nodes, and bad exit nodes etc, but none that are really concerned with you. Webproxies are designed to profit, and often strip features and are overall slower than a vindilia bundle or Tor.
- 01 Apr. 2013 03:22am #11
Technically I probably could get suspended, but I won't.
Using a proxy of any sort is against the rules at my school.
For security, again. Any of the free proxies you're using (excluding Tor) are logging all that information you send out.
I control the communication between my laptop and my home server, making it a bit more secure than a random proxy.
It's much more reliable too, and the speeds are better. I don't feel like having to find a new proxy every time one goes down.
I do use Tor under certain circumstances, but again, my home server is faster, and my IP doesn't get blacklisted on Google like a lot of Tor nodes do. If I was doing something shady I obviously wouldn't use my home computer, but for me there's more speed and reliability than a random proxy or a Tor node. (Though a Tor node would have much better security)I don't get tired.
- 01 Apr. 2013 03:25am #12
What won't you kids get suspended for anyways? Be kewl drop out of skewl
Though keep in mind, tor exit nodes will sometimes store info from where you came from, your IP etc. If you are really worried on shady stuff, you could just make a program that uses Tor and jumps identities every 5 minutes or so.
- 01 Apr. 2013 03:43am #13
- 01 Apr. 2013 03:45am #14
- 01 Apr. 2013 03:47am #15
- 01 Apr. 2013 04:17am #16
In case Art visits this thread:
Originally Posted by Isonyx
- 01 Apr. 2013 05:05am #17