Don’t let the robots in the door!
A GPL V2 PHP Protection Script for your site.


This php security script is designed to detect certain behaviors detrimental to websites, or known bad addresses attempting to access your site. It then will send the bad robot (usually) or hacker an authentic 403 FORBIDDEN page with a description of what the problem was. If the attacker persists, then they will be served up a permanently reccurring 503 OVERLOAD message with a 24 hour timeout.

If you are looking for a script to help with protection of a Counter-Strike Gaming server, this is not the zBlock program you are looking for. You can find them at http://zblock.mgamez.eu/ , however, many of the same sites could also benefit from what this site has to offer. The name is purely coincidental (I have been using the moniker Zaphod Breeblebrox for 25 years), and their version number is V. 4.4 a post-release. While ZB Block (double Bs and a space) is still in beta development.

What ZB Block is Excellent at:
  • Saves money by reducing hacker bandwith usage! (by 2,500% on this site’s index page alone!)
  • Strengthing your site against defacement.
  • Preventing PHP script exploitation.
  • Ending Remote File Include (RFI) exploits.
  • Protecting against directory traversal attacks.
  • Stopping MySQL database injection and tampering.
  • Removing access from known bad addresses and domain names.
  • Blocking access from top level domains, like .cn (China) and .kp (North Korea).
What ZB Block is Good at:
  • Avoiding website scraping/content theft.
  • Deterring bad user agents.
  • Halting referrer spam.
  • Impeding some Cross Site Scripting (XSS) attacks.
What ZB Block will not do:
  • Protect non-PHP pages.
  • Stop access to non-exploitable resource files like .gif, .jpg, or .swf .

ZB Block is also fast, not only does ZB Block check for over 100,000,000 bad IPs/Hostnames and many thousands of bots, but standard execution times are around 1/10th of a second on an aged PIII 930, which is unnoticable to the web surfer. This anti-exploit / anti-‘sploit / anti-hacking / anti-injection script should find many uses around the web as it’s good at detecting, and stopping exploitation probes from many of the worst known skript kiddie tools.

Why ZB Block is BETTER than .htaccess methods…
  1. Under certiain tasks, it is FASTER than htaccess due to only polling the server for data once per execution. An example of this is domain blocking.
  2. It will run on webservers that do not support the full gamut of .htaccess commands (And there are quite a few).
  3. It allows for intelligent detection of problem clients without previous knowledge of their address.
  4. It can sniff query strings to find attack sequences from all IPs, while allowing legitimate requests to go through.
  5. Through proper signature use, it can automatically remove some blocks that have met a condition. (such as registration of domain)
  6. It can ban whole whole ranges of IPs written in classic decimal quadot notation. You can put your own custom ones in the signatures like through . (.htaccess gets a big FAIL! on dealing with IPs as it uses tricky to maintain CIDR ranges that only work in a most signifigant bit (MSB) method, sometimes requiring multiple entries for oddball ranges. ‘Did I really include all the IPs? Did I accidentally go to far?’)
  7. Some hosts don’t like custom 403s, so they don’t allow you to use your own .htaccess driven 403. ZB Block doesn’t care if the .htaccess is emplaced.
  8. It logs banned accesses for later review in plain, easy to read english, with a description as to why said session was blocked.
  9. It’s simple and easy to use, and requires no authorization beyond the ability to upload files to your php equipped web-server.
  10. Most importantly, it slows down evil robot machines to a crawl (sometimes) and helps alleviate (we hope) your fellow hosts/webmasters from some of the unwanted traffic!

Please note: Several versions of Microsoft IIS are broken, and do not allow custom PHP errors to come through their trashed (in our opinion) architecture. ZB Block is still effective on these systems, but cannot display it’s custom, informative error page. We have no plans to make a work-around to fix this aberrant behaviour that violates proper use of the PHP interpereter. Our best suggestion to you, keep the server OS, and re-rig your server with XAMPP for Windows(clickable link) , and follow standards. Microsoft IIS is jokingly referred to as MS It Isn’t Secure for good reason in our book.

Theory of operation…

This is generally how ZB Block works…

  1. Capture the execution of the page, as close as possible to the beginning of it, definitely before MySQL operations.
  2. Poll all connection details: QUERY, POST, IP, Hostname, Referer, and User Agent. Treat all polled data as hostile and do not attempt to load as distinct variables.
  3. Check for problems in the polled data through the standard signature file.
  4. Check again through the custom signature file.
  5. If no problems are found return execution to the main part of the page and add 0 bytes to connection. Elsewise…
  6. Log connection details to killed_log.txt (Can be very important if you suspect accidental "catches", or wish to inspect the "catch" for more ways to detect the problem).
  7. Handle attack by dumping the connection to a "You Are Banned / 403 Forbidden" page.
  8. Do not return execution to the original file and send DIE command to the php interpereter.

At no time does ZB Block actually perform processing with the data in the connection, nor does it try to correct it. It simply scans the information for known problems. It also does not use MySQL or any other Server Query Language, as that in itself could open up your site to an attack (We don’t want some of this data even getting NEAR your database).

  • At no time should ZB Block effect any hostile actions towards the connecting client, so it is safe for the most serious business website.
  • At no time should ZB Block affect the output of data to a non-hostile connection, thus, it is safe for the most complex websites.

Caveat: ZB Block IS a GPL V.2 script, so responsibilities for problems are the user’s, not the authors. In otherwords, I, or the team, in part or total take no responsibility for loss, damage, or harm, whether real or imagined, if you use this script. That said, we code it very carefully to avoid errors, so we think you can use it with confidence. (This site is currently using it, and protected by it.)



Leave a comment