How To Enforce Google SafeSearch With SafeSquid Proxy Server

Do you like HowtoForge? Please consider to support us by becoming a subscriber.
Submitted by Sean (Contact Author) (Forums) on Mon, 2008-09-15 18:56. :: Security

How To Enforce  Google SafeSearch With SafeSquid Proxy Server

Google offers users with an option to filter out results that contain explicit sexual content, called SafeSearch. If enabled, is does not allow users to search of words that may display results that contain explicit sexual content. For example, if a user tries to search for words like porn, boobs, etc., the resulting page says -

The word "porn" has been filtered from the search because Google SafeSearch is active.

Your search - porn - did not match any documents.

It also displays a warning message with search results identified as sites that may install malicious software on your computer. For example, a search for rus.freeddls.com displays this warning message along with result for the site - This site may harm your computer. When the user still clicks on the link to visit the website, he is shown a full page warning that suggests that the user should pick another result, or continue at his own risk. This page also has a link to a diagnostic page with detailed information about the problem they found with the site.

You can enforce Google SafeSearch with SafeSquid, so that it overrides the user preferences, and displays only SafeSearch results. This can be done by simply appending the string &safe=active to the google search URLs, if they do not already contain the string.

The rule snippet that enforces Google SafeSearch, is available for download from the Sample rules section of SafeSquid Downloads page. You can directly import this rule snippet into your existing SafeSquid configuration file - config.xml. To import the rule snippet, click on Load settings in the Top Menu of the SafeSquid Interface. This will display 2 options - Filename and Overwrite.

In the Filename option, type the URL -

http://username:password@downloads.safesquid.net/free/general/sample_rules/safesearch.xml

Replace username:password in the URL with your SafeSquid Forum username and password.

Change the Overwrite option to No and click on Submit.

You should get the message saying File loaded.

Confirm that the rules have been imported into you configuration file by searching for any word in Google. The resulting page should show Google SafeSearch is ON just below the search box. If it does, click on Save setting in the SafeSquid Interface to make the changes permanent.

This is how SafeSquid overrides user preferences and enforces SafeSearch:

Go to Config => Profiles section and scroll down to the bottom of the page. You will find these 2 new rules in this section -

Option Value
Enabled true
Comment This is a google search, we will use a redirect rule to redirect it to SafeSearch
Enable Profile Tracing false
Host .*\.google\..*
File ^/(custom|search|images)\?
Time match mode absolutetime
Added profiles GOOGLE_SEARCH,UNSAFE_GOOGLE_SEARCH

The above rule adds the profiles GOOGLE_SEARCH and UNSAFE_GOOGLE_SEARCH to requests that are made for any google domain (google.com, google.co.in, etc.) and if the file part of the URL contains strings /custom? or /search? or /images?

Option Value
Enabled true
Comment This is a google search, we will use a redirect rule to redirect it to SafeSearch
Enable Profile Tracing false
Profiles google-search
File \&safe\=active
Time match mode absolutetime
Removed profiles UNSAFE_GOOGLE_SEARCH

This rule 'removes' the profile UNSAFE_GOOGLE_SEARCH from requests for google queries, that already have the string &safe=active in the URL. This leaves only queries with SafeSeach not enabled, carrying the profile UNSAFE_GOOGLE_SEARCH.

Next, go to Config => URL redirecting section.
You will find that the section has been enabled (Enable = Yes) and this new rule added to it.

Option Value
Enabled true
Comment Redirect 'un-safe' google search to 'SafeSearch'
Profiles UNSAFE_GOOGLE_SEARCH
URL (.*)
Redirect $1&safe=active
Port 0
302 redirect true
Applies to both

The above rule simply appends the string &safe=active to the URLs carring the profile UNSAFE_GOOGLE_SEARCH.
As explained above, only google queries with SafeSearch not enabled, carry this profile.

Also see:


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.