viagra usa viagra pills discounts cialis levitra viagra buy cheap viagra uk sales viagra soft tablets mexico rx viagra cheap viagra germany viagra professional indian genric viagra viagra without rx viagra prescription or non overnight viagra how much viagra costs pfizer viagra cheap viagra in canada buy viagra no prescription pills viagra usa online sales viagra 100g viagra 50 mg delivery viagra 100 mg fast where can i get viagra germany generic viagra canada viagra fast viagra for wwomen overnight generic viagra cheap natural viagra delivery canadian viagra online sale canada non prescription viagra germany online viagra canada canada viagra viagra gel viagra no prescription canadian viagra germany viagra 100 cheap viagra canada viagra oral gel where to buy viagra online now buy viagra online without prescription viagra without a prescription viagra 100mg canadian pharmacy viagra how to buy viagra viagra pfizer viagra purchase discounts what kind of viagra canada viagra usa india viagra viagra discounts discounts viagra uk real viagra cheapest viagra online gel viagra viagra for sale viagra without prescription delivery canadian pharmacies/viagra now how does viagra work? usa pfizer viagra online viagra 100mg cheap where to get viagra for women uk now buy viagra cheap buy purchase viagra with no prescription pills generic viagra 50mg viagra soft viagra overnight canada buy india viagra buy how does viagra work viagra samples germany buy real viagra no rx viagra buy cheap viagra online pharmacy viagra - 100mg canadian buy viagra single online does viagra contains pork or alcohol should you use viagra with a catheter usa viagra sale viagra prescriptions buy pfizer viagra viagra prices usa viagra online sales now viagra side effects sales viagra price comparison viagra cost viagra sales viagra in mexico viagra low price cheap viagra price germany cost of viagra viagra sample germany purchase viagra 50mg reliable purchase of viagra where to buy viagra fast viagra discount viagra with no prescription viagra cheapest germany purchase viagra benefits of viagra germany generic viagra viagra online free viagra viagra drug buy viagra no prescription discount no prescription viagra viagra canadian pharmacy viagra no doctor fast viagra side effect viagra online ordering usa viagra on line usa is there a generic version of viagra buy viagra canada where can i get cheap viagra sales viagra now low price viagra usa discount viagra online viagra on sale cheap viagras viagra on line san marino viagra for women cialis best price cialis best way to take cialis discounts brand cialis discounts brand name cialis pharmacy buy cialis buy cialis without prescription sales buy generic cialis germany buy real cialis canada brand name cialis delivery canada pharmacy cialis canada pharmacy cialis soft buy canadian online cialis canadian pharmacy online generic cialis usa cheap cialis pharmacy cheap cialis no prescription cheapest cialis on the net cheapest price cialis fast cialis 100 cialis 100mg cialis 20mg cialis 30mg fast cialis 50mg cialis abdominal pain cialis age 45 fast cialis available cialis brand cialis canada online cialis canada pharmacy cialis canadian pharmacy cialis costs online cialis fast delivery germany cialis for sale now cialis for women cialis free cialis from canada now cialis from mexico cialis gel cialis generic cheap cialis generic on lice pills cialis in canada now cialis information canada cialis korea sales cialis levitra viagra canada cialis mailed overnight buy cialis medication sales cialis mexico cialis next day cialis next day delivery cialis no prescription pharmacy cialis online canadian delivery cialis online overnight germany cialis overnight cialis overnight delivery now cialis pills cialis pills canadian pharmacy sales cialis price pills cialis professional cialis professional singapore cialis purchase cialis purchase israel fast cialis sample cialis samples cialis side effects cialis suppliers fast cialis tablet sales cialis tablets cialis to children cialis without a prescription pills cialis without prescription pills discount cialis generic cialis buy generic cialis overnight online generic cialis overnight delivery online how cialis works delivery how much is cialis how to get cialis inquiry cialis sales low price cialis online name brand cialis canada next day delivery of cialis non-prescription cialis order cialis sales ordering cialis phentolamine in generic cialis professional cialis pharmacy canada purchase real cialis usa purchse cialis real cialis soft cialis where can i buy cialis where purchase cialis cheap where should i buy cialis online cheap where to buy real cialis buy why cialis does not work cialis daily usa generic viagra female viagra viagra buy cialis daily cialis viagra generic canada women viagra cialis price professional cialis online brand viagra professional online cialis dosage buy cialis no prescription now viagra gel viagra rx in canada buy cialis online canada fast brand viagra without prescription buy delivery viagra from india pills viagra 50 mg generic viagra made in india now cialis professional next day delivery buy cialis us discount viagra overnight delivery sales cialis soft viagra for cheap how to get viagra no prescription cialis professional 100 mg canada china viagra pharmacy buy viagra now price of cialis in canada delivery cheapest viagra online levitra vs viagra buying real viagra without prescription effect of cialis on women discounts cialis daily canada viagra in canada viagra canada pills how much does cialis cost canadian pharmacy cialis sales cialis for women viagra discount natural viagra viagra dosage germany cialis daily cialis without prescription pharmacy canadian pharmacy discount code viagra viagra soft tabs 100 mg now best viagra alternative delivery viagra tablets sale discount cialis herbal viagra viagra sales in canada viagra no prescription canada viagra generic where to purchase viagra canada buy cialis once daily sales viagra side effects viagra 100 mg sales pfizer viagra cheap 5 mg cialis buy viagra in canada no prescription canadian pharmacy viagra legal now price check 50mg viagra professional cialis online generic cialis canadian order usa viagra online now buy pfizer viagra online pills viagra cheap canada cialis professional germany buy cialis on line cheap viagra for sale mexico pharmacy cialis soft viagra real viagra without prescription discount brand name cialis buying cialis on line viagra online pharmacy usa canada online cheap viagra buy viagra china buy cialis generic cialis canada low cost viagra cialis women buy online pharmacy cialis usa cialis canadian pharmacy is pfizer viagra available in india delivery viagra fast delivery delivery get cialis online fast canada pharmacy viagra pfizer cialis professional no prescription cialis canadian pharmacy online overnight canadian viagra fast generic cialis soft tabs pfizer mexico viagra best cialis price viagra china viagra tablets canada cialis 50 mg viagra brand usa women viagra buy generic viagra made in india buy buy cialis without a prescription what better viagra or cialis canadain viagra india usa buy cialis without doctor prescription germany double dose of cialis 5 mg original brand cialis viagra no prescription sales does generic cialis work cheap viagra for women in india now one day delivery cialis pills buy cialis viagra canada generic viagra cheap canada sales buy cialis online uk how does viagra work viagra professional cialis soft canada sales cialis overnight cialis vs levitra cheap real viagra online buy cialis canada online buy viagra online viagra in india cost of viagra now female viagra viagra usa buy viagra cheap canada fast best price for generic cialis us discount viagra overnight delivery cheap viagra overnight delivery buy cialis online without prescription online order viagra overnight delivery buy cialis professional viagra in canada pfizer brand name cialis cialis fast delivery usa now pfizer viagra 50 mg online cheapest prices for viagra sales cheapest prices on viagra viagra canadian scam generic cialis in india cheap viagra for cheap cheap usa generic viagra cialis blood thinner cialisis in canada buy real cialis online overnight viagra buy get cialis online cialis for sale cialis low price cialis generic viagra order buying viagra buy viagra cookies cheap viagra oral gel pharmacy viagra samples viagra pfizer online viagra fast viagra dose sales viagra viagra cost no prescription viagra pills how to get cialis no prescription purchase cialis next day delivery canada viagra pharmacies scam brand name cialis overnight viagra online without a prescription pfizer viagra buy brand name cialis without prescription pills cialis and canada custom online viagra canadian pharmacy dosage cialis next day delivery fast brand viagra over the net can i get viagra in mexico online generic cialis 100 mg online pharmacy cialis low cost canadian viagra buy where to get viagra cheap now cialis canadian pharmacy sales where to get viagra cheap cialis samples in canada buy cialis doctor online viagra overnight delivery viagra generic canada pharmacy cialis germany pfizer female viagra cialis prescription

 

