포트 스캔을 체크툴인 Portsentry 1.1를 설정하는 방법과 실제 테스트후 블러킹 하는 방법
portsentry 란?
portsentry는 실시간으로 이런 portscan을 탐지하고 대응하기 위해 만들어진 프로그램이며, Abacus Project의 일환으로 PSIONIC사에서 개발 배포하는 도구중 하나이다. portsentry는 정상적인 스캔과 비밀스캔 모두를 탐지한다. portsentry는 portscan을 탐지하기 위해 많은 옵션들을 가지고 있는데 아래의 방법들로 portscan에 반응한다. (자세한 내용은 README.install을 참고하세요.)
portsentry 다운받기
the Project Sentry Tools Summary Page 에서 1.2 버전을 다운받을 수 있다.
Psionic Technologies 에서 개발되고 오픈소스로 공개된 프로그램인데
Psionic Technologies 가 cisco에 acquire되면서 더이상의 서비스를 제공하지 않고있다.
현재로서는 여기에서 마지막 업데이트 버전을 제공받을 수 있다.
portsentry 설치하기
[root@chtla kan]# tar xvfz portsentry-1.2.tar.gz
[root@chtla portsentry-1.2]# make linux
SYSTYPE=linux
Making
cc -O -Wall -DLINUX -DSUPPORT_STEALTH -o ./portsentry ./portsentry.c
./portsentry_io.c ./portsentry_util.c
[root@chtla portsentry-1.2]# make install
디폴트 디렉토리는 /usr/local/psionic/portsentry/portsentry 이다..
[root@chtla portsentry-1.2]# cd /usr/local/psionic/portsentry/
[root@chtla portsentry]# vi portsentry.conf
수정할 내용은 portsentry가 점검할 대상 포트(port)에 대한 것으로서 필요한 점검포트들을 모두설정하거나 점검하지 않을 포트들을 빼버리면 된다. 크게 대상 포트는 TCP 포트와 UDP포트로 나위어져 있으며, 특히 Stealth 스캔에 대한 옵션에 대한 설정도 할수 있음을 유심히 보기 바란다.
[root@chtla portsentry]# vi portsentry.ignore
12.34.56.78 <== portsentry 에서 block 되지 않을 아이피를 적어준다..(즉 자신의 서버 아이피등..안전하다고 생각되는 아이피)
[root@chtla portsentry]# vi /etc/rc.d/rc.local <== 부팅시 실행을 위해 추가..
-tcp - Basic port-bound TCP mode (기본 포트 제한 TCP 모드)
PortSentry는 설정파일들을 확인하고 나서, 백그라운드에 있는 모든 TCP포트들을 묶을 것이다. 만약 여러분이 init 상태를 점검하길 원한다면, 단지 여러분은 메시지가 저장되어지는 local syslog 파일을 살펴보면 된다.
-udp - Basic port-bound UDP mode (기본 포트 제한 UDP 모드)
PortSentry는 설정파일들을 확인하고 나서, 백그라운드에 있는 모든 UDP포트들을 묶을 것이다. 만약 여러분이 init 상태를 점검하길 원한다면, 단지 여러분은 메시지가 저장되어지는 local syslog 파일을 살펴보면 된다. UDP/스텔스 스캔 경고가 적용된다. (README.stealth파일을 읽어보라.)
-stcp - Stealth TCP scan detection mode (스텔스 TCP 스캔 탐지 모드)
PortSentry는 호스트로 들어오는 모든 패킷들을 감시하기 위해서 raw 소켓을 사용할 것이다. 만약 호스트로 들어오는 패킷이 감시되고 있는 포트로 향한다면, PortSentry는 호스트를 방어하기 위해 작동할 것이다. 이 방법은 connect() 스캔과 SYN/half-open 스캔과 FIN 스캔을 탐지할 것이다.
UDP/스텔스 스캔 경고가 적용된다. (README.stealth파일을 읽어보라.)
-sudp - "Stealth" UDP scan detection mode (스텔스 UDP 스캔 탐지 모드)
이것은 위의 TCP stealth mode와 작동방법은 동일하다. UDP 포트들을 나열하면, 그 포트들은 감시된다. 이것은 어떠한 소켓도 묶지 않으며, 실제 스텔스 스캔 탐지 모드가 아닌 중에도 거의 동일하게 동작한다.( 모든 UDP 패킷에 반응한다.)
UDP/스텔스 스캔 경고가 적용된다. (README.stealth파일을 읽어보라.)
-atcp - Advanced TCP stealth scan detection mode (advanced TCP 스텔스 스캔 탐지 모드)
PortSentry는 ADVANCED_PORTS_TCP 옵션에 지정된 최상의 포트번호이하의 모든 열려진 포트에 대한 목록을 만들면서 시작하고, 이러한 포트들을 기초로 제외(exclusion)목록을 만들 것이다. 제외되지 않은( 예를 들어, [SMTP, HTTP, 등의] 열려진[listening] network daemon이 아닌, ) 영역내의 임의의 포트에 연결된 호스트들은 접속이 금지된다. 이것은 여러분이 반드시 알고 있어야 할 몇몇 아주 강력한 함축적 의미들을 가지고 있다.
-audp - Advanced UDP stealth scan detection mode (advanced UDP 스탤스 스캔 탐지 모드)
UDP 프로토콜을 사용한다는 점을 제외하고는 위와 같다. Advanced UDP stealth scan detection은 지원되지 않는 트래픽을 즉시 알 수 있기 때문에 강력하지만 부정확한 경보의 가능성이 높다.
[root@chtla portsentry]# ps -ax|grep portsentry
1084 ? S 0:00 /usr/local/psionic/portsentry/portsentry -tcp
1086 ? S 0:00 /usr/local/psionic/portsentry/portsentry -udp
1092 ? S 0:01 /usr/local/psionic/portsentry/portsentry -atcp
1094 ? S 0:00 /usr/local/psionic/portsentry/portsentry -audp
이처럼 실행을 되어 있는 것은 확인할수 있다..
그런데-stcp와 -sudp가 실행이 되지 않을것이다.. 서버 두대에서 같은 방법으로 돌려 보았는데, 실행이 되지 않고 있다.. 별문제라 문제되지 않아 아직까지 크게 신경을 쓰고 있지는 않아, (혹 아시는 분은 제게 좀 알려주세요..^^) 그냥 방치에 두고 있었다..
글을 쓰고면서 다시 기억이 났으니 우선을 그냥 넘어가기로 한다.. 큰 문제는 아니다.
침입 ip blocking 시키기..
우선 portsentry 는 디폴트로 tcp-wrapper 와 연동이 되어 정상적인 포트가 아닌 다른 포트로 스캔을 할지 자동으로 /etc/hosts.deny 에 기록을 하게 된다.
그냥 사용을 해도 좋으나 iptables 가 설치 되어 있다면 이것과 연동을 하는 것이 더 낮을것이다.
iptables와 연동을 하려면
[root@chtla portsentry]# vi portsentry.conf
#KILL_HOSTS_DENY="ALL: $TARGET$" <=== 이것을 주석처리 하구
# iptables support for Linux <=== 끝부분에 있을것임
KILL_ROUTE="/sbin/iptables -A INPUT -s $TARGET$ -j DROP" <=== 이것을 주석 처리를 풀어준다.
iptables 의 기본 옵션으로 -I 로 되어 있을것이다.. 그대로 사용해도 사용이 없으나, iptables를 사용할 사용이라면 -A 를 쓰도록 하자.
(-I 는 최상위로 올라가기에, 즉 최상우선적으로 적용을 시키는 옵션으로 개인적으로 iptables에 허가 ip를 등록시켜둔 상태라서 저는 이렇게 사용합니다..
-A 를 쓰면 -I 으로 적용한것보다 밑에 있게 되어 보기가 편하거든요..)
침입 테스트하기
다른 컴퓨터나 해당 서버에 텔넷(보통 기본적으로 막혀 있음)이나 다른 포트에 접속을 해 보자..
(다른 컴터에서)
# telnet 12.34.56.78 23
접속하면 별일없이 프럼프트 상에서 한참을 기다리고 있을것이다.(linux상에서).. 종료후 해당 서버의 /etc/hosts.deny (iptables 설정을 안했을 경우) 를 열어 보거나, iptables로 설정한 경우
# iptables -L
target prot opt source destination
DROP all -- 61.xx.xx.196 anywhere <== 허가 거부된 ip
const KEY_QUERY_VALUE = &H0001
const KEY_SET_VALUE = &H0002
const KEY_CREATE_SUB_KEY = &H0004
const DELETE = &H00010000
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet"
oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_QUERY_VALUE, _
bHasAccessRight
If bHasAccessRight = True Then
StdOut.WriteLine "Have Query Value Access Rights on Key"
Else
StdOut.WriteLine "Do Not Have Query Value Access Rights on Key"
End If
oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_SET_VALUE, _
bHasAccessRight
If bHasAccessRight = True Then
StdOut.WriteLine "Have Set Value Access Rights on Key"
Else
StdOut.WriteLine "Do Not Have Set Value Access Rights on Key"
End If
oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_CREATE_SUB_KEY, _
bHasAccessRight
If bHasAccessRight = True Then
StdOut.WriteLine "Have Create SubKey Access Rights on Key"
Else
StdOut.WriteLine "Do Not Have Create SubKey Access Rights on Key"
End If
oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, DELETE, bHasAccessRight
If bHasAccessRight = True Then
StdOut.WriteLine "Have Delete Access Rights on Key"
Else
StdOut.WriteLine "Do Not Have Delete Access Rights on Key"
End If
Uses WMI to check access rights for the logged on user to HKLM\SYSTEM\CurrentControlSet.
const KEY_QUERY_VALUE = &H0001
const KEY_SET_VALUE = &H0002
const KEY_CREATE_SUB_KEY = &H0004
const DELETE = &H00010000
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet"
oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_QUERY_VALUE, _
bHasAccessRight
If bHasAccessRight = True Then
StdOut.WriteLine "Have Query Value Access Rights on Key"
Else
StdOut.WriteLine "Do Not Have Query Value Access Rights on Key"
End If
oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_SET_VALUE, _
bHasAccessRight
If bHasAccessRight = True Then
StdOut.WriteLine "Have Set Value Access Rights on Key"
Else
StdOut.WriteLine "Do Not Have Set Value Access Rights on Key"
End If
oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_CREATE_SUB_KEY, _
bHasAccessRight
If bHasAccessRight = True Then
StdOut.WriteLine "Have Create SubKey Access Rights on Key"
Else
StdOut.WriteLine "Do Not Have Create SubKey Access Rights on Key"
End If
oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, DELETE, bHasAccessRight
If bHasAccessRight = True Then
StdOut.WriteLine "Have Delete Access Rights on Key"
Else
StdOut.WriteLine "Do Not Have Delete Access Rights on Key"
End If
MicroSoft사의 WindowsXP에서는 Windows 원격 데스크탑 접속을 할 수 있습니다. 서버로 사용하는 컴퓨터에 원격 접속 설정을 하면 학교 연구실에 있는 컴퓨터를 계속 켜고 퇴근한 후에 집에서 노트북으로 학교 연구실 컴퓨터에 접속해서 원격으로 작업을 할 수 있는 장점이 있습니다.
Window에서는 원격으로 Windows를 연결하여 원격 작업을 할 수 있습니다.
그렇다만 Linux 컴퓨터는 Xwindow가 설치되어 있는데 Windows에서 Linux컴퓨터의 Xwindow를 원격으로 실행 시킬까요?
여러가지 방법 중에서 VNC를 사용하는 방법이 있지만, VNC demon을 실행시키지 않으면 Windows에서 Linux컴퓨터의 Xwindow 실행시킬수 없습니다.
여기서는 Windows에서 Xming을 설치한 다음 Xming을 이용하여 쉽게 Linux컴퓨터의 Xwindow를 원격으로 실행하는 방법을 알려드리겠습니다.
※ Xming이란? Wikipedia : Xming 배포사이트 : http://www.straightrunning.com/XmingNotes/
Xming는 Windows용 X Server입니다.
Microsoft사의 Windows에서 Xwindow용 프로그램을 출력할 수 있도록 해주는 화면 출력 서버입니다.
Microsoft사의 Windows에서 Linux 컴퓨터안의 X Window 프로그램을 화면에 출력할 수 있는 서버인 Xming을 설치하면 리눅스 프로그램도 Microsoft사의 Windows에서 실행 할 수 있습니다.
Windows에서 리눅스 프로그램을 실행하는 것처럼 보이지만, 실제 실행은 리눅스 컴퓨터에서 하고, 다만 X Server는 프로그램에서 전송하는 화면을 출력하고, 사용자의 키보드나 마우스와 같은 입력을 프로그램 쪽으로 전송해 주는 역할을 합니다.
2. Display settings에서 One window without titlebar를 선택합니다.
3. 데스크탑에서 Xwindow를 실행시킬려면 Start a program을 선택합니다.
4. 여기서 Xwindow환경을 실행할때에 Gnome를 실행하려면 Start Program에서 gnome-session을 넣고 KDE를 실행하려면 startkde를 넣으시면 됩니다.
원격접속할때에는 Run Remote에서 Using Putty를 선택하여 IP와 ID, Password를 넣으시면 됩니다.
5. Clipboard를 원격접속하는 곳에서 쓸려면 선택합니다.
6. 이제 셋팅이 끝났습니다.
결과 화면
ps1. Xmanager같은 비싼 프로그램이 한글지원도 편하게 되어서 사용하기에 좋긴 하지만, 학생이고 오픈소스로 공개된 Xming을 오픈소스 프로그램인 iPutty에 연결해 씁니다. 있을 것은 다 있는 오픈소스 프로그램들이라서 굳이 불법으로 쓸 필요는 없으니깐요.
ps2. Xming때문에 학교 안나오고 집에서 작업 한 후에 교수님에게 작업한 결과물을 보여주면서 학교는 나왔습니다 하면서 땡땡이 칠 수 있는 장점도 있습니다!
만일 oracle 계정의 shell을 ksh 로 하지 않고, bash로 했다면, .profile 파일을 수정하지 않고, .bash_profile 파일을 수정하도록 한다.
여유 디스크 공간 확인 및 디렉토리 생성
오라클 10G R2를 설치하기 위해서는 최소한 1GB 이상의 디스크 공간이 필요하다.
또한, 오라클을 설치하기 전에 필요한 디렉토리는 미리 생성해두는 것이 좋다.
일반적으로 오라클 S/W와 Datafile(실제 데이터가 저장되는 공간)의 물리적인 위치를 별도로 지정하는 것이 좋다.
oracle 계정의 home 디렉토리와 오라클 S/W가 설치되는 곳은 달라도 상관 없다.
우선, 오라클 S/W는 /u/app/oracle/product/10.2.0/db_1 에 설치하도록 하자. (Datafile 및 기타 파일의 위치는 오라클 설치 후 DB 생성시 고려하면 되겠다.)
su - root mkdir -p /u/app/oracle/product/10.2.0/db_1 chown -R oracle:dba /u/app/oracle
오라클 10G R2 설치
oracle 계정으로 switch user (su) 한 다음, 다운받은 오라클 설치 파일을 압축해제한 디렉토리로 이동하여 runInstaller를 실행한다.
# xhost + # su - oracle $ cd database $ ./runInstaller
xhost + 명령을 실행한 이유는 간혹 oracle 계정에서 Display 세팅때문에 OUI를 실행하지 못하는 경우가 있는데, Display의 제어권을 root에서 oracle로 넘겨주기 위함이다. xhost + 를 실행하지 않아도 잘 되는 경우에는 그냥 oracle계정으로 su 하여 runInstaller를 실행하면 된다.
runInstaller를 실행시키면 몇 초 후 OUI (Oracle Universal Installer)가 실행된다.
- 설치방식선택 : 고급설치 (기본설치를 선택하면 쉽게 할 수 있지만, 고급설치를 통해 좀 더 배워보자.) "다음" 클릭
- 인벤토리 디렉토리 및 인증서 지정 : 인벤토리 디렉토리에 대한 전체 경로 입력 (제품에 대한 설치정보를 저장하는 곳이며 약 150KB정도가 사용된다.) -> /u/app/oracle/oraInventory : 운영체제 그룹 이름 지정 (oracle을 설치하는 Linux 계정이 속한 그룹명을 입력하면 된다.) -> dba "다음" 클릭
- 설치유형 선택 : 사용자정의 (보통 Enterprise Edition을 선택하면 되지만, 여기서는 필요한 부분만 최소용량으로 설치하기 위해 사용자 정의를 선택하였다.) "다음" 클릭
- 홈 세부 정보 지정 : 이름 (oraInventory 내에 저장하기 위한 이름으로 특별한 의미는 없으며 추후 설치된 오라클을 제거할 때의 이름으로 사용되므로 적절히 입력하거나 입력되어 있는 내용을 그대로 사용하면 된다.) -> OraDB10g_home1 : 경로 (.profile에서 ORACLE_HOME 으로 지정한 디렉토리가 입력되어 있을 것이다. 확인하고 틀렸으면 수정하자.) -> /u/app/oracle/product/10.2.0/db_1 "다음" 클릭
- 사용가능한 제품 구성 요소 (설치 유형에서 "사용자정의"를 선택하였기때문에 제품 구성요소를 선택하여 설치를 할 수 있다. Eterprise Edition을 선택했다면 이 화면은 나타나지 않는다.) : 선택되어 있는대로 진행해도 상관 없지만, 필자의 경우 개발 목적으로 설치하는 것이 아니므로 -> Oracle Programmer 10.2.0.1.0 체크 해제 -> Oracle XML Developer Kit 10.2.0.1.0 체크 해제 (나머지 항목은 그대로) "다음" 클릭
- 제품별 필요 조건 검사 : 사전에 커널변수와 필요한 패키지들을 미리 세팅해두었다면 큰 무리 없이 통과가 가능하다. 만일, 상태 항목에 "경고" 라는 문구가 있는 항목이 있으면 아래 내용을 읽어보고 조치한 후 "재시도" 버튼을 클릭하면 되고, 귀찮으면(ㅡ.ㅡ) "경고" 바로 좌측에 있는 체크박스를 모두 클릭한 후 "다음" 클릭.
- 권한 부여된 운영체제 그룹 : 데이터베이스 관리자(OSDBA) 그룹 -> dba : 데이터베이스 운영자(OSOPER) 그룹 -> dba (국내의 경우 관리자와 운영자가 동일한 경우가 대부분이지만, 외국의 경우 실제로 관리자와 운영자가 분리되어 있으므로 이러한 선택사항이 있는것으로 보인다. 모두 dba로 입력하자.) "다음" 클릭.
- 데이터베이스 생성 : 데이터베이스 소프트웨어만 설치 (여기서 데이터베이스를 생성해도 되지만, 이것저것 준비할 것도 많고, 시간이 오래걸리므로 소프트웨어만 설치하고 데이터베이스는 나중에 생성하도록 하자.) "다음" 클릭.
- 요약 : 지금까지 세팅한 설치 옵션들을 한 눈에 요약하여 보여준다. 만일 틀린부분이 있다면 뒤로 가서 다시 세팅하도록 하자. "설치" 클릭.
- 설치 (설치는 상당한 시간이 소요된다. 시스템의 사양에 따라서 많은 차이가 있지만, 대략 1시간 정도 생각하면 되겠다. 설치하는데 심심하다면 설치화면 하단에 있는 로그파일 위치에 가서 생성되는 로그를 확인해보는 것도 좋겠다.)
- 구성 스크립트 실행 (새로운 터미널 창을 열어 root로 switch user(su - root)한 후 스크립트를 실행한다.) mkdir /opt (Haansoft Linux에는 /opt 디렉토리가 없으므로 생성하도록 한다. root.sh 실행시 필요하다.) /u/app/oracle/oraInventory/orainstRoot.sh /u/app/oracle/product/10.2.0/db_1/root.sh (현재 오라클을 설치하는 oracle 계정은 타 디렉토리에 대한 생성 권한이 없기때문에 root로 위 스크립트를 실행하여 필요한 환경을 세팅하는 것이다.) "종료" 클릭.
윈도우즈는 통일된 단일한 방식을 통해서, 스스로 설치되는 프로그램을 만들 수 있다. 보통 Install Shield의 형태로 관리되며, 거의 모든 윈도우 버젼에 동일하게 적용시킬 수 있다.
그러나 리눅스에 배포할 경우 많은 문제가 따른다. 일단리눅스만으로 목표를 한정한다고 해도, RedHat, Debian, Zentoo, ubuntu 등 배포판 고유의 전혀다른 배포방식을 제공하며, 일반적으로 호환되지 않는다. 리눅스에서 개발되고 다른유닉스로 포팅된 프로그램을 배포하는 데에도 역시 동일한 문제가 발생한다.
단순하게tar로 묶어서 배포하면 된다. 이건 논외로 하기로 한다. 여기에서는 Install Shield와 같이 유저와 상호대화 가능하면서 간단하게 배포가능한 방법에 대해서 논할 것이다.
shell script와 tail로 구현하는 간단한 Install Script 만들기
그렇다면 리눅스 뿐만이 아닌 다른 유닉스에서도 사용가능한 Install Script 프로그램을 만드는 방법에 대해서 알아보겠다. 일단 만들 Install script는 모든 유닉스에서 작동이 될 수 있다는 것을 보장해야 하므로, 유닉스에 기본적으로 설치되는 명령만을 가지고 작성을 해야 한다.
이 문서를 제대로 이해하고 활용하기 위해서는 Bash 스크립트 프로그래밍에 대한 지식을 가지고 있어야 한다.초보자를 위한 Bash 스크립트 프로그래밍문서를 참고하기 바란다.
여기에서는 모든 유닉스에 기본적으로 제공된다고 생각되는 sh,tail, tar를 통해서 Install Script를 만드는 방법에 대해서 알아보도록 하겠다.
당신이 mypackage-1.2.3.tgz이란 프로그램을 배포한다고 가정해보자. 당신은 실행하면, 여러가지 환경변수를 검사하고 유저의 입력을 받아서 자동으로 해당 디렉토리에 압축이 풀리는 스크립트를 만들기를 원할 것이다. 아래와 같은 방법으로 간단하게 만들 수 있다.
#!/bin/sh
echo ""
echo "MyPackage v99.99 - extracting archive... please wait"
echo ""
# take the archive portion of this file and pipe it to tar
# the NUMERIC parameter in this command should be one more
# than the number of lines in this header file
tail +12 $0 | tar xz
exit 0
tail +12 는 12번째 줄 부터 출력을 하라는 명령이다. 즉 mypackage-1.2.3.sh의 12번째줄 부터 출력을 해서 tar로 풀어라 이런 명령이 된다. 12번째 줄은 cat으로 가져다붙인 mypackage-1.2.3.tgz이 있으니, 최종적으로 현재 디렉토리에 mypackage-1.2.3.tgz의 압축을 풀게 된다.
Advanced Install Script
위의 Install Script는 별 문제 없이 돌아가지만, 본격적으로 사용하기에는 몇 가지 문제가 있다.
tail로 출력한 라인수를 수동으로 계산해주어야 한다. 만약 sfx-header이 사용자에 의해서 수정된다거나 라인수를 잘못 입력했다하면, 제대로 작동하지 않게 된다.
현재 디렉토리에 압축이 풀리는데, 사용자가 원하는 디렉토리에 풀리도록 해야 할것이다. 사용자의 입력을 받아들일 수 있어야 할 것이다.
만약의 경우를 대비해서, 임시디렉토리에서 압축을 푸는 등의 관련작업을 한 다음, 성공했을 경우 지정된 디렉토리로 옮기도록 한다.
다음은 위의 문제들을 해결하도록 수정된 스크립트다.
#!/bin/sh
DEFDIR="/usr/local"
TEMPDIR="/tmp/myapp"
WORKDIR=$PWD
clear
echo "====================================================="
echo "ESM Package V1.0 - extracting archive ... please wait"
echo "====================================================="
if [ $UID != 0 ];
then
echo "Your not Root !!"
exit 1
fi
echo -n "Install Directory ($DEFDIR): "
read UDIR
if [ "$UDIR" = "" ];
then
UDIR=$DEFDIR
else
UDIR="$UDIR"
fi
echo "Install Dir is $UDIR"
test -d $UDIR
if [ $? -eq 1 ];
then
mkdir $UDIR
if [ $? -ne 0 ];
then
echo "Directory Create failure : $UDIR"
fi
fi
SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' $0`
mkdir $TEMPDIR
cp $0 $TEMPDIR
cd $TEMPDIR
tail +$SKIP $0 | tar x
mv * $UDIR
cd $WORKDIR
if [ $? -eq 0 ];
then
echo "======================================================="
echo " Program Install Success"
echo "======================================================="
else
echo "======================================================="
echo " Program Install Failure"
echo "======================================================="
fi
exit 0
__ARCHIVE_FOLLOWS__
read 명령을 이용해서 프로그램이 설치될 경로를 사용자가 직접 입력할 수 있도록 했다. 만약 아무것도 입력하지 않는다면, 기본경로인DEFDIR에 설치되도록 했다. 그다음 test 명령을 이용해서 사용자가 입력한 경로가 존재하는지를 확인하고, 존재하지 않는다면mkdir(1)로 해당 디렉토리를 설치하도록 한다. 자동으로 압축을 풀어야할 줄을 계산하기 위해서awk(1) 명령을 이용하고 있다. awk를 이용해서ARCHIVE_FOLLOWS를 찾게하고, 이 문자열의 줄수를 얻어와서 tail로 넘기도록 했다. 마지막으로 임시디렉토리를 만든다음 설치파일을 복사하고, 압축을 푼다음, 풀린 파일을 설치 디렉토리로 이동하도록 한다. 모든 작업을 마친다음 원래 작업 경로로 이동하는 걸로 설치 스크립트가 끝난다.
Installing Ubuntu 8.04 Hardy Heron in Virtual PC 2007
A picture is worth a thousand words...
"An unrecoverable processor error has been encountered. The virtual machine will reset now."
It looks like Ubuntu isn't the only one with this problem... Fedora 9 releases tomorrow and according to this post, it has the same error in Virtual PC. Whatever happened to Linus' Law? (given enough eyeballs, all bugs are shallow). I guess enough eyeballs writing kernel code are not doing so on Virtual PC. ;)
Using guidance from a number of participants on this blog I’ve successfully managed to install Ubuntu 8.04 on two separate PC’s running VPC 2007 and I have it running at 1152 X 768 @ 55Hz with working sound.
The notes below are nothing original, they are just summarized from previous entries and maybe clarified.
To get the CD to load, Press F4 to select an alternate starting mode. When it pops up, change to Safe graphics mode and press Enter. Select F6 and add “noreplace-paravirt” to the end of the command line and press Enter. Now pick “Try Ubuntu…” (should already be selected) and press enter. Do NOT pick the Install Ubuntu option,
Once Ubuntu is loaded from CD, select install from the desktop and it’ll build the system on the VPC disk. After you press restart, it just kind of hangs there. I shut the VPC session down and told it to save state, then started it again and it booted fine.
Once it gets to GRUB, interupt the boot and add the “noreplace-paravirt” to the kernel boot line.
1. Press “esc” while grub is visible. 2. You should now see 3 entries to select from. Leave the first one “Ubuntu 8.04, kernel 2.6.24-16-generic” selected and press “e”. 3. On the next page, select the second entry that reads “kernel /boot/vmlinuz…” and press “e” again. 4. You will see a command line that ends with “xforcevesa”. Hit “space” and add “noreplace-paravirt” (without the quotes) to that line and press “enter”. 5. You are now back at the previous selection screen with the entry “kernel /boot/vmlinuz…” still selected. Now press “b” and it should boot correctly.
Once Ubuntu has loaded, open a terminal window (Applications. Accessories, Terminal) and on the command line enter “sudu nano /boot/grub/menu.lst” Enter your password and page down to near the bottom and locate the “kernel /boot/vmlinuz… in the “Ubuntu 8.04, kernel 2.6.24-16-generic” section
Move the cursor to the end of the line after xforcevesa and add “noreplace-paravirt” (no quotes) Ctrl + O to write out, enter to accept the name, Ctrl + X to close
While you’re editing, you might as well fix the sound while you’re at it.
sudo nano /etc/rc.local
At the end of the # lines, but before “exit 0″, type on a new line (again without quotes) “modprobe snd-sb16″ Ctrl + O to write out, enter to accept the name, Ctrl + X to close.
Reboot Ubuntu. The reboot should be clean, and the sound icon should come up without an error indication.
Find the entry from pb dated April 27 and cut the xorg.conf file from this entry and past it into the Ubuntu text editor. (Applications, Accessories, Text Editor). Save the file as xorg.conf in your user folder.
Open a terminal window.
Backup the old version of xorg.conf sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
Copy the new one you created to the same location sudo cp xorg.conf /etc/X11/xorg.conf
Reboot.
When Ubuntu reboots, your get a black screen with a X in the middle, then you’ll get a dialog message to saying “Ubuntu is running in low graphics mode, screen and graphics card coud not be detected”.
Take the option to configure graphics mode. In the drop down where it says plug & play, select “Monitor 1280 X 1024″. Select 1280 X 1024 @ 60Hz as your resolution. Select Test You should get a larger ‘gray’ window with option to keep the confguration. Select the option to keep it.
Ubuntu will start as normal and will be exactly the same size as before. Before you reboot, take alook at /etc/X11/xorg.conf …. it’s not the one you just created. Creating the new one appears to force Ubuntu to create a new one with more options.
Reboot again and you shold have a Ubuntu session runing at 1152 X 768 @ 55Hz.
Last couple of things…. in System, Preferences, Sound, set the playback options to ALSA. It’s pretty crappy but works better than OSS and certainly better than Auto detect which generates a stream error when you try to play MP3’s or movies.
Whew! That's a lot of text. I'll leave you with the new Ubuntu desktop background, which is pretty cool in a orange-brown-must-be-the-new-black kind of way.
If you have Vista, or installed XP SP3, you might have seen some quirkiness out of Microsoft Virtual PC 2007. To counter, Microsoft has released a Service Pack for this Virtual environment. The Download is for x86 and x64 and...
#re: Installing Ubuntu 8.04 Hardy Heron in Virtual PC 2007
Very helpful article. Using it I got a Hardy Heron Desktop install onto a Virtual PC VM on Vista. Any suggestions about how to get the Server install onto a VM instead?
[제목] 아파치 로그 파일 - 특이한 녀석들은 따로 담거나 없애기
* 제목이 좀 이상하네요........^.^
작성자 : 김칠봉 <san2(at)linuxchannel.net>
작성일 : 2001. 04. 30
대상자 : 초보
- 힌트 URL : 임은재님이 쓴 글을 보고 나서
http://kltp.kldp.org/stories.php?story=00/10/22/9724184
- 관련 문서 : 아파치 제공 문서
http://httpd.apache.org/docs/mod/mod_log_config.htmlhttp://httpd.apache.org/docs/mod/mod_setenvif.html
목차
1. 배경
2. 기초지식
2-1. 로그포맷과 CustomLog 지시자
2-2. 아파치 환경변수 설정
3. 예제
3-1. 특정 IP 주소만 환경변수로 설정하기
3-2. 특정 타입의 파일만 환경변수로 설정하기
3-3. 특정 User-Agent 만 환경변수로 설정하기
3-4. 종합예제 : 사오정(?) 로그 분석 피하기
------------------------------------------
1. 배경
몇 달 전부터 Webalizer 라는 로그 분석기로 제가(이하 '필자') 운영하는 싸이트의
로그를 대충 분석(?)해 봤는데 사오정(?) 분석이 되어 버렸더군요.
결정적으로 필자가 운영하는 싸이트의 대부분은 php로 구성되어 있는데, 이는 실제로
- 방문자 외에 localhost에서 php가 실행하는 로그 기록
- 로봇들의 접근 기록
- 운영자(필자)가 접근한 로그 기록
등등이 함께 기록되어 있어 순수 방문자 통계에 약간 덜(?) 정확한 통계가 나오더군요.
따라서 이런 유형들의 로그는 없애거나 따로 로그기록하는 것이 낫을 것 같더군요.
위의 내용이 이하 다루는 내용입니다.
2. 기초지식
2-1. 로그포맷과 CustomLog 지시자
Module mod_log_config 은 아파치 기본 모듈입니다.
로그 포맷 스트링
%a : 원격의 IP 주소
%b : 헤더를 포함한 전송량(bytes)
%{var}e : 환경 변수 "var"
%f : 파일이름
%h : 원격의 호스트
%{hdr}i : 서버에 들어오는(요청) 헤더 값 "hdr"
%l : 원격의 로그인 ID(지원한다면)
%{label}n : 다른 모듈에서 "label" 구성
%{hdr}o : 응답 헤더 값 "hdr"
%p : 서버의 Canonical 포트 번호
%P : 자식 프로세스 ID(PID)
%r : 첫번째 요청 라인
%s : 상태코드
%t : 시간 포맷(CLF 포맷)
%{format}t : "format"으로 구성된 시간 포맷
%T : 서버에 요청하는 시간(초)
%u : 원격의 유저이름(인증시)
%U : 요청한 URL
%v : 클라이언트 요청에 따른 Canonical 서버네임
%V : UseCanonicalName 설정에 따른 서버네임
일반적으로 아파치를 설치하고 나면, 다음과 같이 기본설정되어 있을 겁니다.
(굳지 수정할 필요없음)
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /usr/local/apache/logs/access_log common
물론 이 정도는 다 알고 계시리라 믿습니다.
로그 기록 지시자
CookieLog
CustomLog
LogFormat
TransferLog
CookieLogs는 제외하고 나머지 지시자에 대해서 알아봅시다.
LogFormat 지시자
Syntax: LogFormat format|nickname [nickname]
Default: LogFormat "%h %l %u %t \"%r\" %>s %b"
Context: server config, virtual host
Status: Base
Compatibility: Nickname only available in Apache 1.3 or later
Module: mod_log_config
CustomLog 지시자
Syntax: CustomLog file|pipe format|nickname [env=[!]environment-variable]
Context: server config, virtual host
Status: Base
Compatibility: Nickname only available in Apache 1.3 or later.
Conditional logging available in 1.3.5 or later.
Module: mod_log_config
TransferLog 지시자
Syntax: TransferLog file|pipe
Default: none
Context: server config, virtual host
Status: Base
Module: mod_log_config
LogFormat 지시자는 앞에서 예제가 있으므로 생략하고 비슷한 기능을 가진
CustomLog, TransferLog 지지자에 대해서 잠깐 알아봅시다.
둘다 file 에 로그를 기록한다는 면에서는 동일한 기능입니다.(pipe 기능도 동일)
같은점
1. 둘다 file에 로그를 기록한다.
2. |pipe 에 설정한 외부 프로그램을 인자로 사용할 수 있다.
3. 둘다 다중 로그를 사용할 수 있다.
다른점
1. CustomLog 지시자는 LogFormat 지시자에서 설정한 nickname이나 Log format을
인자로 사용할 수 있다.
2. CustomLog 지시자는 환경변수를 인자로 가질 수 있다.
따라서,
이하 다룰 내용은 환경변수를 설정하고 이 환경변수(env)와 동일(=)하거나 그렇지 않은(!=)
특정 유형에 대해서 로그에 기록해야하 하므로 당연히 CustomLog 지시자를 사용해야
합니다.
*주의)
환경변수를 인자로 사용할 경우 하나만 가능.
이해가 되셨는지 모르겠네요....
2-2. 아파치 환경변수 설정
아파치에서 환경변수를 설정하는 방법은 몇가지 있습니다.
예를 들어,
- mod_env 모듈에 의한
SetEnv
지시자 이용
- mod_setenvif 모듈에에 의한
BrowserMatch
BrowserMatchNoCase
SetEnvIf
SetEnvIfNoCase
지시자 이용
등이 있습니다.
여기에서 주로 사용할 지시자는 BrowserMatch 지시자와 SetEnvIf 지시자입니다.
*참고)
xxxxNoCase 지시자는 대소문자를 구분하지 않겠다는 의미입니다.
이 두개의 지시자에 대한 사용법만 간단하게 알아봅시다.
BrowserMatch 지시자
Syntax: BrowserMatch regex envar[=value] [envar[=value]] ...
Default: none
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Base
Module: mod_setenvif
Compatibility: Apache 1.2 and above (in Apache 1.2 this directive was found in the
now-obsolete mod_browser module); use in .htaccess files only supported with
1.3.13 and later
SetEnvIf 지시자
Syntax: SetEnvIf attribute regex envar[=value] [envar[=value]] ...
Default: none
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Base
Module: mod_setenvif
Compatibility: Apache 1.3 and above; the Request_Protocol keyword and
environment-variable
matching are only available with 1.3.7 and later; use in .htaccess files only supported
with 1.3.13 and later
환경변수 지정 및 값 지정 방법
1.varname, or
2.!varname, or
3.varname=value
예 :
BrowserMatch ^Mozilla forms jpeg=yes browser=netscape
BrowserMatch "^Mozilla/[2-3]" tables agif frames javascript
BrowserMatch MSIE !javascript
BrowserMatchNoCase Robot is_a_robot
SetEnvIfNoCase User-Agent Robot is_a_robot
BrowserMatchNoCase mac platform=macintosh
BrowserMatchNoCase win platform=windows
SetEnvIf Request_URI "\.gif$" object_is_image=gif
SetEnvIf Request_URI "\.jpg$" object_is_image=jpg
SetEnvIf Request_URI "\.xbm$" object_is_image=xbm
:
SetEnvIf Referer www\.mydomain\.com intra_site_referral
:
SetEnvIf object_is_image xbm XBIT_PROCESSING=1
SetEnvIfNoCase Host Apache\.Org site=apache
SetEnvIf 지자자에서 attribute 에 올 수 있는 것들 :
Remote_Host - the hostname (if available) of the client making the request
Remote_Addr - the IP address of the client making the request
Remote_User - the authenticated username (if available)
Request_Method - the name of the method being used (GET, POST, et cetera)
Request_Protocol - the name and version of the protocol with which the request
was made (e.g., "HTTP/0.9", "HTTP/1.1", etc.)
Request_URI - the portion of the URL following the scheme and host portion
그외
Host, User-Agent, and Referer 가능
see http://www.rfc-editor.org/rfc/rfc2616.txt
따라서,
BrowserMatch와 SetEnvIf User-Agent 는 서로 동일하다는 것을 알 수 있을 겁니다.
*중요)
CustomLog 지자자와 다르게 환경변수 인자에 여러 개를 설정할 수 있음.
여기까지 이해가 되셨다면 다음은 보지 않아도 될듯 하군요.......^.^
3. 예제
3-1. 특정 IP 주소만 환경변수로 설정하기
- 환경변수 이름 : do_not_log
- 목적 : 이 환경변수에 해당되는 특정 IP 주소는 access_log에 기록하지 않는다.
SetEnvIf Remote_Addr "^127.0.0.1$" do_not_log
SetEnvIf Remote_Addr "^211.35.159.12[89]$" do_not_log
SetEnvIf Remote_Addr "^211.35.159.1[345][0-9]$" do_not_log
위에서 설정한 특정 IP 주소는
127.0.0.1 자기자신을 말하는 루프백 주소
211.35.159.128, 211.35.159.129 두개의 IP 주소
211.35.159.130 ~ 211.35.159.139 10개의 IP 주소
211.35.159.140 ~ 211.35.159.149 10 개의 IP 주소
211.35.159.150 ~ 211.35.159.159 10 개의 IP 주소
즉 원격의 IP 주소(Remote_Addr)가 위와 일치하면 do_not_log 환경변수에 지정하는 예임.
*참고)
^ 은 시작을 의미
$ 은 마지막을 의미
[0-9] 0~9까지의 숫자중 어느 하나
3-2. 특정 타입의 파일만 환경변수로 설정하기
SetEnvIfNoCase Request_URI "\.(gif|jpg|png|css|js|java)$" do_not_log
요청 URI(Request_URI) 파일이
*.gif
*.jpg
*.png
*.css
*.js
*.java
로 끝난 파일인 경우(대소문자를 구별하지 않음) do_not_log 환경변수에 지정함
3-3. 특정 User-Agent 만 환경변수로 설정하기
- 환경변수 이름 : do_not_log 과 is_a_robot
- 목적 : 이 환경변수에 해당되는 특정 User-Agent는 access_log에 기록하지 않고,
따로 로그(robot-log)에 기록하거나 기록하지 않기 위함.
BrowserMatchNoCase "ru-robot" do_not_log is_a_robot
BrowserMatchNoCase "Slurp/si" do_not_log is_a_robot
BrowserMatchNoCase "Mercator" do_not_log is_a_robot
BrowserMatchNoCase "Gulliver" do_not_log is_a_robot
BrowserMatchNoCase "SyncIT/" do_not_log is_a_robot
BrowserMatchNoCase "FAST-WebCrawler" do_not_log is_a_robot
BrowserMatchNoCase "Lycos_Spider" do_not_log is_a_robot
BrowserMatchNoCase "^ia_archive" do_not_log is_a_robot
BrowserMatchNoCase "^tv" do_not_log is_a_robot
BrowserMatchNoCase "Scooter" do_not_log is_a_robot
BrowserMatchNoCase "ZyBorg/" do_not_log is_a_robot
BrowserMatchNoCase "KIT-Fireball" do_not_log is_a_robot
BrowserMatchNoCase "Googlebot/" do_not_log is_a_robot
BrowserMatchNoCase "DIIbot/" do_not_log is_a_robot
BrowserMatchNoCase "teoma_agent3" do_not_log is_a_robot
BrowserMatchNoCase "empas_robot" do_not_log is_a_robot
모두 로봇으로 맞게 설정되었는지 모르겠네요...............T.T
각각의 정규표현식 조건에 맞는 User-Agent 인 경우, do_not_log 환경변수와
is_a_robot 이라는 두개의 환경변수에 설정한 예입니다.
is_a_robot 이라고 또 하나의 환경변수를 지정한 이유는 앞서 얘기했듯이
이 조건게 맞는 User-Agent가 접근할 경우 따로 로그에 기록하기 위함입니다.
이 BrowserMatchNoCase 지시자 대신에 SetEnvIfNoCase User-Agent 로 대신할 수 있는데
첫번째 부분을 다음과 같이 설정할 수 있습니다.(둘다 똑 같은 결과임)
SetEnvIfNoCase User-Agent "ru-robot" do_not_log is_a_robot
3-4. 종합예제 : 사오정(?) 로그 분석 피하기
앞의 3개의 예제를 모두 적용하면 다음과 같습니다.
목적은 배경에서 설명했듯이 가능한 access_log 파일에
- 방문자 외에 localhost에서 php가 실행하는 로그 기록은 기록하지 않는다.
- 로봇들의 접근 기록은 따로 robot-log 파일에 기록한다.
- 운영자가 주고 접근할 IP 주소는 로그에 기록하지 않는다.
- *.gif, *.jpg, *.png, *.css, *.js, *.java 등과 같은 파일은 로그에 기록하지 않는다.
이 정도의 조건이라면 가능한 어느 정도 수준으로 순수 방문자의 접근 기록만
access_log 파일에 기록할 수 있습니다.
-- httpd.conf(실제로 필자가 운영하는 아파치 설정 내용임) --------------------
##
## 중간 생략
##
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{User-Agent}i\"" use_robot
##
## 중간 생략
##
## 환경변수 do_not_log에 일치하지 않은 접근만 access_log 파일에 기록함.
##
CustomLog /usr/local/apache/logs/access_log combined env=!do_not_log
## 중간 생략
## 로봇들은 따로 robot_log 파일에 user_robot 포맷에 맞게 기록함
##
CustomLog /usr/local/apache/logs/robot_log use_robot env=is_a_robot
## 중간 생략
## 특정 IP 주소는 로그에 기록하지 않는다.
## 주로 서버 IP 주소와 운영자가 자주 접속하는 IP 주소들
##
SetEnvIf Remote_Addr "^127.0.0.1$" do_not_log
SetEnvIf Remote_Addr "^211.35.159.12[89]$" do_not_log
SetEnvIf Remote_Addr "^211.35.159.1[345][0-9]$" do_not_log
## 중간 생략
## 주로 이미지 파일을 요청했을 경우 로그에 기록하지 않는다.
##
SetEnvIfNoCase Request_URI "\.(gif|jpg|png|css|js|java)$" do_not_log
## 중간 생략
## 로봇들의 환경변수 지정
##
BrowserMatchNoCase "ru-robot" do_not_log is_a_robot
BrowserMatchNoCase "Slurp/si" do_not_log is_a_robot
BrowserMatchNoCase "Mercator" do_not_log is_a_robot
BrowserMatchNoCase "Gulliver" do_not_log is_a_robot
BrowserMatchNoCase "SyncIT/" do_not_log is_a_robot
BrowserMatchNoCase "FAST-WebCrawler" do_not_log is_a_robot
BrowserMatchNoCase "Lycos_Spider" do_not_log is_a_robot
BrowserMatchNoCase "^ia_archive" do_not_log is_a_robot
BrowserMatchNoCase "^tv" do_not_log is_a_robot
BrowserMatchNoCase "Scooter" do_not_log is_a_robot
BrowserMatchNoCase "ZyBorg/" do_not_log is_a_robot
BrowserMatchNoCase "KIT-Fireball" do_not_log is_a_robot
BrowserMatchNoCase "Googlebot/" do_not_log is_a_robot
BrowserMatchNoCase "DIIbot/" do_not_log is_a_robot
BrowserMatchNoCase "teoma_agent3" do_not_log is_a_robot
BrowserMatchNoCase "empas_robot" do_not_log is_a_robot
## 이하 생략
##
------------------------------------------------------
END
VirtuaWin is a virtual desktop manager for the Windows operating system (Win9x/ME/NT/Win2K/XP). A virtual desktop manager lets you organize applications over several virtual desktops (also called 'workspaces'). Virtual desktops are very common in Unix/Linux, and once you get accustomed to using them, they become an essential part of a productive workflow.
VirtuaWin is designed to be simple and elegant to use yet still be highly configurable and extensible.
Have as many as 9 virtual desktops on Windows with VirtuaWin!
# Installing Fedora 9 (Sulphur) in Virtual PC 2007
Fedora 9 was released last week, which you can download here: http://fedoraproject.org/get-fedora.html
# Virtual PC 2007 SP1 now out.
If you have Vista, or installed XP SP3, you might have seen some quirkiness out of Microsoft Virtual PC 2007. To counter, Microsoft has released a Service Pack for this Virtual environment. The Download is for x86 and x64 and...
# Virtual Server on Windows Home Server
Virtual Server on Windows Home Server
# Installare Fedora 9 in Virtual PC 2007
Installare Fedora 9 in Virtual PC 2007
# re: Installing Ubuntu 8.04 Hardy Heron in Virtual PC 2007
Very helpful article. Using it I got a Hardy Heron Desktop install onto a Virtual PC VM on Vista. Any suggestions about how to get the Server install onto a VM instead?
# Instalación de Ubuntu 8.04 en Virtual PC 2007
Reconozco que siempre he utilizado Windows, ya que mi trabajo así lo ha requerido, pero con los nuevos