В этой заметке будет рассмотрена следующая цепочка приложений: shorewall + (psad + syslog-ng) + squid + havp + clamav + privoxy + tor.
где:
shorewall - файрвол (www.shorewall.net)
psad - детектор сканирования портов (www.cipherdyne.org)
syslog-ng - продвинутый syslog (www.balabit.com/network-security/syslog-ng/)
squid - прокси (www.squid-cache.org);
havp - http анти-вирус прокси (www.server-side.de);
clamav - антивирусный сканер (www.clamav.org)
privoxy - прокси-фильтр (www.privoxy.org)
tor - программа для анонимного серфинга (www.torproject.org)
Логика работы цепочки:
Веб браузер -> squid прокси (кэширование веб трафика) ? -> havp анти-вирусный прокси (проверка на вирусы проходящего трафика) -> privoxy (фильтр трафика) -> tor обеспечние анонимности -> Интернет
Установка ПО
Установить с помощью пакетного менеджера вашего дистрибутива соответствующие пакеты:
shorewall
psad
syslog-ng
squid
havp
clamav
privoxy
tor
Конфигурация ПО
psad (/etc/psad/psad.conf)
Код:
SYSLOG_DAEMON syslog-ng
HOME_NET NOT-USED
syslog-ng (/etc/syslog-ng/syslog-ng.conf)
Код:
destination psadpipe { pipe("/var/lib/psad/psadfifo"); };
filter f_kerninfo { facility(kern); };
log { source(src); filter(f_kerninfo); destination(psadpipe); };
shorewall
Конфигурация shorewall на отдельном компьютере.
/etc/shorewall/interfaces
Код:
#ZONE INTERFACE BROADCAST OPTIONS
net eth0 detect dhcp,tcpflags,routefilter,nosmurfs,logmartians
/etc/shorewall/zones
Код:
#ZONE TYPE OPTIONS IN OUT
# OPTIONS OPTIONS
fw firewall
net ipv4
/etc/shorewall/policy
Код:
#SOURCE DEST POLICY LOG LIMIT:BURST LEVEL
fw net REJECT info
net all DROP info
all all DROP info
#LAST LINE -- DO NOT REMOVE
/etc/shorewall/rules
Код:
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK
# PORT PORT(S) DEST LIMIT GROUP
#SECTION ESTABLISHED
#SECTION RELATED
SECTION NEW
HTTP/ACCEPT fw net
HTTP/DROP net fw
HTTPS/ACCEPT fw net
FTP/ACCEPT fw net
FTP/DROP net fw
Auth/DROP fw net
Auth/DROP net fw
DNS/ACCEPT fw net
Ping/ACCEPT fw net
Ping/DROP net fw
ICQ/ACCEPT fw net
ICQ/DROP net fw
JabberSecure/ACCEPT \
fw net
JabberSecure/DROP \
net fw
#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE
squid (/etc/squid/squid.conf)
Код:
http_port 3128
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
#acl Safe_ports port 70 # gopher
#acl Safe_ports port 210 # wais
#acl Safe_ports port 1025-65535 # unregistered ports
#acl Safe_ports port 280 # http-mgmt
#acl Safe_ports port 488 # gss-http
#acl Safe_ports port 591 # filemaker
#acl Safe_ports port 777 # multiling http
#acl Safe_ports port 901 # SWAT
acl purge method PURGE
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
# Deny CONNECT to other than SSL ports
http_access deny CONNECT !SSL_ports
http_access allow localnet
http_access allow localhost
http_access deny all
cache_peer localhost parent 8080 7 no-query no-digest no-netdb-exchange default
visible_hostname localhost
never_direct allow all
Для анонимного серфинга раскомментируйте следующие строки:
Код:
request_header_access Allow allow all
request_header_access Authorization allow all
request_header_access WWW-Authenticate allow all
request_header_access Proxy-Authorization allow all
request_header_access Proxy-Authenticate allow all
request_header_access Cache-Control allow all
request_header_access Content-Encoding allow all
request_header_access Content-Length allow all
request_header_access Content-Type allow all
request_header_access Date allow all
request_header_access Expires allow all
request_header_access Host allow all
request_header_access If-Modified-Since allow all
request_header_access Last-Modified allow all
request_header_access Location allow all
request_header_access Pragma allow all
request_header_access Accept allow all
request_header_access Accept-Charset allow all
request_header_access Accept-Encoding allow all
request_header_access Accept-Language allow all
request_header_access Content-Language allow all
request_header_access Mime-Version allow all
request_header_access Retry-After allow all
request_header_access Title allow all
request_header_access Connection allow all
request_header_access Proxy-Connection allow all
request_header_access All deny all
havp (/etc/havp/havp.config)
Код:
PARENTPROXY localhost
PARENTPORT 8118
PORT 8080
BIND_ADDRESS 127.0.0.1
ENABLECLAMLIB true
CLAMBLOCKBROKEN true
ENABLECLAMD true
CLAMDSERVER 127.0.0.1
CLAMDPORT 3310
Для хранения временных вайлов HAVP необходим временный каталог, который должен располагаеться на файловой системе с функцией принудительного блокирования. Чтобы не создавать отдельного раздел диска для дирректории HAVP, создадим образ и смонтируем его на эту дирректорию с включеным блокированием. Воспользуемся командой dd:
Код:
dd if=/dev/zero of=havp.img count=1 bs=256M
Врезультате будет создан файл образа размером 256Mb. Переместим этот образ в соответствующую дирректорию, отформатируем и примонтируем его:
Код:
mv havp.img /usr/
mkfs.ext3 /usr/havp.img
mount /usr/havp.img /usr/tmp/havp -o loop,mand
chown -R havp:havp /usr/tmp/havp
Для монтирования полученного образа файла во время загрузки, добавляем в /etc/fstab:
Код:
/usr/havp.img /usr/tmp/havp ext3 loop,mand,noexec 0 0
clamav (/etc/clamd.conf)
Код:
TCPSocket 3310
TCPAddr 127.0.0.1
AllowSupplementaryGroups yes
Код:
usermod -a -G havp clamav
privoxy (/etc/privoxy/config)
Код:
forward-socks4a / localhost:9050 .
tor (/etc/tor/torrc)
Код:
SocksPort 9050 # what port to open for local application connections
SocksListenAddress 127.0.0.1 # accept connections only from localhost
Для корректной работы tor, необходимо установить точное системное время
Используемый материал
http://www.opennet.ru/base/net/shorewall.txt.html
http://blog.doylenet.net/?p=46
https://wiki.torproject.org/noreply/TheOnionRouter/SquidProxy
http://www.cyberciti.biz/faq/linux-detect-port-scan-attacks/
http://forum.antichat.ru/thread126658.html