예전것/시스템 보안2009. 5. 26. 23:27

보안모니터링 프로그램 secure agent를 컴파일하여 실행파일을 얻었다.
그런데 이 실행파일은 daemon형태로 시스템에서 항상 실행되어야 하는 프로그램이다.
시스템이 부팅시마다 secure agent가 실행될 수 있도록 완전한 부팅 스크립트를
작성하여 적절한 위치에 설치하시오.
현재 secure agent 데몬의 실행파일 경로는 /usr/local/bin/sagentd이며,
설치하고자 하는 시스템은 solaris이다.


참조 : http://www.onurmark.co.kr/76 

리눅스에서는
/etc/init.d/ (문제의 solaris 시스템에서는 이디렉토리만 존재하지만 centos에서는 /etc/init.d도 있지만 /etc/rc.d/init.d도 존재. 똑같은 스크립트를 가진다. 왜 이런식으로 사용하는지는 잘모르겠다.- 검색이 더 필요)


여튼 , /etc/init.d/ 아래 있는 스크립트 파일들은 부팅시에 실행되는 것들이다.
여기에 sagentd가 실행될수있도록 아무 파일이나 만들자. (여기서는 SA라고 하자. 사실 sagentd로 만들고 싶었으나 같은 파일이 존재한다. 깨져서 먼말인지는 잘 모르겠다.)

#vi SA
을 치고 SA파일을 작성하자
#!/bin/sh
/usr/local/bin/sagentd
작성후 꼭
#chmod 755 SA 를 해서 실행가능하도록 해야한다..

실제로 리눅스는 부팅할때 /etc/rc.d/init.d에 있는 스크립트를 실행을 하게 되는데 이 파일들을 바로 불러서 쓰는것이 아니다. 이 스크립트들은 리눅스의 부팅 레벨이나 사용 설정에 따라 실행 되게 된다. 이러한 설정은 /etc/rc.d/에 보면 rcX.d(X는 숫자)로 되어있는 디렉토리가 있는것을 알 수 있다.

#grep 'initdefault' /etc/inittab
을 쳐서 default runlevel을 확인하자 ( runlevel은 3)

ln -s /etc/init.d/SA /etc/rc.d/rc3.d/S89SA   --> 심볼릭 링크를 만들어주자.
(뒤에 S의 의미는 부팅시 수행되는 스크립트라는 뜻. K가 붙으면 종료시 수행. S뒤의 숫자는 우선순위이다.)

사실 /etc/rc.d/rc3.d/S89SA 파일을 만들고 작성해서 사용해도되지만 나중에 관리가 힘들어진다고 한다.

이제 끝

finish







예전것/시스템 보안2009. 5. 26. 03:16

inetd 데몬은 ftp, telnet등을 탑재(?)한 데몬인데 항상 수행되지는않으나 가끔 수행되는것을 여기에 놓고 쓴다고한다,

inetd vs xinetd(eXtended inted)
xinetd는 inted의 문제점을 보완하고 기능이 추가된 확장판이라고 할 수 있다.

더 자세한 사항 :
http://www.linuxplanet.com/linuxplanet/tutorials/4505/2/ 

문제 : 그동안 ftp서버로 사용하던 시스템을 ftp서비스를 더이상 제공하지 않고
다른 용도로 사용하게 되었다.
현재 제공되고 있는 ftp서비스를 중지시키고
앞으로도 부팅시에도 더이상 제공되지 않도록 필요한 시스템 설정을 바꾸시오.

vi /etc/inetd.conf 에 inetd에 관한 설정이 들어있다. ftp관련 항목을 #으로 주석처리한다.
/etc/services 에도 ftp 항목이있고 이것은 주석처리 안해주어도 상관없다. 이것은 포트 번호를 모를때 우리는 그냥 ftp, smtp 이렇게 쓰는데 이것의 역도 된다. (주석처리를 하면 안됨, 보안과는 별 상관이 없는듯하다.)

/ ************* 퍼온 글
/etc/services에 있는 것은 그냥 서버스의 영문약자를 숫자로 전환하기 위한
테이블에 불과하고,
ipchains나 iptables와 같은 툴로 다 필터링이 가능하다고, *************/

이것만 해도 문제가 풀린다.

