국가 IP Drop 메뉴얼 (GeoIP, IPtables 를 활용한)
작성일 : 2010.12.27
작성자 : (주)스마일서브 이선규 (seroot.com)


공지사항!

1) 이 설정 메뉴얼은 2010.12.27 일자 서버에 테스트, 적용되었습니다.

2) 아래 설치과정중 특이하게 주의할 사항은 없으나 각자 환경에 따라 iptables 룰셋 적용시
    돌발사항이 발생할 수도 있으니, 테스트 서버에서 충분히 테스트 한후 적용하기 바랍니다.

3) 커널 업데이트시 적용이 되는지는 확인되지 않았습니다.

 

0. 요구사항 체크

  레드헷계열 OS (CentOS, Fedora) OS
  iptables 1.4.3 버전 이상 (CentOS 5.5 버전에서 rpm으로 설치된 버전은 1.3.5 일 것임)
  geoip
  xtables-addons


1. 프로그램 파일 준비

  /usr/local/src 로 이동하여 적당한 디렉토리를 만들고, 그 안에 아래 파일들을 다운로드 받습니다.
  *주) xtables-addons 최신 버전도 존재하나 tar.xz 파일 구조로 되어 있어, 아래 1.15 버전 사용을 추천합니다.

  # wget http://nchc.dl.sourceforge.net/sourceforge/xtables-addons/xtables-addons-1.15.tar.bz2
  # wget http://www.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip
  # wget http://jengelh.medozas.de/files/geoip/geoip_src.tar.bz2
  # wget ftp://ftp.netfilter.org/pub/iptables/iptables-1.4.3.2.tar.bz2


2. 압축해제 및 프로그램 설치


 1) iptables

  # tar xvfj iptables-1.4.3.2.tar.bz2
  # cd iptables-1.4.3.2
  # ./configure
  # make
  # make install

 2) xtables-addons

  # tar xvfj xtables-addons-1.15.tar.bz2
  # xtables-addons-1.15
  # ./configure --with-xtables=/usr/local
  # make 치면 다음과 같은 에러가 나올 것이다.
 
---------------------------------------------------------------------------
make  all-recursive
make[1]: Entering directory `/usr/local/src/20101224/xtables-addons-1.15'
Making all in extensions
make[2]: Entering directory `/usr/local/src/20101224/xtables-addons-1.15/extensions'
  GEN      modules
make[3]: Entering directory `/usr/src/kernels/2.6.18-194.26.1.el5-i686'
  CC [M]  /usr/local/src/20101224/xtables-addons-1.15/extensions/compat_xtables.o
In file included from /usr/local/src/20101224/xtables-addons-1.15/extensions/compat_xtables.c:20:
/usr/local/src/20101224/xtables-addons-1.15/extensions/compat_skbuff.h:29: error: redefinition of 'skb_reset_network_header'
include/linux/skbuff.h:1122: error: previous definition of 'skb_reset_network_header' was here
/usr/local/src/20101224/xtables-addons-1.15/extensions/compat_skbuff.h:33: error: redefinition of 'tcp_hdr'
include/linux/tcp.h:169: error: previous definition of 'tcp_hdr' was here
/usr/local/src/20101224/xtables-addons-1.15/extensions/compat_skbuff.h:37: error: redefinition of 'udp_hdr'
include/linux/udp.h:33: error: previous definition of 'udp_hdr' was here
In file included from /usr/local/src/20101224/xtables-addons-1.15/extensions/compat_xtables.c:21:
/usr/local/src/20101224/xtables-addons-1.15/extensions/compat_xtnu.h:9: error: redefinition of typedef 'bool'
include/linux/types.h:36: error: previous declaration of 'bool' was here
/usr/local/src/20101224/xtables-addons-1.15/extensions/compat_xtnu.h:10: error: redeclaration of enumerator 'false'
include/linux/stddef.h:16: error: previous definition of 'false' was here
/usr/local/src/20101224/xtables-addons-1.15/extensions/compat_xtnu.h:10: error: redeclaration of enumerator 'true'
include/linux/stddef.h:18: error: previous definition of 'true' was here
/usr/local/src/20101224/xtables-addons-1.15/extensions/compat_xtnu.h:131: error: redefinition of 'csum_unfold'
include/net/checksum.h:88: error: previous definition of 'csum_unfold' was here
/usr/local/src/20101224/xtables-addons-1.15/extensions/compat_xtables.c: In function 'xtnu_ip_route_me_harder':
/usr/local/src/20101224/xtables-addons-1.15/extensions/compat_xtables.c:376: error: too many arguments to function 'ip_route_me_harder'
make[4]: *** [/usr/local/src/20101224/xtables-addons-1.15/extensions/compat_xtables.o] 오류 1
make[3]: *** [_module_/usr/local/src/20101224/xtables-addons-1.15/extensions] 오류 2
make[3]: Leaving directory `/usr/src/kernels/2.6.18-194.26.1.el5-i686'
make[2]: *** [modules] 오류 2
make[2]: Leaving directory `/usr/local/src/20101224/xtables-addons-1.15/extensions'
make[1]: *** [all-recursive] 오류 1
make[1]: Leaving directory `/usr/local/src/20101224/xtables-addons-1.15'
make: *** [all] 오류 2
---------------------------------------------------------------------------

  다음과 같이 처리 후 진행하도록 한다.


  # vi extensions/compat_skbuff.h

