Monday, June 18, 2012

BSD FTP-Proxy: PF Firewall Allow Outgoing Active / Passive FTP Connections

Q. I've FreeBSD based Apache webserver. I need to allow outgoing ftp client requests so that BSD ports collection can download from various ftp sites. How do I allow outgoing FTP connection via PF network firewall software under FreeBSD or OpenBSD operating system?

A. You need to use ftp-proxy, which is a proxy for the Internet File Transfer Protocol. ftp-proxy is installed by default along with PF firewall.

Step # 1: Turn on ftp-proxy under FreeBSD

Open /etc/rc.conf file under FreeBSD
# vi /etc/rc.conf
Append following line:
ftpproxy_enable="YES"
If you are using OpenBSD, type the following command to start the ftp proxy on boot:
echo 'ftpproxy_flags=""' >>/etc/rc.conf.local
By default ftp proxy listen on 8021 port bind to 127.0.0.1 IP address.

Step # 2: Configure pf and ftp-proxy

Open your /etc/pf.conf file and add following into your NAT section:
To activate it, put something like this in the NAT section of pf.conf:
nat-anchor "ftp-proxy/*"
rdr-anchor "ftp-proxy/*"
rdr pass proto tcp from any to any port ftp -> 127.0.0.1 port 8021

All three rules required, even if your setup does not use NAT. Find your filtering rule and append the following rules:
anchor "ftp-proxy/*"
Save and close the file.

Sample pf.conf rules

Here is my own working sample /etc/pf.conf file that allows outgoing ftp, along with ssh, http, dns service. It only allows incomming traffic on port 53, 80:
#### First declare a couple of variables ####
# outgoing services
tcp_services = "{ ssh, smtp, domain, www, https, ntp, 43}"
udp_services = "{ domain, ntp }"
icmp_types = "{ echoreq, unreach }"
 
martians = "{ 127.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8, 169.254.0.0/16, 192.0.2.0/24, 0.0.0.0/8, 240.0.0.0/4 }"
 
ext_if = "em1" # Internet
int_if = "em0" # vpn / lan
 
proxy="127.0.0.1" # ftp proxy IP
proxyport="8021" # ftp proxy port
 
#### Normalization
scrub in all
 
#### NAT and RDR start
nat-anchor "ftp-proxy/*"
rdr-anchor "ftp-proxy/*"
 
# Redirect ftp traffic to proxy
rdr pass proto tcp from any to any port ftp -> $proxy port $proxyport
 
#### Start filtering
# Drop incoming everything
block in all
 
# Default connection refused message to client
block return
 
# keep stats of outging connections
pass out keep state
 
# We need to have an anchor for ftp-proxy
anchor "ftp-proxy/*"
 
# Unlimited traffic for lo0 and VPN/Lan interface
set skip on {lo0, $int_if}
 
# activate spoofing protection for all interfaces
block in quick from urpf-failed
 
# Antispoof is a common special case of filtering and blocking. This mechanism protects against activity from spoofed or forged IP addresses
antispoof log for $ext_if
 
#Block RFC 1918 addresses
block drop in log (all) quick on $ext_if from $martians to any
block drop out log (all) quick on $ext_if from any to $martians
 
# Allow outgoing via ssh, smtp, domain, www, https, whois etc
pass out on $ext_if proto tcp to any port $tcp_services
pass out on $ext_if proto udp to any port $udp_services
 
# Allow outgoing Trace route
pass out on $ext_if inet proto udp from any to any port 33433 >< 33626 keep state
 
# Allow incomming named udp / tcp 53
pass in on $ext_if proto udp from any to any port 53
# All tcp service protected using synproxy
pass in on $ext_if proto tcp from any to any port 53 flags S/SA synproxy state
# Allow http traffic
pass in on $ext_if proto tcp from any to any port 80 flags S/SA synproxy modulate state
# SSH
pass in on $ext_if proto tcp from any to any port 22 flags S/SA synproxy modulate state
# Allow ICMP ping
pass inet proto icmp all icmp-type $icmp_types keep state

Step # 3: Restart PF firewall

Type the following command under FreeBSD:
# /etc/rc.d/pf restart
OR type the following under OpenBSD (also works under FreeBSD):
# pfctl -nf /etc/pf.conf
# pfctl -f /etc/pf.conf

