/* About ----- This directory contains extra files to make the 'fancy urls' feature even more fancier, by eliminating the 'index.php'-part of the URL Installation ------------ 1. Copy all files in this directory (except for index.html) to your main nucleus dir (where your index.php and action.php file are) If you have an already existing .htaccess file (most ftp-programs don't show hidden files by default, so don't start uploading it without checking your server). If you do, download that old one first, and copy the contents of the new .htaccess file (from the fancyurls folder) in your old one, and upload that... 2. Edit this file so that $CONF['Self'] points to your main directory. NOTE: this time, and only this time, the URL should NOT end in a slash 3. Also edit the $CONF['Self'] variable in your index.php, if you don't want to end up with index.php/item/1234 urls when people come via that way 4. Enable 'Fancy URLs' in the Nucleus admin area (nucleus management / edit settings) 5. Off you go! If it doesn't work: ------------------- Remove the files again (don't forget the hidden file .htaccess). Voila. */ // remember: this URL should _NOT_ end with a slash. $CONF['Self'] = 'http://www.momoso-net.com/~ms08'; ?>
2006-01-16: 不正アクセス対策
今年に入りSSHをねらった不正アクセスが増えてきました。そこでファイヤーウォール(iptables)の設定とswatchによる監視と、不審者を自動で登録しアクセスを拒否する対策をしました。
まず、gentooなのでこのへんを参照しカーネルを再構築します。
swatchのバージョンはapp-admin/swatch-3.1これ!
iptablesのバージョンはnet-firewall/iptables-1.3.4これ!
カーネル再構築後は再起動し自分の環境に合わせてiptablesを設定しておく!
さて、まずこんなシェルを作っておく場所は/etc/swatch/ipselect.shに。
/var/log/auth.logのDid not receive identification string fromとかFailed password for invalid userとかのログをswatchが監視し、下記のシェルに情報をわたしたらシェルがIPアドレスを抜き出してiptablesのアクセス拒否文を発行する。
#!/bin/sh
#---------------------------------------------
# CREATE: MoMoSo-NET.COM. H.COYAMA
# DATE : 2006-01-14
# iptables IP Address check tool Ver.0.01
#---------------------------------------------
IPTMPFILE="/etc/swatch/iptables.tmp" #一時ファイル
IPLOGFILE="/var/log/iptables.log" #ログファイル
TIME=`/bin/date`
/bin/echo $* > $IPTMPFILE
NEW_IP=`/bin/sed 's/port [0-9]* ssh2//g' $IPTMPFILE | \
/bin/sed 's/[A-Z][a-z]* //g' | \
/bin/sed 's/[0-9]* [0-9]*:[0-9]*:[0-9]* //g' | \
/bin/sed 's/gentooez8 sshd\[[0-9]*\]://g' | \ #このへんはてきとうに
/bin/sed 's/[a-z]*//g' | \
/bin/sed 's/ //g'`
/bin/rm -r $IPTMPFILE
/sbin/iptables -A INPUT -s $NEW_IP -j DROP
/bin/echo -e "$TIME /sbin/iptables -A INPUT -s $NEW_IP -j DROP" >> $IPLOGFILE
つぎに、swatchの定義ファイルを作成。場所は/etc/swatch/.swatchrc
watchfor = /Did not receive identification string from/
bell=2
exec "/etc/swatch/ipselect.sh $_"
watchfor = /Failed password for invalid user/
exec "/etc/swatch/ipselect.sh $_"
watchfor = /Illegal user/
exec "/etc/swatch/ipselect.sh $_"
rcファイルはこんな感じ。ちょっとヤッツケっぽいがかんべんして!場所は/etc/init.d/swatchd
#!/sbin/runscript
# Copyright 2004-2006 Husakazu Coyama MoMoSo-NET.COM.
# Ver.0.03
# 2006-01-07 起動及び停止方法の変更
# Ver.0.02
# 記憶にない
# Ver.0.01
# テスト版
SWATCHD_PIDFILE="/var/run/swatchd.pid"
depend() {
need net
}
checkconfig() {
if [ ! -e /etc/swatch/.swatchrc ] ; then
eerror "You need an /etc/swatch/.swatchrc file first"
return 1
fi
}
start() {
checkconfig || return 1
[ -e "${SWATCHD_PIDFILE}" ] && rm -f ${SWATCHD_PIDFILE} &>/dev/null
ebegin "Starting Simple Watcher"
/usr/bin/swatch --config-file /etc/swatch/.swatchrc --tail-file=/var/log/auth.log --daemon
/bin/pidof swatch > ${SWATCHD_PIDFILE}
eend $?
}
stop() {
ebegin "Stopping Simple Watcher"
SWATCHD_PID=`/bin/cat ${SWATCHD_PIDFILE} | /bin/awk '{print $1}'`
/bin/kill -9 "${SWATCHD_PID}"
/bin/rm -f "${SWATCHD_PIDFILE}"
eend $?
}
最後に
rc-update -a iptables default
rc-update -a
iptablesswatchd default再起動してあとは掛かるのを待つだけ。
今回使ったスクリプトはMoMoSo-NET.COM Downloadからどうぞ!
Category: Gentoo Linux No Trackbacks