28~39 라인 주석처리

     28 /* static inline void skb_reset_network_header(struct sk_buff *skb)
     29 {
     30     skb->nh.raw = skb->data;
     31 }
     32 static inline struct tcphdr *tcp_hdr(const struct sk_buff *skb)
     33 {
     34     return (void *)skb_transport_header(skb);
     35 }
     36 static inline struct udphdr *udp_hdr(const struct sk_buff *skb)
     37 {
     38     return (void *)skb_transport_header(skb);
     39 } */


  # vi extensions/compat_xtnu.h

9~10 라인 주석처리

      9 /* typedef _Bool bool;
     10 enum { false = 0, true = 1, };
     11 */


  # vi extensions/compat_xtables.c

372 라인 변경

 372 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17) 
     --> #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18) 로 수정


  # vi extensions/compat_xtnu.h

131~134라인 주석처리

    131 /*static inline __wsum csum_unfold(__sum16 n)
    132 {
    133     return (__force __wsum)n;
    134 }*/


  # make
  # make install


 3) geoip_src 설치

  # mkdir -p /var/geoip/LE
  # tar xvfj geoip_src.tar.bz2
  # unzip GeoIPCountryCSV.zip
  # cp geoip_csv_iv0.pl /var/geoip/LE
  # mv GeoIPCountryWhois.csv /var/geoip/LE
  # cd /var/geoip/LE

  아래 명령을 실행하면 에러메세지가 나온다.

---------------------------------------------------------------------------
  # ./geoip_csv_iv0.pl GeoIPCountryWhois.csv
Can't locate Text/CSV_XS.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at ./geoip_csv_iv0.pl line 12.
BEGIN failed--compilation aborted at ./geoip_csv_iv0.pl line 12.
---------------------------------------------------------------------------

  다음과 같이 처리한다음 진행한다.
 
  # perl -MCAPN -e shell

---------------------------------------------------------------------------
  모든 과정을 따로 설정해줄 필요는 없으므로, 엔터로 진행한다.
  참, 실행전 자체 방화벽이 올려져 있다면 잠시 내려놓도록한다.
---------------------------------------------------------------------------

  엔터로 진행중 계속 물어보는 부분이 나타날 것이다.  국가 선택부분인데.

  # 대륙/국가를 선택한다.

(1) Africa
(2) Asia
(3) Australasia
(4) Central America
(5) Europe
(6) North America
(7) Oceania
(8) South America
Select your continent (or several nearby continents) [] 2
Sorry! since you don't have any existing picks, you must make a
geographic selection.

(1) China
(2) Hong Kong
(3) India
(4) Indonesia
(5) Japan
(6) Republic of Korea
(7) Russia
(8) Singapore
(9) Taiwan
(10) Thailand
(11) Turkey
Select your country (or several nearby countries) [] 6
Sorry! since you don't have any existing picks, you must make a
geographic selection.


  # 적당하게 파일 받을 곳(URL)을 선택한다.

(1) ftp://cpan.mirror.cdnetworks.com/CPAN/
(2) ftp://cpan.sarang.net/CPAN/
(3) ftp://ftp.kaist.ac.kr/pub/CPAN
Select as many URLs as you like (by number),
put them on one line, separated by blanks, e.g. '1 4 5' [] 1 2 3

Enter another URL or RETURN to quit: []
New set of picks:
 