Step # 4: Start ftp-proxy

Type the following command to start ftp-proxy under, FreeBSD:
# /etc/rc.d/ftp-proxy start
Under OpenBSD, you can simply type the following to start ftp-proxy:
# /usr/sbin/ftp-proxy

Test your setup

Use ftp client to test your test, enter:
$ ftp ftp.freebsd.org

How To Back Up a Web Server

Q. I'm using Red Hat Enterprise Linux based Apache web server. How do I backup my Apache webserver, MySQL and PostgreSQL database to another disk called /backup and then copy it to other offsite backup ssh server called backup.example.com?

A. There are many tools under Linux / UNIX to backup a webserver. You can create a simple shell script to backup everything to /backup directory. You can also copy /backup directory content offsite using ssh and scp tool.

Step # 1: Create /root/backup.sh script

Use the following shell script (download link):
#!/bin/bash
# A Simple Shell Script to Backup Red Hat / CentOS / Fedora / Debian / Ubuntu Apache Webserver and SQL Database
# Path to backup directories
DIRS="/home/vivek/ /var/www/html/ /etc"
 
# Store todays date
NOW=$(date +"%F")
 
# Store backup path
BACKUP="/backup/$NOW"
 
# Backup file name hostname.time.tar.gz
BFILE="$(hostname).$(date +'%T').tar.gz"
PFILE="$(hostname).$(date +'%T').pg.sql.gz"
MFILE="$(hostname).$(date +'%T').mysql.sq.gz"
 
# Set Pgsql username
PGSQLUSER="vivek"
 
# Set MySQL username and password
MYSQLUSER="vivek"
MYSQLPASSWORD="myPassword"
 
# Remote SSH server setup
SSHSERVER="backup.example.com" # your remote ssh server
SSHUSER="vivek" # username
SSHDUMPDIR="/backup/remote" # remote ssh server directory to store dumps
 
# Paths for binary files
TAR="/bin/tar"
PGDUMP="/usr/bin/pg_dump"
MYSQLDUMP="/usr/bin/mysqldump"
GZIP="/bin/gzip"
SCP="/usr/bin/scp"
SSH="/usr/bin/ssh"
LOGGER="/usr/bin/logger"
 
# make sure backup directory exists
[ ! -d $BACKUP ] && mkdir -p ${BACKUP}
 
# Log backup start time in /var/log/messages
$LOGGER "$0: *** Backup started @ $(date) ***"
 
# Backup websever dirs
$TAR -zcvf ${BACKUP}/${BFILE} "${DIRS}"
 
# Backup PgSQL
$PGDUMP -x -D -U${PGSQLUSER} | $GZIP -c > ${BACKUP}/${PFILE}
 
# Backup MySQL
$MYSQLDUMP -u ${MYSQLUSER} -h localhost -p${MYSQLPASSWORD} --all-databases | $GZIP -9 > ${BACKUP}/${MFILE}
 
