« Posts under security

Improve security for apc.php

If you’re running APC with PHP, you have the option to download apc.php to view, monitor the usage/stats. However, the default authentication is very open. Without any credential, anyone can view the running stats and also the cached filenames (a simple search on “APC INFO” will show some site running APC). The login is to view per-directory file caching. So if you want to require login credential on ALL access change this code:

to this:

Some Hack Script

After my fare share of performing security audit, these are some hacking script I found, not for the purpose of hacking, but for education, analysis and prevention.

Windows Vista Firewall

If I didn’t know, I would say it sucks and install another firewall, like ZoneAlarm for all my other XP computers. However, after an issue with delay and slow connection to localhost, I have identified the problem is with conflicting firewalls. Uninstalled ZoneAlarm, then tweak Vista Firewall, it’s quite powerful (use w/ Advanced Security option). You’ll be able to add/edit rules just like iptables under Linux. For my purpose, I created a trusted zone for local IP addresses ( and things flies again. Don’t use the default settings, but you don’t have to do much. Just block all incoming AND outgoing for all level (Domain, Public, Private) and check those Enable rules. Only let things out/in under your control.

mod_dosevasive Configuration


The hash table size defines the number of top-level nodes for each child’s hash table. Increasing this number will provide faster performance by decreasing the number of iterations required to get to the record, but consume more memory for table space. You should increase this if you have a busy web server. The value you specify will automatically be tiered up to the next prime number in the primes list (see mod_evasive.c for a list of primes used).


This is the threshhold for the number of requests for the same page (or URI) per page interval. Once the threshhold for that interval has been exceeded, the IP address of the client will be added to the blocking list.


This is the threshhold for the total number of requests for any object by the same client on the same listener per site interval. Once the threshhold for that interval has been exceeded, the IP address of the client will be added to the blocking list.


The interval for the page count threshold; defaults to 1 second intervals.


The interval for the site count threshold; defaults to 1 second intervals.


The blocking period is the amount of time (in seconds) that a client will be blocked for if they are added to the blocking list. During this time, all subsequent requests from the client will result in a 403 (Forbidden) and the timer being reset (e.g. another 10 seconds). Since the timer is reset for every subsequent request, it is not necessary to have a long blocking period; in the event of a DoS attack, this timer will keep getting reset.


If this value is set, an email will be sent to the address specified whenever an IP address becomes blacklisted. A locking mechanism using /tmp prevents continuous emails from being sent.