ftp://cpan.mirror.cdnetworks.com/CPAN/
  ftp://cpan.sarang.net/CPAN/
  ftp://ftp.kaist.ac.kr/pub/CPAN


commit: wrote /usr/lib/perl5/5.8.8/CPAN/Config.pm
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support available (try 'install Bundle::CPAN')

  cpan> 프롬프트가 떨어졌다면 다음과 같이 설치 명령을 내린다.

  capn> install Getopt::Long
  capn> install IO::Handle
  capn> install Text::CSV_XS

  설치를 마쳤다면 quit 명령으로 빠져 나오자.

  cpan> quit

  이제 에러가 났던 명령을 다시 실행하면 국가별로 KR.iv0 와 같은 파일이 생성된다.

  # ./geoip_csv_iv0.pl GeoIPCountryWhois.csv

-------------------------------------------------
[생략]
 2973 ranges for IT Italy
   87 ranges for JE Jersey
   76 ranges for JM Jamaica
   94 ranges for JO Jordan
 1745 ranges for JP Japan
  150 ranges for KE Kenya
   38 ranges for KG Kyrgyzstan
   75 ranges for KH Cambodia
    2 ranges for KI Kiribati
    5 ranges for KM Comoros
   63 ranges for KN Saint Kitts and Nevis
    5 ranges for KP Korea, Democratic People's Republic of
  632 ranges for KR Korea, Republic of
  166 ranges for KW Kuwait
   32 ranges for KY Cayman Islands
  175 ranges for KZ Kazakhstan
   14 ranges for LA Lao People's Democratic Republic
[생략]
-------------------------------------------------


3. 국가대역 막아보기

  이제 실제로 국가대역을 막아볼 차례다.
  중국에서 들어오는 IP 에 대해 서버의 80번 포트 서비스 요청을 거부하는 명령을 내려본다.

  # /usr/local/sbin/iptables -A INPUT -p tcp --dport 80 -m geoip --src-cc CN -j DROP

  정상적으로 프롬프트가 떨어졌다면 성공이다.

 주) /usr/local/sbin/iptables 로 실행하는 것은 소스로 설치한 iptables 1.4.3.2 버전이
 이 위치로 설치되기때문, rpm 으로 설치한 버전은 geoip 라이브러리를 인식하지 못하기 때문에
 에러 메세지가 나올 수 있다.

 ---------------------------------------------------------------------------------------
 iptables v1.3.5: Couldn't load match `geoip':/lib/iptables/libipt_geoip.so: cannot open shared object file: No such file or directory
 ---------------------------------------------------------------------------------------

  아래와 같이 추가되었다면 성공한 것이다.

  # iptables -L -n

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80 Source country: CN

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination


#### 서버에서 적용 ####

1. 먼저, ACCEPT 시킬 IP 에 대해 열거, 후에 해당 국가 IP 대역 DROP 정책 실시 (순서 바뀌면 ACCEPT 적용 안됨)
2. --src-cc 뒤에 국가 코드는 고정 두자리로 /var/geoip/LE 내에  **.iv0 파일의 국가 코드와 일치함.

  예) 한국 KR, 중국 CN, 일본 JP, 미국 US, 캐나다 CA 등


#### 중국 IP 대역중 특정 IP에 대해서만 접근 허용 ####
$IPTABLES -A INPUT -s 11.22.33.11 -j ACCEPT

#### 중국 IP 대역 모든 서비스 접근 금지 ####
$IPTABLES  -A INPUT -m geoip --src-cc CN -j DROP




* 이 글과 관련한 문의사항은 댓글 남겨주시면 답변드리겠습니다.

 

 

 

 

 

 

 

 


 

2010/12/27 15:36 2010/12/27 15:36








마음튼튼 이 작성.

당신의 의견을 작성해 주세요.

[로그인][오픈아이디란?]
오픈아이디로만 댓글을 남길 수 있습니다


제   목 : mod_security 웹방화벽 설치 서버에서 phpmyadmin 사용할 수 있게 우회 룰셋 적용하기