# Dump all local files to failsafe remote UNIX ssh server / home server
$SSH ${SSHUSER}@${SSHSERVER} mkdir -p ${SSHDUMPDIR}/${NOW}
$SCP -r ${BACKUP}/* ${SSHUSER}@${SSHSERVER}:${SSHDUMPDIR}/${NOW}
 
# Log backup end time in /var/log/messages
$LOGGER "$0: *** Backup Ended @ $(date) ***"
Customize it according to your needs, set username, password, ssh settings and other stuff.

Step # 2: Create ssh keys

Create ssh keys for password less login from your server to another offsite server hosted at your own home or another datacenter. See following faqs for more information:
  • Howto Linux / UNIX setup SSH with DSA public key authentication (password less login)
  • SSH Public key based authentication - Howto

Step #3: Create Cron job

Setup a cronjob to backup server everyday, enter:
# crontab -e
Append following code to backup server everyday at midnight:
@midnight /root/backup.sh

FreeBSD php5-posix-5.2.6 has known vulnerabilities error – Stop in /usr/ports/sysutils/php5-posix.

Q. When I run make install clean for php5-extensions port, I'm dumped with the following error:
/usr/ports/sysutils/php5-posix
===> php5-posix-5.2.6 has known vulnerabilities:
=> php -- input validation error in posix_access function.
Reference: < http://www.FreeBSD.org/ports/portaudit/ee6fa2bd-406a-11dd-936a-0015af872849.html >
=> Please update your ports tree and try again.
*** Error code 1
Stop in /usr/ports/sysutils/php5-posix.
*** Error code 1
Stop in /usr/ports/lang/php5-extensions.
*** Error code 1
Stop in /usr/ports/lang/php5-extensions.
How do I fix this error?

A. Try upgrading your port tree by typing the following commands:
# portsnap fetch update
# portaudit -Fda

If you still see the error, temporarily disable error by adding following code to /etc/make.conf file:
# get around php5-posix error
.if !empty(.CURDIR:M*sysutils/php5-posix*)
DISABLE_VULNERABILITIES=yes
.endif
Save and close the file. Try to rebuild port again:
# cd /usr/ports/lang/php5-extensions
# make install clean

Another option is build /usr/ports/lang/php5-extensions port without looking at VULNERABILITIES:
# make -DDISABLE_VULNERABILITIES install
According to FreeBSD security team:
It should be noted that this vulnerability is not considered to be serious by the FreeBSD Security Team, since safe_mode and open_basedir are insecure by design and should not be relied upon.

dnstop: Monitor BIND DNS Server (DNS Network Traffic) From a Shell Prompt

Q. How do I monitor my Bind 9 named (or any other dns server) server traffic / network traffic under Linux? How do I find out and view current DNS queries such as A, MX, PTR and so on in real time? How do I find out who is querying my DNS server or specific domain or specific dns client IP address?

A. Log file can give out required information but dnstop is just like top command for monitoring dns traffic. It is a small tool to listen on device or to parse the file savefile and collect and print statistics on the local network's DNS traffic. You must have read access to /dev/bpf*. bpf (Berkeley Packet Filter) which provides a raw interface to data link layers in a protocol independent fashion. All packets on the network, even those destined for other hosts, are accessible through this mechanism.
dnstop can either read packets from the live capture device, or from a tcpdump savefile.

Install dnstop

Type the following command to install dnstop under Debian / Ubuntu Linux:
$ sudo apt-get update
$ sudo apt-get install dnstop

A note about Red Hat / CentOS / RHEL / Fedora Linux

Install latest version using make command (see below for for binary RPM file). First, grab latest source code by visiting official dnstop website.
First install required development libs, enter:
# yum install libpcap-devel ncurses-devel
Now, grab latest source code using wget command, enter:
# cd /tmp
# wget http://dns.measurement-factory.com/tools/dnstop/src/dnstop-20080502.tar.gz
# tar -zxvf dnstop-20080502.tar.gz
# cd dnstop-20080502

Compile and install dnstop, enter:
# ./configure
# make
# make install

dnstop rpm file

Alternatively, you can download dnstop rpm from dag's repo for RHEL / CentOS / Fedora Linux.

dnstop under FreeBSD

If you are using FreeBSD, follow these installation instructions.

Monitor Dns Server

You can monitor various dns data and queries using command line options.

How do I view dns traffic with dnstop?

Simply, type the following command at a shell prompt to monitor traffic for eth0 interface:
# dnstop {interface-name}
# dnstop eth0
# dnstop em0

Sample output:
2 new queries, 220 total queries                  Mon Aug  4 05:56:50 2008
Sources count %
---------------- --------- ------
180.248.xxx.26 72 32.7
77.89.xx.108 7 3.2
186.xxx.13.108 5 2.3
90.xxx.94.39 4 1.8
178.xx.77.83 4 1.8
187.xxx.149.23 4 1.8
xxx.13.249.70 4 1.8
1.xxx.169.102 4 1.8
189.xx.191.126 4 1.8
xxx.239.194.97 3 1.4
You can force dnstop to keep counts on names up to level domain name levels by using the -l {level} option. For example, with -l 2 (the default), dnstop will keep two tables: one with top-level domain names (such as .com, .org, .biz etc), and another with second level domain names (such as co.in, col.uk).
# dnstop -l 3 eth0
Under Debian / Ubuntu Linux, enter:
# dnstop -t -s eth0
Where,
  • -s Track second level domains
  • -t Track third level domains
Please note that increasing the level provides more details, but also requires more memory and CPU to keep track of DNS traffic.

How do I exit or reset counters?

To exit the dnstop, hit ^X (hold [CTRL] key and press X). Press ^R to reset the counters.

How do find out TLD generating maximum traffic?

While running dnstop, hit 1 key to view first level query names (TLDs):
5 new queries, 1525 total queries                 Mon Aug  4 06:11:09 2008
TLD count %
------------------------------ --------- ------
net 520 34.1
biz 502 32.9
in-addr.arpa 454 29.8
in 23 1.5
org 15 1.0
com 11 0.7
Look like this DNS server is serving more .net TLDs. You can also find out more about actual domain name by hinting 2 key while running dnstop:
3 new queries, 1640 total queries                 Mon Aug  4 06:13:20 2008
SLD count %
------------------------------ --------- ------
cyberciti.biz 557 34.0
nixcraft.net 556 33.9
74.in-addr.arpa 34 2.1
208.in-addr.arpa 29 1.8
195.in-addr.arpa 28 1.7
192.in-addr.arpa 27 1.6
64.in-addr.arpa 27 1.6
theos.in 23 1.4
203.in-addr.arpa 20 1.2
202.in-addr.arpa 18 1.1
212.in-addr.arpa 15 0.9
nixcraft.com 13 0.8
217.in-addr.arpa 13 0.8
213.in-addr.arpa 12 0.7
128.in-addr.arpa 12 0.7
193.in-addr.arpa 12 0.7
simplyguide.org 12 0.7
cricketnow.in 3 0.2
To find out 3 level domain, hit 3 key:
www.cyberciti.biz         60   39.0
figs.cyberciti.biz 33 21.4
ns1.nixcraft.net 18 11.7
ns3.nixcraft.net 13 8.4
ns2.nixcraft.net 13 8.4
theos.in 5 3.2
nixcraft.com 5 3.2
cyberciti.biz 2 1.3
jobs.cyberciti.biz 1 0.6
bash.cyberciti.biz 1 0.6

How do I display the breakdown of query types seen?

You can easily find out most requested, query type (A, AAAA, PTR etc) by hinting t key
Query Type     Count      %
---------- --------- ------
A? 224 56.7
AAAA? 142 35.9
A6? 29 7.3

How do I find out who is connecting to my DNS server?

Hit d to view dns client IP address:
Source         Query Name        Count       %
-------------- ------------- --------- ------
xx.75.164.90 nixcraft.net 20 9.1
xx.75.164.90 cyberciti.biz 18 9.1
x.68.25.4 nixcraft.net 9 9.1
xxx.131.0.10 cyberciti.biz 5 4.5
xx.104.200.202 cyberciti.biz 4 4.5
202.xxx.0.2 cyberciti.biz 1 4.5

Option help

There many more option to provide detailed view of current, traffic, just type ? to view help for all run time options:
 s - Sources list
d - Destinations list
t - Query types
o - Opcodes
r - Rcodes
1 - 1st level Query Names ! - with Sources
2 - 2nd level Query Names @ - with Sources
3 - 3rd level Query Names # - with Sources
4 - 4th level Query Names $ - with Sources
5 - 5th level Query Names % - with Sources
6 - 6th level Query Names ^ - with Sources
7 - 7th level Query Names & - with Sources
8 - 8th level Query Names * - with Sources
9 - 9th level Query Names ( - with Sources
^R - Reset counters
^X - Exit
? - this

Linux bnx2: eth1: No interrupt was generated using MSI, switching to INTx mode

Q. I see following message in my logs files:
Linux bnx2: eth1: No interrupt was generated using MSI, switching to INTx mode
My server hangs occasionally after rebooting with above message in /var/log/message. How do I get rid of this problem under CentOS Linux / RHEL version 4.x?

A. This problem can be fixed by upgrading kernel provided by CentOS Linux 4.6 (RHEL 4.6+) or above only. This is well know driver problem. Upgrade your Linux distribution to latest version using up2date / yum command.

psad: Linux Detect And Block Port Scan Attacks In Real Time

Q. How do I detect port scan attacks by analyzing Debian Linux firewall log files and block port scans in real time? How do I detect suspicious network traffic under Linux?

A. A port scanner (such as nmap) is a piece of software designed to search a network host for open ports. Cracker can use nmap to scan your network before starting attack. You can always see scan patterns by visiting /var/log/messages. But, I recommend the automated tool called psad - the port scan attack detector under Linux which is a collection of lightweight system daemons that run on Linux machines and analyze iptables log messages to detect port scans and other suspicious traffic.
psad makes use of Netfilter log messages to detect, alert, and (optionally) block port scans and other suspect traffic. For tcp scans psad analyzes tcp flags to determine the scan type (syn, fin, xmas, etc.) and corresponding command line options that could be supplied to nmap to generate such a scan. In addition, psad makes use of many tcp, udp, and icmp signatures contained within the Snort intrusion detection system.

Install psad under Debian / Ubuntu Linux

Type the following command to install psad, enter:
$ sudo apt-get update
$ sudo apt-get install psad

Configure psad

Open /etc/syslog.conf file, enter:
# vi /etc/syslog.conf
Append following code
kern.info       |/var/lib/psad/psadfifo
Alternatively, you can type the following command to update syslog.conf:
echo -e ’kern.info\t|/var/lib/psad/psadfifo’ >> /etc/syslog.conf
psad Syslog needs to be configured to write all kern.info messages to a named pipe /var/lib/psad/psadfifo. Close and save the file. Restart syslog:
# /etc/init.d/sysklogd restart
# /etc/init.d/klogd

The default psad file is located at /etc/psad/psad.conf:
# vi /etc/psad/psad.conf
You need to setup correct email ID to get port scan detections messages and other settings as follows:
EMAIL_ADDRESSES             vivek@nixcraft.in;
Set machine hostname (FQDN):
HOSTNAME                    server.nixcraft.in;
If you have only one interface on box (such as colo web server or mail server), sent HOME_NET to none:
HOME_NET                NOT_USED;  ### only one interface on box
You may also need to adjust danger levels as per your setup. You can also define a set of ports to ignore, for example to have psad ignore udp ports 53 and 5000, use:
IGNORE_PORTS                udp/53, udp/5000;
You can also enable real time iptables blocking, by setting following two variables:
ENABLE_AUTO_IDS             Y;
IPTABLES_BLOCK_METHOD Y;
psad has many more options, please read man pages for further information. Save and close the file. Restart psad:
# /etc/init.d/psad restart

Update iptables rules

psad need following two rules with logging enabled:
iptables -A INPUT -j LOG
iptables -A FORWARD -j LOG
Here is my sample Debian Linux desktop firewall script with logging enabled at the end:
#!/bin/bash
IPT="/sbin/iptables"
 
echo "Starting IPv4 Wall..."
$IPT -F
$IPT -X
$IPT -t nat -F
$IPT -t nat -X
$IPT -t mangle -F
$IPT -t mangle -X
modprobe ip_conntrack
 
BADIPS=$(egrep -v -E "^#|^$" /root/scripts/blocked.fw)
PUB_IF="eth0"
 
#unlimited
$IPT -A INPUT -i lo -j ACCEPT
$IPT -A OUTPUT -o lo -j ACCEPT
 
# DROP all incomming traffic
$IPT -P INPUT DROP
$IPT -P OUTPUT DROP
$IPT -P FORWARD DROP
 
# block all bad ips
for ip in $BADIPS
do
$IPT -A INPUT -s $ip -j DROP
$IPT -A OUTPUT -d $ip -j DROP
done
 
# sync
$IPT -A INPUT -i ${PUB_IF} -p tcp ! --syn -m state --state NEW -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "Drop Syn"
 
$IPT -A INPUT -i ${PUB_IF} -p tcp ! --syn -m state --state NEW -j DROP
 
# Fragments
$IPT -A INPUT -i ${PUB_IF} -f -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "Fragments Packets"
$IPT -A INPUT -i ${PUB_IF} -f -j DROP
 
# block bad stuff
$IPT -A INPUT -i ${PUB_IF} -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
$IPT -A INPUT -i ${PUB_IF} -p tcp --tcp-flags ALL ALL -j DROP
 
$IPT -A INPUT -i ${PUB_IF} -p tcp --tcp-flags ALL NONE -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "NULL Packets"
$IPT -A INPUT -i ${PUB_IF} -p tcp --tcp-flags ALL NONE -j DROP # NULL packets
 
$IPT -A INPUT -i ${PUB_IF} -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
 
$IPT -A INPUT -i ${PUB_IF} -p tcp --tcp-flags SYN,FIN SYN,FIN -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "XMAS Packets"
$IPT -A INPUT -i ${PUB_IF} -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP #XMAS
 
$IPT -A INPUT -i ${PUB_IF} -p tcp --tcp-flags FIN,ACK FIN -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "Fin Packets Scan"
$IPT -A INPUT -i ${PUB_IF} -p tcp --tcp-flags FIN,ACK FIN -j DROP # FIN packet scans
 
$IPT -A INPUT -i ${PUB_IF} -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
 
# Allow full outgoing connection but no incomming stuff
$IPT -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -o eth0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
 
# allow ssh only
$IPT -A INPUT -p tcp --destination-port 22 -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 22 -j ACCEPT
 
# allow incoming ICMP ping pong stuff
$IPT -A INPUT -p icmp --icmp-type 8 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -p icmp --icmp-type 0 -m state --state ESTABLISHED,RELATED -j ACCEPT
 
# No smb/windows sharing packets - too much logging
$IPT -A INPUT -p tcp -i eth0 --dport 137:139 -j REJECT
$IPT -A INPUT -p udp -i eth0 --dport 137:139 -j REJECT
 
# Log everything else
# *** Required for psad ****
$IPT -A INPUT -j LOG
$IPT -A FORWARD -j LOG
$IPT -A INPUT -j DROP
 
# Start ipv6 firewall
# echo "Starting IPv6 Wall..."
/root/scripts/start6.fw
 
exit 0

How do I view port scan report?

Simply type the following command:
# psad -S
Sample output (some of the sensitive / personally identified parts have been removed):
[+] psadwatchd (pid: 2540)  %CPU: 0.0  %MEM: 0.0
Running since: Sun Jul 27 07:14:56 2008
[+] kmsgsd (pid: 2528) %CPU: 0.0 %MEM: 0.0
Running since: Sun Jul 27 07:14:55 2008
[+] psad (pid: 2524) %CPU: 0.0 %MEM: 0.8
Running since: Sun Jul 27 07:14:55 2008
Command line arguments: -c /etc/psad/psad.conf
Alert email address(es): radhika.xyz@xxxxxxxx.co.in
src: dst: chain: intf: tcp: udp: icmp: dl: alerts: os_guess:
117.32.xxx.149 xx.22.zz.121 INPUT eth0 1 0 0 2 2 -
118.167.xxx.219 xx.22.zz.121 INPUT eth0 1 0 0 2 2 -
118.167.xxx.250 xx.22.zz.121 INPUT eth0 1 0 0 2 2 -
118.167.xxx.5 xx.22.zz.121 INPUT eth0 1 0 0 2 2 -
122.167.xx.11 xx.22.zz.121 INPUT eth0 4642 0 0 4 50 -
122.167.xx.80 xx.22.zz.121 INPUT eth0 0 11 0 1 2 -
123.134.xx.34 xx.22.zz.121 INPUT eth0 20 0 0 2 9 -
125.161.xx.3 xx.22.zz.121 INPUT eth0 0 9 0 1 4 -
125.67.xx.7 xx.22.zz.121 INPUT eth0 1 0 0 2 2 -
190.159.xxx.220 xx.22.zz.121 INPUT eth0 0 9 0 1 3 -
193.140.xxx.210 xx.22.zz.121 INPUT eth0 0 10 0 1 2 -
202.xx.23x.196 xx.22.zz.121 INPUT eth0 0 13 0 1 10 -
202.xx.2x8.197 xx.22.zz.121 INPUT eth0 0 20 0 2 17 -
202.97.xxx.198 xx.22.zz.121 INPUT eth0 0 17 0 2 12 -
202.97.xxx.199 xx.22.zz.121 INPUT eth0 0 18 0 2 15 -
202.97.xxx.200 xx.22.zz.121 INPUT eth0 0 17 0 2 14 -
202.97.xxx.201 xx.22.zz.121 INPUT eth0 0 15 0 2 12 -
202.97.xxx.202 xx.22.zz.121 INPUT eth0 0 21 0 2 16 -
203.xxx.128.65 xx.22.zz.121 INPUT eth0 12 0 0 2 6 Windows XP/2000
211.90.xx.14 xx.22.zz.121 INPUT eth0 1 0 0 2 2 -
213.163.xxx.9 xx.22.zz.121 INPUT eth0 0 0 1 2 2 -
221.130.xxx.124 xx.22.zz.121 INPUT eth0 0 35 0 2 31 -
221.206.xxx.10 xx.22.zz.121 INPUT eth0 0 33 0 2 21 -
221.206.xxx.53 xx.22.zz.121 INPUT eth0 0 33 0 2 27 -
221.206.xxx.54 xx.22.zz.121 INPUT eth0 0 39 0 2 26 -
221.206.xxx.57 xx.22.zz.121 INPUT eth0 0 33 0 2 19 -
60.222.xxx.146 xx.22.zz.121 INPUT eth0 0 40 0 2 33 -
60.222.xxx.153 xx.22.zz.121 INPUT eth0 0 14 0 1 11 -
60.222.xxx.154 xx.22.zz.121 INPUT eth0 0 18 0 2 15 -
Netfilter prefix counters:
"SPAM DROP Block": 161519
"Drop Syn Attacks": 136
Total scan sources: 95
Total scan destinations: 1
Total packet counters:
tcp: 5868
udp: 164012
icmp: 2

How do I remove automatically blocked ips?

Simply type the following command to remove any auto-generated firewall block
# psad -F

How do I view detailed log for each IP address?

Go to /var/log/psad/ip.address/ directory. For example, view log for IP address 11.22.22.33, enter:
# cd /var/log/psad/11.22.22.33
# ls -l

Sample output:
-rw------- 1 root root 2623 2008-07-30 13:02 xx.22.zz.121_email_alert
-rw------- 1 root root 32 2008-07-30 13:02 xx.22.zz.121_packet_ctr
-rw------- 1 root root 0 2008-07-29 00:27 xx.22.zz.121_signatures
-rw------- 1 root root 11 2008-07-30 13:02 xx.22.zz.121_start_time
-rw------- 1 root root 2 2008-07-30 13:02 danger_level
-rw------- 1 root root 2 2008-07-30 13:02 email_count
-rw------- 1 root root 1798 2008-07-29 00:27 whois
Use cat / more or less command to view rest of the information.

Ubuntu Linux Install GDesklets GNOME Program

Q. How do I install GDesklets GNOME program under Ubuntu Linux to enhance my desktop?

A. gDesklets is a GNOME program which provides the architecture for small desktop widgets to be placed on top of the user's desktop. The applets placed on the desktop are meant to be quick ways for the user to retrieve information and not get in the way of normal activity.

Task: Install GDesklets Under Debian / Ubuntu Linux

Open terminal and type the following command:
$ sudo apt-get install gdesklets gdesklets-data
Sample output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
xulrunner-1.9 librarian0 apturl dbus-x11
Use 'apt-get autoremove' to remove them.
Recommended packages:
xmms python-xmms libwww-search-perl python-soappy python-imaging python-feedparser
The following NEW packages will be installed:
gdesklets gdesklets-data
0 upgraded, 2 newly installed, 0 to remove and 29 not upgraded.
Need to get 4401kB of archives.
After unpacking 15.8MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com gutsy/universe gdesklets-data 0.35.6-1ubuntu1 [3923kB]
Get:2 http://archive.ubuntu.com gutsy/universe gdesklets 0.35.3-4ubuntu2 [478kB]
Fetched 4401kB in 43s (100kB/s)
Selecting previously deselected package gdesklets-data.
(Reading database ... 144425 files and directories currently installed.)
Unpacking gdesklets-data (from .../gdesklets-data_0.35.6-1ubuntu1_all.deb) ...
Selecting previously deselected package gdesklets.
Unpacking gdesklets (from .../gdesklets_0.35.3-4ubuntu2_i386.deb) ...
Setting up gdesklets-data (0.35.6-1ubuntu1) ...
Setting up gdesklets (0.35.3-4ubuntu2) ...

How do I start GDesklets?

Simply click on the Application > Accessories > GDesklets
You should see a dialog box as follows:

(Fig. 01: Gnome GDesklets Shell)
Now select required desktop widget and click on display button. Some of the following I use regularly
  1. Clock
  2. Calendar
  3. Weather
  4. RSS feed aggregators
  5. Controls for other applications (such as XMMS and Pidgin)
  6. Desktop notes
  7. System monitors etc
To configure widget right click > Select configure desklet. Here is my desktop with desklets:

(Fig. 02: GDesklets in Action)