May 21, 2007

CSF - Config Server Firewall

Filed under: Technical Articles — @ 3:55 am

ConfigServer Firewall (csf)

The mains scripts provided by the csf are:

# Straight-forward SPI (Stateful Packet Inspection) iptables firewall script.
# Daemon process that checks for login authentication failures for:

* courier imap and pop3
* ssh
* non-ssl cpanel / whm / webmail (cPanel servers only)
* pure-pftd
* password protected web pages (htpasswd)
* mod_security failures

# POP3/IMAP login tracking to enforce logins per hour
# SSH login notification
# Excessive connection blocking
# WHM iptables report log (cPanel servers only)
# Block traffic on unused server IP addresses - helps reduce the risk to your server
# Alert when end-user scripts sending excessive emails per hour - for identifying spamming scripts
# Suspicious process reporting - reports potential exploits running on the server
# Excessive user processes reporting
# Suspicious file reporting - reports potential exploit files in /tmp and similar directories
# Directory and file watching - reports if a watched directory or a file changes
# Server Security Check - Performs a basic security and settings check on the server (cPanel servers only)
# Alert sent if server load average remains high for a specified length of time
# mod_security log reporting (if installed)

ConfigServer Security & Firewall

CSF is an add-on product for cPanel servers running on Linux.

This suite of scripts provides:

1. A straight-forward SPI iptables firewall script
2. A daemon process that checks for Login Authentication
3. A WHM configuration interface

ConfigServer Firewall (csf)

CSF is a Stateful Packet Inspection (SPI) iptables firewall that may not be as complicated and comprehensive as others, but is straight-forward, easy and flexible to configure and secure with more checks to ensure smooth operation.

Login Failure Daemon (lfd)

LFD is daemon process that runs all the time and periodically (every X seconds) scans the latest log file entries for login attempts against your server that continually fail within a short period of time. Such attempts are often called “Brute-force attacks” and the daemon process responds very quickly to such patterns and blocks offending IP’s quickly.

lfd is also integrated into chkservd on installation so that the WHM > Service
Manager > will restart lfd if it fails for any reason.

WHM Configuration Interface
To help with the ease and flexibility of the suite , csf and lfd developed with a front end
which is accessible by the root account through WHM. From there you can modify the configuration files and stop, start and restart the applications and check their status. This makes configuring and managing the firewall very simple indeed.

2. csf Principles
The idea with csf, as with most iptables firewall configurations, is to block
everything and then allow through only those connections that you want. This is
done in iptables by DROPPING all connections in and out of the server on all
protocols. Then allow traffic in and out from existing connections. Then open
ports up in and outgoing for both TCP and UDP individually.

This way we can control exactly what traffic is allowed in and out of the
server and helps protect the server from malicious attack.

A port filtering firewall can help is when a user level compromise occurs and a hacker installs DOS tools to effect other servers. A firewall configured to block outgoing connections except on specific ports can help prevent DOS attacks from working and make it immediately apparent to you from the system logs.

3. lfd Principles

One of the best ways to protect the server from inbound attack against network
daemons is to monitor their authentication logs. Invalid login attempts which
happen in a short space of time from the same source can often mean someone is
attempting to brute-force their way into the server, usually by guessing
usernames and passwords and therefore generating authentication and login
failures.

lfd can monitor the most commonly abused protocols, SSHD, POP3, IMAP, FTP and
HTTP password protection. Unlike other applications, lfd is a daemon process
that monitors logs continuously and so can react within seconds of detecting
such attempts.

