DenyHosts
์ด ๋๊ตฌ๋ Fail2Ban์ฒ๋ผ IPS๋ก ์ฌ์ฉ๋๋ค. ์๊ฒฉ์์ ์ฌ๋ฌ IP๋ก ๋ฌด์ฐจ๋ณ ์ฐ๊ฒฐ์ ์๋ํ๋ DDoS ๊ณต๊ฒฉ์ ํด์ปค๋ฅผ ๋ง๋ ๊ธฐ๋ฒ ์ค ํ๋์ด๋ค. ์๋ฒ๊ฐ DDoS ๊ณต๊ฒฉ์์์ ๊ฐ์ด ์ฌ์ค IP๋ ์ ์ ์๋ ๋ฌด์ํ ์
์ฑ IP ์ฃผ์๋ค์ ๋ชจ๋ ๋ง์ ์ ์์ผ๋ฏ๋ก ์ฐ๊ฒฐ์ ํ์ฉํ IP ์ฃผ์๋ง ์ง์ ํด๋๊ณ ์๋ฒ์ Messages๋ Secure ๋ก๊ทธ๋ฅผ ์ฝ์ด์ ์ด๋ฐ ์ด์ํ IP ์ฃผ์๋ ๋คํธ์ํฌ๋ค์ ์ฐ๊ฒฐ์ TCPwrapper์ /etc/hosts.deny ํ์ผ์ ๋ฃ์ด์ ๋ง๋ ๊ธฐ๋ฒ์ด๋ค.
TCPwrapper๋ ์ผ๋ฐ์ ์ผ๋ก /etc/hosts.allow ํ์ผ์ ๋จผ์ ๋ณด๊ณ /etc/hosts.deny ํ์ผ์ ๋์ค์ ๋ณด๋ฏ๋ก ์ค์ ์ ๋จผ์ /etc/hosts.deny ํ์ผ์์ ๋ชจ๋ ๊ฑฐ๋ถ๋ก ํด๋๊ณ , /etc/hosts. allow ํ์ผ์์ ํ์ํ ๊ฒ๋ค๋ง ํ์ฉํด์ฃผ๋ฉด ํ์ฉํ ๊ฒ ์ด์ธ์๋ ๋ชจ๋ ๊ฑฐ๋ถ๋๋ค.
์ค์ต
DenyHosts ์ค์น - /usr/src์ ์ค์นํ๋ค(์ผ๋ฐ์ ์ผ๋ก ์ธ๋ถ๋ชจ๋์ ์ค์นํด์ ๋๋๋ ๊ณณ)cd /usr/srcwget http://sourceforge.net/projects/denyhosts/files/denyhosts/2.6/DenyHosts-2.6.tar.gz --no-check-certificate
tar xvfz DenyHosts-2.6.tar.gz
[root@localhost src]# ls
debug DenyHosts-2.6 DenyHosts-2.6.tar.gz kernels
DenyHosts๋ก ๋ค์ด๊ฐ ๋ค์์ ๋ชฉ๋ก์ ๋ณด๊ณ , setup.py์ ์คํ ๊ถํ์ ์ค๋ค.
๊ทธ๋ฆฌ๊ณ python setup.py install์ผ๋ก ์ค์นํ๋ค.
ls /usr/share/denyhosts/ << ์ค์ ํ์ผ
cp -arp denyhosts.cfg-dist denyhosts.cfg
nano -c denyhosts.cfg
์ธ๋ถ์์ sshd vsftpd httpd mysqld ๋ฑ์์ ์ด์ํ ์ ๋ค์ด ๋ค์ด์ค๋ฉด ๋ง์๋ฒ๋ฆฌ๊ฒ ๋ค.
์ด์ํ ์ ๋ค์ด ๋ค์ด์ค๋ฉด ์ฌ๊ธฐ๋ก ๋ฉ์ผ์ ๋ณด๋ด์ฃผ์ธ์.
cp -arp daemon-control-dist daemon-control
๋ณ๊ฒฝํด์ค๋ค.
ln -s /usr/share/denyhosts/daemon-control denyhosts
๋ฐ๋ชฌ์ปจํธ๋กค ์ค์ ํ์ผ์ ์ํํธ๋งํฌ๋ก ๊ฑธ์ด์ค๋ค.
์ฒดํฌ์ฝํผ๊ทธ๋ก ๋ฐ๋ ๋ฒจ์ ์ถ๊ฐํด์ฃผ๊ณ ์ํํธ๋งํฌ๊ฐ ์์ฑ๋ ๊ฒ์ ํ์ธํด์ฃผ๊ณ init.d ์๋น์ค๋ฅผ ์คํํด์ค๋ค.
๋ก์ปฌํธ์คํธ์ ์ผํ ์ค2๋ง ํ์ฉํ๋ค.
/etc/hosts.allow์ /etc/hosts.deny ํ์ผ์์๋ 'Service_name:Host/Network'๋ก ์ค์
httpd : ALL(๋ชจ๋)
sshd : 192.168.100.*(๋คํธ์ํฌ)
sendmail : 192.168.100.200(ํธ์คํธ)
ALL : ALL(๋ชจ๋) ์์ผ๋ก ํด์ค๋ค.
nano /usr/share/denyhosts/denyhosts.cfg ์ค์ ํ์ผ๋ ๋ง์ ธ์ค๋ค.
root@localhost init.d]# chkconfig denyhosts on && service denyhosts start
starting DenyHosts: /usr/bin/env python /usr/bin/denyhosts.py --daemon --config=/usr/share/denyhosts/denyhosts.cfg
DenyHosts could not obtain lock (pid: 4263)
[Errno 17] File exists: '/var/lock/subsys/denyhosts'
[root@localhost init.d]# rm -rf /var/lock/subsys/denyhosts
[root@localhost init.d]# service denyhosts start
starting DenyHosts: /usr/bin/env python /usr/bin/denyhosts.py --daemon --config=/usr/share/denyhosts/denyhosts.cfg
[root@localhost init.d]# cat /var/log/denyhosts
tail -f /var/log/secure
์ค์๊ฐ์ผ๋ก ๋ณด์์ ๊ดํ ๋ก๊ทธ ํ์ผ ๋ณด๊ธฐ
์ค์๊ฐ์ผ๋ก centos2์์ ์ ์ํ๋๋ ๋ด๋ค.
BT๋ ๋ง์๋ค.
OSSEC(Open Source SECurity)
OSSEC๋ ๊ฐ๋ ฅํ IDS/IPS ๋๊ตฌ์ธ๋ฐ ๊ทธ๋ํฝ ๋ชจ๋๋ก ๋ค์ํ๊ฒ ์ค์ ํด์ ๋คํธ์ํฌ์์ ๋ ธ๋๋ค์ ํ๋์ ๋ณผ ์ ์๋ค. ๋คํธ์ํฌ ์์ ๋ ธ๋๋ค์ OSSEC์ ์์ด์ ํธ๊ฐ ๋์ด์ ์์ ๋ค์ ์ ๋ณด๋ฅผ OSSEC์๊ฒ ๋ณด๋ด๋ ๋ฐฉ์์ผ๋ก ํด์ OSSEC๊ฐ ๋ ธ๋๋ค์ ํ๋์ ๊ฐ์งํ๋ค.
๋ณดํต ๋ณด์ ์ค์ ์ HID(Host Intrusion Detection)๊ณผ NID(Network Intrusion Detection)์ผ๋ก ๋๋์ด์ ํด์ค๋ค. ์ด OSSEC๋ HID ์ค์ ์ด๋ค.
๋ณด์ ์นจํด๋ฅผ ๊ฐ์งํ๋ - ModSecurity
ModSecurity๋ ๋ณด์ ์นจํฌ๋ฅผ ๊ฐ์งํ๊ณ ๋ง์์ฃผ๋ ๋ฐฉํ๋ฒฝ์ผ๋ก ์์์ด ์๋ ๋๊ตฌ์ธ๋ฐ Web, DB, ๊ทธ๋ฆฌ๊ณ DDoS ๊ณต๊ฒฉ๋ ์ ๋ง์์ค๋ค. ํ๋ก๊ทธ๋จ์ ๋ด์ฅ๋ ๋ฃฐ ์ด์ธ์ ํ๊ตญ์ ๋ณด๋ณดํธ์งํฅ์(http://www.securenet.or.kr)์์ ModSecurity์ ๋ฃฐ์ ๋ณ๋๋ก ๋ค์ด๋ฐ์์ ์ฌ์ฉํ ์๋ ์๋ค. ์ฐ๋ฆฌ๋๋ผ ๋ณด์๊ธฐ๊ด์์ ์ง์ํ๊ณ ์๋ ๋๊ตฌ์ด๋ฏ๋ก ์ ์์๋๋ฉด ์ข๋ค.
APM(Apache Web server + PHP Web programming language + MySQL Database server)์ Linux ๋จธ์ ์์ ์คํ๋๋ ๋ชจ๋์ด๋ค.
์ค์ต
add-apt-repository ppa:ondrej/php ๋ก ๋ฆฌํฌ์งํฐ๋ฆฌ๋ฅผ ์ถ๊ฐํด์ค๋ค.
apt update && apt -y install apache2 php5.6 mysql-server mysql-client php5.6-mysql
apt -y install libxml2 libxml2-dev libxml2-utils libaprutil1 libaprutil1-dev
apt -y install libapache2-mod-security2
apachectl -M |grep --color security2
cp -arp /etc/modsecurity/modsecurity.conf-recommended /etc/modsecurity/modsecurity.conf
service apache2 reload && service apache2 restart
cat -n /etc/modsecurity/modsecurity.conf
root@ubuntu1:/home/ubuntu# sed -i "7s/DetectionOnly/On/" /etc/modsecurity/modsecurity.conf
root@ubuntu1:/home/ubuntu# sed -i "112s/On/Off/" /etc/modsecurity/modsecurity.conf
root@ubuntu1:/home/ubuntu# sed -n '7p' /etc/modsecurity/modsecurity.conf
SecRuleEngine On
root@ubuntu1:/home/ubuntu# sed -n '112p' /etc/modsecurity/modsecurity.conf
SecResponseBodyAccess Off
sed -n '32,45p' /etc/modsecurity/modsecurity.conf | cat -n
SecRequestBodyInMemoryLimit 131072 << ๋ฉ๋ชจ๋ฆฌ ํฌ๊ธฐ
mysql -u root -p
alter user 'root'@'localhost' identified by 'rootoor';
alter user 'root'@'%' identified by 'rootoor';
create database testt;
create table userss(username varchar(30), password varchar(20));
desc userss;
mysql> insert into userss values('paul', 'paulpass');
Query OK, 1 row affected (0.01 sec)
mysql> insert into userss values('mary', 'marypass');
Query OK, 1 row affected (0.00 sec)
systemctl start mysql && systemctl enable mysql.service
nano /var/www/html/login.php ##์น์์ ์คํ๋จ
chmod +x /var/www/html/login.php
firefox http://localhost/login.html
๋ก๊ทธ์ธ์ด ๋์ด์ผ ํ๋๋ฐ ์ ์๋ ๊น? ใ ใ ใ ใ ใ ๋๋ฉด ๋ค์ ํด์ ์ฌ๋ฆฌ๊ฒ ์.........
PacketFence
์ด ๋๊ตฌ๋ ๋คํธ์ํฌ์์ ์์ง ๋ชปํ๋ ๋ ธ๋๊ฐ ๋ค์ด์ค๋ฉด ํด๋น ๋ ธ๋์ MAC ์ฃผ์๋ฅผ ๊ฒํ ํด์ isolation(๊ฒฉ๋ฆฌ) ๋คํธ์ํฌ๋ก ๋๊ณ , ์ธ์ฆ๋ ๋ ธ๋๋ค์ registration(๋ฑ๋ก) ๋คํธ์ํฌ๋ก ๋๋๋ฐ ๊ด๋ฆฌ์ ๋คํธ์ํฌ๋ ์์ ์ ์๋ค. ํ๋์ ๋ก์ปฌ LAN์ด์ง๋ง ๊ฒฉ๋ฆฌ์ ๋ฑ๋ก ๋คํธ์ํฌ๋ก ๋๋ ์ ์๋ ๊ฒ์ ๋ฐ๋ก VLAN(Virtual LAN)์ผ๋ก ๊ตฌ์ฑํ๊ธฐ ๋๋ฌธ์ด๋ค.