구   분 : 운영 tip
작성자 : 이선규 (neosky) (neosky(at)smileserv.com, admin(at)nple.com,
http://seroot.com)
작성일 : 2010년 10월 21일



mod_security 방화벽 설치 후 phpmyadmin 에서 특정 메뉴 (보기, 내보내기 등) 에 진입했을 때
406 에러를 내면서 접근 못하는 경우가 발생한다.


이럴 때 간단히 룰셋 수정만으로 접근 가능하게 할 수 있다.


313~314 라인쯤

        SecRule REQUEST_HEADERS:Host '(127.0.0.1|localhost|서버IP)' 'chain,skip:40,pass,nolog'
        SecRule REQUEST_URI '(/phpmyadmin|/myadmin|/pma)'


헤더값이 로컬접근 (127.0.0.1, localhost) 이거나 서버IP 이고, /phpmyadmin, /myadmin, /pma 가 URI에 들어 있는 것에 대해 skip, pass, nolog 를 하라는 뜻이다.

pass, nolog 는 skip 하여 40 라인에 가더라도 자체 룰셋에 이해 다시 block 을 당할 수 있으므로 써준 것이다
.


위와 같이 설정해주고 난뒤 Apache 를 재시작 해주면 406 에러 없이 접근됨을 확인할 수 있다.






2010/10/21 10:07 2010/10/21 10:07








마음튼튼 이 작성.

당신의 의견을 작성해 주세요.

[로그인][오픈아이디란?]
오픈아이디로만 댓글을 남길 수 있습니다


제목 : ssh 불법침입 탐지해서 block 시켜주는 스크립트
 
작성자 : 이선규 (neosky)  (neosky(at)smileserv.com, admin(at)nple.com,
http://seroot.com)
작성일 : 2010년 7월 8일



아래 내용은 외국 어느 고마운 분이 배포하고 있는 스크립트로,
ssh 불법침입을 탐지해서 block 시키는데 유용하게 쓰일 수 있어 소개하고자 합니다.


홈페이지 : http://bluedogsecurity.cyberinfo.se/sshblock2/Main.html


현재 SSH Block 2.2 버전이 공개되어 있고, 그 스크립트의 내용은 아래와 같습니다.
소스 그대로 긁어서 서버에 붙여넣어주고 실행권한만 주면 됨.

SunOS, Darwin, FreeBSD, OpenBSD, Linux OS에 적용가능하고,
Linux의 경우 /var/log/secure, /var/log/messages 에 남겨진 로그를 참조해서
/etc/hosts.deny 에 접근을 차단할 IP를 추가해줍니다.  (편리하죠? ㅎㅎ)

일정시간마다 모니터링해서 추가할 수 있도록 cron 설정해두면 좋습니다.




#!/bin/bash

################################################################################
#                                                                              #
#  Copyright (C) 2006 Jack-Benny Persson <jake@cyberinfo.se>                   #
#                                                                              #
#   This program is free software; you can redistribute it and/or modify       #
#   it under the terms of the GNU General Public License as published by       #
#   the Free Software Foundation; either version 2 of the License, or          #
#   (at your option) any later version.                                        #
#                                                                              #
#   This program is distributed in the hope that it will be useful,            #
#   but WITHOUT ANY WARRANTY; without even the implied warranty of             #
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              #
#   GNU General Public License for more details.                               #
#                                                                              #
#   You should have received a copy of the GNU General Public License          #
#   along with this program; if not, write to the Free Software                #
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  #
#                                                                              #
################################################################################

# SSH Block 2 - A script that blocks SSH probing hosts in /etc/hosts.deny
# This is version two of SSH Block, wich is a total re-write of the original
# code. This version should work on Linux, FreeBSD, Solaris and Mac OS X.
# Please read the README file for more information.

#If these users are trying to login via SSH, the host is instantly blocked.
#Be careful not to add users that normaly login via SSH here...
BLOCK_USERS=("root" "mysql" "nobody")

SLEEP_TIME=10
OS=`uname`

if [ "$OS" = "FreeBSD" ]; then
    DENYFILE="/etc/hosts.allow" #Both allow and deny in one file on FreeBSD
elif [ "$OS" != "FreeBSD" ]; then
    DENYFILE="/etc/hosts.deny" #The default way...
fi

if [ "$UID" -ne 0 ]; then
    echo "Must be run as root"
    exit 2
fi

#The default way...
print_ip()
{
    sort | uniq | sed -e 's/^/sshd : /' >> ${DENYFILE}
}

#The FreeBSD way...
print_ip_freebsd()
{
    sort | uniq | sed -e 's/^/sshd : /' | sed -e 's/$/ : deny/' >> \
    ${DENYFILE}
}

#Diffrent logfiles with diffrent syntax on diffrent systems...
SunOS_greplog()
{
    grep sshd /var/log/authlog | grep 'invalid user' \
    | awk '{print $15}' - | sort | uniq

    for i in ${BLOCK_USERS[*]}; do grep \
    "Failed keyboard-interactive for $i from" \
    /var/log/authlog; done | awk '{print $14}' - | sort | uniq
}

FreeBSD_greplog()
{
    (grep 'Illegal user' /var/log/auth.log || \
    grep 'Invalid user' /var/log/auth.log) \
    | awk '{print $10}' - | sort | uniq

    for i in ${BLOCK_USERS[*]}; do grep "Failed password for $i from" \
    /var/log/auth.log; done | awk '{print $11}' - | sort | uniq
}

OpenBSD_greplog()
{
    grep 'Invalid user' /var/log/authlog \
    | awk '{print $10}' - | sort | uniq

    for i in ${BLOCK_USERS[*]}; do grep "Failed password for $i from" \
    /var/log/authlog; done | awk '{print $11}' - | sort | uniq
}

Linux_greplog()
{
    (grep '[Ii]nvalid user' /var/log/messages || \
    grep '[Ii]llegal user' /var/log/secure || \
    grep '[Ii]llegal user' /var/log/messages || \
    grep '[Ii]nvalid user' /var/log/secure) \
    | egrep -o '[0-9]{1,3}(\.[0-9]{1,3}){3}' - | sort | uniq

    for i in ${BLOCK_USERS[*]}; do grep \
    "Authentication failure for $i from" \
    /var/log/messages; done | egrep -o '[0-9]{1,3}(\.[0-9]{1,3}){3}' \
    - | sort | uniq

    for i in ${BLOCK_USERS[*]}; do grep "Failed password for $i from" \
    /var/log/messages; done | egrep -o '[0-9]{1,3}(\.[0-9]{1,3}){3}' \
    - | sort | uniq

    for i in ${BLOCK_USERS[*]}; do grep \
    "Authentication failure for $i from" \
    /var/log/secure; done | egrep -o '[0-9]{1,3}(\.[0-9]{1,3}){3}' \
    - | sort | uniq
}

Darwin_greplog()
{
    grep sshd /var/log/system.log | grep 'illegal user' \
    | awk '{print $15}' - | sort | uniq

    for i in ${BLOCK_USERS[*]}; do grep \
    "Authentication failure for $i from" \
    /var/log/system.log; done |  - | awk '{print $13}' sort | uniq

}

SunOS_size()
{
    ls -l /var/log/authlog | awk '{print $5}'
}

Darwin_size()
{
    ls -l /var/log/system.log | awk '{print $5}'
}

FreeBSD_size()
{
    ls -l /var/log/auth.log | awk '{print $5}'
}

OpenBSD_size()
{
    ls -l /var/log/authlog | awk '{print $5}'
}

Linux_size()
{
    if [ -e /var/log/secure ] && [ -e /var/log/messages ]; then
        A=`ls -l /var/log/secure | awk '{print $5}'`
        B=`ls -l /var/log/messages | awk '{print $5}'`
        let C=A+B
        echo $C
    elif [ -e /var/log/secure ]; then
        ls -l /var/log/secure | awk '{print $5}'
    elif [ -e /var/log/messages ]; then
        ls -l /var/log/messages | awk '{print $5}'
    fi
}

touch ${DENYFILE}

#Check if we have run SSH Block before....
RUN_BEFORE=`grep -c "#BEGIN_SSHBLOCK" ${DENYFILE}`
if [ $RUN_BEFORE -gt 0 ]; then
    echo "/#BEGIN_SSHBLOCK/,/#END_SSHBLOCK/d|x" \
    | ex -s ${DENYFILE}
fi

OLD_SIZE=0

#Here we go!
(
while true
do
    case "$OS" in
        SunOS) SIZE=`SunOS_size` ;;
        Darwin) SIZE=`Darwin_size` ;;
        FreeBSD) SIZE=`FreeBSD_size` ;;
        OpenBSD) SIZE=`OpenBSD_size` ;;
        Linux) SIZE=`Linux_size` ;;
    esac
    if [ $OLD_SIZE -ne $SIZE ]; then

        BLOCK_EXIST=`grep -c "#BEGIN_SSHBLOCK" ${DENYFILE}`
        if [ $BLOCK_EXIST -gt 0 ]; then
            echo "/#BEGIN_SSHBLOCK/,/#END_SSHBLOCK/d|x" \
            | ex -s ${DENYFILE}
        fi

        echo "#BEGIN_SSHBLOCK" >> ${DENYFILE}
        case "$OS" in
            SunOS) SunOS_greplog | print_ip ;;
            FreeBSD) FreeBSD_greplog | print_ip_freebsd ;;
            OpenBSD) OpenBSD_greplog | print_ip ;;
            Linux) Linux_greplog | print_ip ;;
            Darwin) Darwin_greplog | print_ip ;;
        esac
        echo "#END_SSHBLOCK" >> ${DENYFILE}
        case "$OS" in
            SunOS) OLD_SIZE=`SunOS_size` ;;
            Darwin) OLD_SIZE=`Darwin_size` ;;
            FreeBSD) OLD_SIZE=`FreeBSD_size` ;;
            OpenBSD) OLD_SIZE=`OpenBSD_size` ;;
            Linux) OLD_SIZE=`Linux_size` ;;
        esac
        sleep ${SLEEP_TIME}
    else
        sleep ${SLEEP_TIME}
    fi