Once the number of failed login attempts is reached, lfd immediately forks a
sub-process and uses csf to block the offending IP address from both in and
outgoing connections. Stopping the attack in its tracks in a quick and timely
manner.

If you want to know when lfd blocks an IP address you can enable the email
alert (which is on by default) and you should watch the log file in
/var/log/lfd.log. If you use logcheck, you can add it to your log monitoring
by editing logcheck.sh and adding the line:

$LOGTAIL /var/log/lfd.log >> $TMPDIR/check.$$

4. csf Command Line Options

You can view the csf command line options by using:

# csf -h

Usage: /usr/sbin/csf [option] [value]

Option Meaning
-h, –help Show this message
-l, –status List/Show iptables configuration
-s, –start Start firewall rules
-f, –stop Flush/Stop firewall rules
-r, –restart Restart firewall rules
-a, –add [ip] Add an IP address to be whitelisted to /etc/csf.allow
-d, –deny [ip] Add an IP address to be blocked to /etc/csf.deny
-u, –update Checks for updates to csf+lfd and performs an upgrade if
available
-x, –disable Disable csf and lfd
-e, –enable Enable csf and lfd if previously disabled
-v, –version Show csf version

These options allow you to easily and quickly control and view csf. All the
configuration files for csf are in /etc/csf and include:

csf.conf - the main configuration file, it has helpful comments explaining what each option does
csf.allow - a list of IP’s and CIDR addresses that should always be allowed through the firewall
csf.deny - a list of IP’s and CIDR addresses that should never be allowed through the firewall

If you modify any of the files listed above, you will need to restart csf to
have them take effect. Both csf.allow and csf.deny can have comments after the IP address listed. The comments must be on the same line as the IP address otherwise the IP rotation of csf.deny will remove them.

You can also include comments when using the csf -a or csf -d commands, but in
those cases you must not use a # like this:

csf -d 11.22.33.44 Added because I don’t like them

5. lfd Command Line Options

lfd doesn’t have any command line options of its own but is controlled through
the init script /etc/init.d/lfd which stops and starts the daemon. It is
configured using the /etc/csf/csf.conf file.

The best way to see what lfd is up to is to take a look in /var/log/lfd.log
where its activities are logged.

The various email alert templates follow, care should be taken if you
modify that file to maintain the correct format:

/etc/csf/alert.txt - for port blocking emails
/etc/csf/tracking.txt - for POP3/IMAP blocking emails
/etc/csf/connectiontracking.txt - for connection tracking emails
/etc/csf/processtracking.txt - for process tracking alert emails
/etc/csf/usertracking.txt - for user process tracking alert emails
/etc/csf/sshalert.txt - for SSH login emails
/etc/csf/sualert.txt - for SU alert emails
/etc/csf/scriptalert.txt - for script alert emails
/etc/csf/filealert.txt - for suspicious file alert emails
/etc/csf/watchalert.txt - for watched file and directory change alert emails
/etc/csf/loadalert.txt - for high load average alert emails
/etc/csf/resalert.txt - for process resource alert emails

If you have problems getting lfd to start you can edit /etc/csf/lfd.pl and set
the $debug variable to 1. This will prevent the daemon process from forking and
allow you to see any perl errors that might be occurring.

7. Script Email Alerts

lfd can scan for emails being sent through exim from scripts on the server.

To use this feature you must add an extended email logging line to WHM >
Exim Configuration Editor > Switch to Advanced Mode > in the first textbox
add the following line:

log_selector = +arguments +subject

If you already already use extended exim logging, then you need to either
include +arguments or use +all

This setting will then send an alert email if more than LF_SCRIPT_LIMIT lines
appear with the same cwd= path in them within an hour. This can be useful in
identifying spamming scripts on a server, especially PHP scripts running
under the nobody account. The email that is sent includes the exim log lines
and also attempts to find scripts that send email in the path that may be the
culprit.