inetd데몬을 중지시키기 위해서 inetd데몬이 어디 위치해 있는지 찾고 중지시키는것도 괜찮겠다.
하지만 이방법은 ftp가 아닌 다른 서비스도 중지시키므로 자제.

데몬관리 : http://ask.nate.com/knowhow/view.html?num=123513 여기 참고

 (2)슈퍼데몬 inet에서 관리하는 데몬
   1) inet에서 관리하는 전체를 중지 또는 실행시키는 방법
    ㄱ. 커널 2.2 버전
       /etc/rc.d/init.d/inet stop
       /etc/rc.d/init.d/inet start
    ㄴ. 커널 2.4 버전
       /etc/rc.d/init.d/xinetd stop
       /etc/rc.d/init.d/xinetd start
    ㄷ. 참고: 위의 방법으로 inet을 중단시키면 inet데몬에 관련된 모든 데몬들이 작동을 하지 않는
             다. 그러므로, 한가지 데몬만을 중단한 경우에는 적합하지 않다.

   2) inet(또는 xinetd)에서 관리하는 데몬중 일부만 중지시키기
    ㄱ. 커널 2.2 버전: inet데몬에서 일부만 중단하려면 /etc/inetd.conf 파일에서 한다. 해당 서비
                      스 항목의 맨 앞에 주석처리('#')를 하면 해당 서비스에 해당하는 데몬이
                      작동하지 않는다.

   예) telnet서비스 중단하기
       #telnet  stream  tcp     nowait  root    /usr/sbin/tcpd  in.telnetd
        => (항목설명)
          - 서비스이름: /etc/services파일에 정의된 텔넷, ftp와 같은 특정 서비스들을 의미
          - 소켓타입: 서비스에 의해 사용된 연결의 타입을 기술. 보통 tcp서비스인 경우에는
                     'stream', udp서비스인 경우에는 'dgram'이 옴
          - 프로토콜: 네트워크 프로토콜 타입이 기술된다. 보통 'tcp'나 'udp'가 옴.
          - 대기상태: 하나의 서버프로세스가 한번에 여러 요청을 처리할 수 있는지를 나타냄. wait
                     이면 inetd가 서비스들에 대한 각각의 요청을 처리하기 위해 여러 프로세스가
                     생성되는 것을 방지하고 nowait라고 설정되어 있으면 각각의 요청을 위해 프로
                     세스를 생성
          - 사용자이름: 네트워크 서비스를 수행해야 할 로그인 이름
          - 서버프로그램: 네트워크 서비스를 활성화시키기 위해 수행해야 할 프로그램을 가리킴
          - 서버프로그램인자: 네트워크 서비스가 수행되기 시작할 때, 전달 되어야 할 인자와 설정
                             플래그들을 나열
    ㄴ. 커널 2.4 버전: /etc/xinetd.d디렉토리에 보면 xinetd에서 관리하는 데몬들의 파일이 생성
                     되어 있다. 만약 telnet이면 telnet이라는 파일의 항목에서 'disable = yes'
                     라고 설정하면 해당 데몬은 xinetd에서 실행하지 않는다. 또는 'chkconfig
                     telnet off' 하면 된다.



카테고리 없음2009. 5. 22. 22:40

http://nmap.org/bennieston-tutorial/
요 페이지 해석

1. Introduction : 그냥 소개글
Nmap is a free, open-source port scanner available for both UNIX and Windows. It has an optional graphical front-end, NmapFE, and supports a wide variety of scan types, each one with different benefits and drawbacks.

This article describes some of these scan types, explaining their relative benefits and just how they actually work. It also offers tips about which types of scan would be best against which types of host.

The article assumes you have Nmap installed (or that you know how to install it. Instructions are available on the Nmap website, http://www.insecure.org/nmap/install/inst-source.html ), and that you have the required privileges to run the scans detailed (many scans require root or Administrator privileges).

A frequently asked questions section has been added since the first version of this article, and this is included as the last section in this version. This is a fully revised and updated version of this tutorial, re-typed and converted to a TeX format, allowing more output formats to be utilised. At the time of writing, the latest Nmap version was 4.11.

2. Disclaimer (A disclaimer is a statement in which a person says that they did not know about something or that they are not responsible for something)
This information is provided to assist users of Nmap in scanning their own networks, or networks for which they have been given permission to scan, in order to determine the security of such networks. it is not intended to assist with scanning remote sites with the intention of breaking into or exploiting services on those sites, or for imformation gathering purposes beyond those allowed by law. I hereby disclaim any responsibility for actions taken based upon the information in this article, and urge all who seek information towards a destructive end to reconsider their life, and do something constructive instead.
 -  요약 : 나쁘게 사용해서 인생 망치지 말라는 글

3  Basic Scan Types [-sT, -sS]

The two basic scan types used most in Nmap are TCP connect() scanning [-sT] and SYN scanning (also known as half-open, or stealth scanning) [-sS].
These two types are explained in detail below.

3.1  TCP connect() Scan [-sT]

These scans are so called because UNIX sockets programming uses a system call named connect() to begin a TCP connection to a remote site. If connect() succeeds, a connection was made. If it fails, the connection could not be made (the remote system is offline, the port is closed, or some other error occurred along the way). This allows a basic type of port scan, which attempts to connect to every port in turn, and notes whether or not the connection succeeded. Once the scan is completed, ports to which a connection could be established are listed as open, the rest are said to be closed.
(TCP connection을 할때 system call "connect()를 쓰므로 저렇게 명명 되었다. connect()가 성공하면 연결된다. (안되는경우 : remote system이 offline port closed , 도중에 에러 발생)

This method of scanning is very effective, and provides a clear picture of the ports you can and cannot access. If a connect() scan lists a port as open, you can definitely connect to it - that is what the scanning computer just did! There is, however, a major drawback to this kind of scan; it is very easy to detect on the system being scanned. If a firewall or intrusion detection system is running on the victim, attempts to connect() to every port on the system will almost always trigger a warning. Indeed, with modern firewalls, an attempt to connect to a single port which has been blocked or has not been specifically "opened" will usually result in the connection attempt being logged. Additionally, most servers will log connections and their source IP, so it would be easy to detect the source of a TCP connect() scan.

For this reason, the TCP Stealth Scan was developed.
(단점 : 탐지하기가 쉽다. 대부분의 서버들에 로그가 남는다. 현대의 방화벽은 막혀있는 포트나 특별히 "opened"되지 않은 a single port 로 connect 하려는 시도를 로그에 남긴다.)

3.2  SYN Stealth Scan [-sS]

I’ll begin this section with an overview of the TCP connection process. Those familiar with TCP/IP can skip the first few paragraphs.

When a TCP connection is made between two systems, a process known as a "three way handshake" occurs. This involves the exchange of three packets, and synchronises the systems with each other (necessary for the error correction built into TCP. Refer to a good TCP/IP book for more details.

The system initiating the connection sends a packet to the system it wants to connect to. TCP packets have a header section with a flags field. Flags tell the receiving end something about the type of packet, and thus what the correct response is.

Here, I will talk about only four of the possible flags. These are SYN (Synchronise), ACK (Acknowledge), FIN (Finished) and RST (Reset). SYN packets include a TCP sequence number, which lets the remote system know what sequence numbers to expect in subsequent communication. ACK acknowledges receipt of a packet or set of packets, FIN is sent when a communication is finished, requesting that the connection be closed, and RST is sent when the connection is to be reset (closed immediately).

To initiate a TCP connection, the initiating system sends a SYN packet to the destination, which will respond with a SYN of its own, and an ACK, acknowledging the receipt of the first packet (these are combined into a single SYN/ACK packet). The first system then sends an ACK packet to acknowledge receipt of the SYN/ACK, and data transfer can then begin.

SYN or Stealth scanning makes use of this procedure by sending a SYN packet and looking at the response. If SYN/ACK is sent back, the port is open and the remote end is trying to open a TCP connection. The scanner then sends an RST to tear down the connection before it can be established fully; often preventing the connection attempt appearing in application logs. If the port is closed, an RST will be sent. If it is filtered, the SYN packet will have been dropped and no response will be sent. In this way, Nmap can detect three port states - open, closed and filtered. Filtered ports may require further probing since they could be subject to firewall rules which render them open to some IPs or conditions, and closed to others.

Modern firewalls and Intrusion Detection Systems can detect SYN scans, but in combination with other features of Nmap, it is possible to create a virtually undetectable SYN scan by altering timing and other options (explained later).

4  FIN, Null and Xmas Tree Scans [-sF, -sN, -sX]

With the multitude of modern firewalls and IDS’ now looking out for SYN scans, these three scan types may be useful to varying degrees. Each scan type refers to the flags set in the TCP header. The idea behind these type of scans is that a closed port should respond with an RST upon receiving packets, whereas an open port should just drop them (it’s listening for packets with SYN set). This way, you never make even part of a connection, and never send a SYN packet; which is what most IDS’ look out for.

The FIN scan sends a packet with only the FIN flag set, the Xmas Tree scan sets the FIN, URG and PUSH flags (see a good TCP/IP book for more details) and the Null scan sends a packet with no flags switched on.

These scan types will work against any system where the TCP/IP implementation follows RFC 793. Microsoft Windows does not follow the RFC, and will ignore these packets even on closed ports. This technicality allows you to detect an MS Windows system by running SYN along with one of these scans. If the SYN scan shows open ports, and the FIN/NUL/XMAS does not, chances are you’re looking at a Windows box (though OS Fingerprinting is a much more reliable way of determining the OS running on a target!)

The sample below shows a SYN scan and a FIN scan, performed against a Linux system. The results are, predictably, the same, but the FIN scan is less likely to show up in a logging system.

   1 [chaos]# nmap -sS 127.0.0.1
   2 
   3 Starting Nmap 4.01 at 2006-07-06 17:23 BST
   4 Interesting ports on chaos (127.0.0.1):
   5 (The 1668 ports scanned but not shown below are in state:
   6         closed)
   7 PORT     STATE SERVICE
   8 21/tcp   open  ftp
   9 22/tcp   open  ssh
  10 631/tcp  open  ipp
  11 6000/tcp open  X11
  12 
  13 Nmap finished: 1 IP address (1 host up) scanned in 0.207
  14         seconds
  15 [chaos]# nmap -sF 127.0.0.1
  16 
  17 Starting Nmap 4.01 at 2006-07-06 17:23 BST
  18 Interesting ports on chaos (127.0.0.1):
  19 (The 1668 ports scanned but not shown below are in state:
  20         closed)
  21 PORT     STATE         SERVICE
  22 21/tcp   open|filtered ftp
  23 22/tcp   open|filtered ssh
  24 631/tcp  open|filtered ipp
  25 6000/tcp open|filtered X11
  26 
  27 Nmap finished: 1 IP address (1 host up) scanned in 1.284
  28         seconds

5  Ping Scan [-sP]

This scan type lists the hosts within the specified range that responded to a ping. It allows you to detect which computers are online, rather than which ports are open. Four methods exist within Nmap for ping sweeping.

The first method sends an ICMP ECHO REQUEST (ping request) packet to the destination system. If an ICMP ECHO REPLY is received, the system is up, and ICMP packets are not blocked. If there is no response to the ICMP ping, Nmap will try a "TCP Ping", to determine whether ICMP is blocked, or if the host is really not online.

A TCP Ping sends either a SYN or an ACK packet to any port (80 is the default) on the remote system. If RST, or a SYN/ACK, is returned, then the remote system is online. If the remote system does not respond, either it is offline, or the chosen port is filtered, and thus not responding to anything.

When you run an Nmap ping scan as root, the default is to use the ICMP and ACK methods. Non-root users will use the connect() method, which attempts to connect to a machine, waiting for a response, and tearing down the connection as soon as it has been established (similar to the SYN/ACK method for root users, but this one establishes a full TCP connection!)

The ICMP scan type can be disabled by setting -P0 (that is, zero, not uppercase o).



예전것/Linux Basic2009. 5. 22. 16:57

주소 : ftp://ftp.sayclub.com/pub/Linux/centos/5.3/os/i386/CentOS/

name : ftp.sayclub.com
directory : pub/Linux/centos/5.3/os/i386

**Caution : directory 가 i386/CentOS가 아니라 i386으로 끝난다!

오래걸린다. 웬만하면 그냥 dvd받자

'예전것 > Linux Basic' 카테고리의 다른 글

emacs의 설정  (0) 2009.07.16
리눅스에서 키설정 & 디버깅  (0) 2009.07.16
NFS 간단설정  (0) 2009.07.12
BASH SHELL LAB EXERCISE  (0) 2009.06.08
.bash_profile , hash  (0) 2009.06.04
예전것/시작2009. 5. 21. 23:05
먼 놈의 초대장이니...

'예전것 > 시작' 카테고리의 다른 글

공부 명언  (0) 2010.03.30