done
) 2> /dev/null &




사용자 삽입 이미지
▲ SSH Block 2 배포 사이트



2010/07/08 15:52 2010/07/08 15:52








마음튼튼 이 작성.

당신의 의견을 작성해 주세요.

[로그인][오픈아이디란?]
오픈아이디로만 댓글을 남길 수 있습니다


제  목 : Nikto의 기능 및 특징

작성자 : 이선규 (neosky)  (neosky(at)smileserv.com, admin(at)nple.com,
http://seroot.com)
작성일 : 2010년 7월 7일



공식사이트 : http://www.cirt.net/nikto2

nikto는 웹 서버 설치시 기본적으로 설치되는 파일과 웹 서버의 종류와 버전 등을 스캔하며,
특히 방대한 DB를 이용해 취약한 CGI 파일을 스캔하는 기능이 매우 뛰어나다.


1. nikto는 취약하다고 알려진 3100여개의 방대한 CGI 파일에 대한 정보를 갖고 있으며 625개가
넘는 서버에 대한 버전 정보를 갖고 있다. nikto는 서버에서 보안적으로 잘못 설정된 부분
(misconfigurations)이나 웹 서버 설치시 기본으로 설치되는 파일이나 스크립트의 존재 유무,
안전하지 못한 파일이나 스크립트의 유무, 오래되어 취약성을 가지고 있는 프로그램의 유무 등을 검색한다.

2. 취약성 DB는 수시로 업데이트가 되며 원격지에서도 쉽게 업데이트가 가능하다.

3. 취약성 점검 결과는 html이나 txt, csv 등으로 저장할 수 있다.


옵션

-Cgidirs : 스캔을 진행할 cgi 디렉토리를 지정할 수 있다. 통상적으로 all로 지정한다.
# ./nikto.pl --Cgidirs all -h www.1234.net

-generic : 스캔시 'Server:' 문자열에 보이는 정보와 관계없이 스캔을 진행하도록 한다.

-findonly : HTTP(S)만 스캔하기 위한 옵션이다.
#./nikto.pl -findonly -h www.1234.net

-Format : 스캔 결과를 파일로 저장할 때 어떤 형식으로 남길지 지정한다.
#./nikto.pl -Format html -output .html -h www.1234.net

-id : 만약 해당 웹서버가 HTTP Authentication으로 보호되고 있을때 ID/PW 인증이 필요한다.
      이때 userid:password 형식으로 넣어준다.

-update : 업데이트가 필요할 경우 사용한다.




사용자 삽입 이미지

2010/07/07 16:27 2010/07/07 16:27








마음튼튼 이 작성.

당신의 의견을 작성해 주세요.

[로그인][오픈아이디란?]
오픈아이디로만 댓글을 남길 수 있습니다



1. 초당 15번의 web 요청이 있는 경우 차단합니다.

iptables -A INPUT -p tcp --dport 80 -m recent --update --seconds 1 --hitcount 15 --name HTTP -j DROP


2. 분당 10번이상의 ssh 새로운 접근이 있는 경우 차단합니다.

iptables -I INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 11 -j DROP


3. syn_food 정책을 만들고 초당 10번의 요청이 있는 경우 차단합니다.

iptables -N syn_flood
iptables -A INPUT -p tcp --syn -j syn_flood
iptables -A syn_flood -m limit --limit 1/s --limit-burst 10 -j RETURN
iptables -A syn_flood -j DROP


http://www.netfilter.org/documentation/HOWTO/netfilter-extensions-HOWTO-3.html#ss3.16




출처 : http://www.jinmoda.com/bbs/board.php?bo_table=board_01&wr_id=98&page=

참조 url : http://blog.pages.kr/624
2010/06/09 18:19 2010/06/09 18:19








마음튼튼 이 작성.

당신의 의견을 작성해 주세요.

[로그인][오픈아이디란?]
오픈아이디로만 댓글을 남길 수 있습니다


그누보드에서 룰셋에 의해 게시판 수정이 차단될때 처리방법

작성일자 : 2010년 3월 5일
작성자 : neosky (nple.com / seroot.com / neosky@smileserv.com)


 1) 테스트 환경

  OS : CentOS
  Apache : 1.3.x
  mod_security : 1.9


 2) 룰셋에 의해 차단된 상태
 
그누보드 관리자페이지 -> 게시판관리 -> 각 게시판 수정 양식에서
다음과 같이 상단(하단)파일 경로에 상위 경로로 설정한 경우

사용자 삽입 이미지
설정 완료후 [확인] 버튼를 누르면 아래와 같이 403 에러 페이지를 만날 수 있습니다.

사용자 삽입 이미지
mod_security 룰셋에 의해 \.\ 이 들어간 구문은 공격으로 간주 차단하고 있기 때문입니다.


 3) 룰셋을 우회하는 정책 설정

   mod_security.conf 설정파일에 아래와 같이 차단 룰셋 전에 적어줍니다.

# (2010-03-05) 그누보드 관리자페이지에서 게시판 정보 수정시
# 상단 파일 경료, 하단 파일 경로에 '..' 상위경로 탐색 문구 삽입시 룰에 의해 차단되었던 것을
# 차단하지 않도록 설정하였음
SecFilterSelective ARGS|REQUEST_URI 'bo_include_head=(http:|https:|\.\.)' allow
SecFilterSelective ARGS|REQUEST_URI 'bo_include_tail=(http:|https:|\.\.)' allow

   아파치를 재시작하고 다시 확인해보면 정상적으로 처리되는 것을 확인할 수 있습니다.

   정상처리 되지만 security 로그에는 그대로 남습니다.


==51912f4a==============================
Request: test.co.kr 220.x.x.x - - [05/Mar/2010:13:30:53 +0900] 'POST /adm/board_form_update.php HTTP/1.1' 200 141 'http://nple.com/adm/board_form.php?w=u&bo_table=FREEBOARD&&sst=&sod=&sfl=&stx=&page=0' 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)' - '-'
----------------------------------------
POST /adm/board_form_update.php HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, */*
Accept-Encoding: gzip, deflate
Accept-Language: ko
Cache-Control: no-cache
Connection: Keep-Alive
Content-Length: 7638
Content-Type: multipart/form-data; boundary=---------------------------7da2be31105c8
Cookie: f33d2ed86bd82d4c22123c9da444d8ab=MTI2Nzc1MjUxNQ%3D%3D; 2a0d2363701f23f8a75028924a3af643=MjIwLjkwLjIxNS40; PHPSESSID=5adb9538e91a2017efd6aefeeac704f6; 96b28b766b7e0699aa91c9ff3d890663=aHR0cDovL3Rlc3QuZ29nb2F1ZGlvLmNvLmtyLw%3D%3D
Host: nple.com
Referer: http://nple.com/adm/board_form.php?w=u&bo_table=FREEBOARD&&sst=&sod=&sfl=&stx=&page=0
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
mod_security-message: Access allowed. Pattern match 'bo_include_head=(http:|https:|\\.\\.)' at POST_PAYLOAD [severity 'EMERGENCY']  <== 허용한 룰임을 밝히고 있음.



* SEROOT.COM 블로그는 맑은고딕체가 설치된 PC에서 잘 보입니다.  :)





2010/03/05 13:49 2010/03/05 13:49








마음튼튼 이 작성.

당신의 의견을 작성해 주세요.

[로그인][오픈아이디란?]
오픈아이디로만 댓글을 남길 수 있습니다