This option uses the /etc/csf/scriptalert text file for alert emails.

If you enable the option LF_SCRIPT_ALERT then lfd will disable the path using
chattr +i and chmod 000 so that the user cannot re-enable it. The alert email
also then includes the commands needed to re-enable the offending path.

Any false-positives can be added to /etc/csf/csf.signore and lfd will then
ignore those listed scripts.

8. Process Tracking

This option enables tracking of user and nobody processes and examines them for
suspicious executables or open network ports. Its purpose is to identify
potential exploit processes that are running on the server.
If a suspicious process is found an alert email is sent with relevant information.

It is then the responsibility of the recipient to investigate the process
further as the script takes no further action. Processes (PIDs) are only
reported once unless lfd is restarted.

There is an ignore file /etc/csf/csf.pignore which can be used to whitelist
either usernames or full paths to binaries

You must use the following format:

exe:/full/path/to/file
user:username
cmd:command line

The command line as reported in /proc has the trailing null character removed
and all other occurrences replaced with a space. So, the line you specify in
the file should have space separators for the command line arguments, not null
characters.

The email alerts are sent using the processtracking.txt email template.

It should be noted that this feature will not pickup a root compromise as root
processes are ignored - you should use established IDS tools for such security
considerations.

9. Directory Watching

Directory Watching enables lfd to check /tmp and /dev/shm and other pertinent
directories for suspicious files, i.e. script exploits.

If a suspicious file is found an email alert is sent using the template
filealert.txt.

To remove any suspicious files found during directory watching, enable
corresponding setting the suspicious files will be appended to a tarball in
/etc/csf/suspicious.tar and deleted from their original location. Symlinks are
simply removed.

If you want to extract the tarball to your current location, use:
tar -xpf /etc/csf/suspicious.tar
This will preserver the path and permissions of the original file.

The lfd directory watching will ignore the files which added in csf.fignore files
/etc/csf/csf.fignore
You must specify the full path to the file

/tmp/clamav.*

You can also add entries to ignore files owner by a particular user by
preceding it with user:, for example:
user:bob

Note: files owned by root are ignored

The second aspect of Directory Watching is enabled with LF_DIRWATCH_FILE. This
option allows you to have lfd watch a particular file or directory for changes
and should they change and email alert using watchalert.txt is sent. It uses a
simple md5sum match from the output of “ls -laAR” on the entry and so will
traverse directories if specified.

10. Advanced Allow/Deny Filters

In /etc/csf.allow and /etc/csf.deny you can add more complex port and ip
filters using the following format (you must specify a port AND an IP address):

tcp/udp:in/out:s/d=port:s/d=ip:u=uid

Broken down:

tcp/udp : EITHER tcp OR udp protocol
in/out : EITHER incoming OR outgoing connections
s/d=port : EITHER source OR destination port number (use a _ for a port range)
s/d=ip : EITHER source OR destination IP address
u/g=UID : EITHER UID or GID of source packet, implies outgoing connections, s/d=IP value is ignored

Examples:

# TCP connections inbound to port 3306 from IP 11.22.33.44
tcp:in:d=3306:s=11.22.33.44

# UDP connections outbound to port 22 on IP 11.22.33.44
udp:out:d=22:d=11.22.33.44

Installation

wget http://www.configserver.com/free/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh

If you would like to disable APF+BFD (which you will need to do if you have
them installed otherwise they will conflict horribly):

sh disable_apf_bfd.sh

That’s it. You can then configure csf and lfd in WHM, or edit the files
directly in /etc/csf/*

Uninstallation

Removing csf and lfd is even more simple:

cd /etc/csf
sh uninstall.sh

Article Authored by Sibu Skariah,

Author, Sibu, is a Sr.Systems Engineer with SupportPRO. Sibu specializes in Windows and Linux servers. SupportPRO offers 24X7 technical support services to Web hosting companies and service providers.

AddThis Social Bookmark Button

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress