CentOS 6.8 snort 설치
//2017.03.17 수정 (snort 구동문제)
1. snort
snort는 1998년에 마틴 로시(Martin Roesch)가 개발한 무료 오픈소스 네트워크 침입 차단 탐지 시스템이다.
여러 OS를 지원하고 snort 커뮤니티에서 rule을 다운받아 사용 가능하고 사용자가 직접 탐지 rule을 설정해서 사용할 수도 있다.
2. snort 기능
snort는 실시간 트래픽 분석과 패킷 로깅을 수행한다.
모드
- 패킷 스니퍼 모드 (Sniffer Mode)
tcpdump와 같은 네트워크상의 TCP/IP 패킷을 읽어 보여주는 기능
- 패킷 로거 모드 (PacketLogger Mode)
모니터링한 패킷을 저장하고 로그를 기록하는 기능
트래픽 디버깅에 유용
- 네트워크 침입 탐지 모드 (Network Intrusion Detection System Mode:NIDS)
침입탐지시스템(IDS), 네트워크 트래픽(패킷) 부석 및 공격 탐지 기능
- Snort Inline
침입방지시스템(IPS), 패킷 분석, 공격 차단 기능
옵션
-v : snort를 패킷 Sniffing 모드로 동작(TCP)
-d : 모든 네트워크 계층을 포함
-e : 데이터 링크 계층 헤더를 포함
-c : 패킷 검출
3. snort 구조
- Sniffer
Snort IDS를 통과한 모든 패킷 수집하여, 사람이 보기 쉽게 Decode한다.
어플리케이션 또는 하드웨어 장치에서 해당 네트워크의 트래픽을 도청할 수 있다.
- Preprocessor
효율적인 공격 탐지를 위해 몇가지 플러그인을 먼저 거치며 매칭 확인한다.
비정상 헤더 구조 패킷이나, 트래픽을 구분한다.
snort 디코더를 통해 분해하여 패킷구조, 플래그 정보, 프로토콜 정보를 이용하여 패킷의 형식이나 구조를 해석한다.
Fragment된 패킷은 조합하여 정상적인 패킷인지 검사한다.
- Detection Engine
rule기반의 탐지 엔진으로, 사전에 정의된 탐지룰과 매칭되는지 확인한다.
Payload에 포함된 Data를 분석해 공격 여부를 판단한다.
패킷과 일치하는 ruleset이 있으면 해당 패킷은 Alrt/Logging으로 전달된다.
- Alert/Logging
정책에 따른 로그 기록을 한다. Alert는 Log File, SMB, SNMP trap등으로 Log는 Text File 또는 DB에 저장한다.
OS : VMware CentOS 6.8 x86_64
snort : 2.9.9.0
daq : 2.0.6
snort rule : 2962(registered)
4-1. 라이브러리 설치
라이브러리를 다운받아 준다.
1 2 3 4 | yum install -y mysql mysql-server mysql-bench mysql-devel httpd php php-mbstring php-devel php-mysql php-pear gcc php-gd gd glib2-devel gcc g++ flex bison zlib tcpdump apache2 pcre* libxml2-devel vimenhanced* zlib-devel nbtscan libpcap yum -y groupinstall "Development Tools" | cs |
이후 구글에 libdnet을 검색하여 libdnet-1.12.tgz, libdnet-1.12-6.el6.x86_64.rpm, libdnet-devel-1.12-6.el6.x86_64.rpm 을 받아준다.
1 2 3 4 5 6 | tar -zxvf libdnet-1.12.tgz cd libdnet-1.12 ./configure cd .. rpm -ivh libdnet-1.12-6.el6.x86_64.rpm rpm -ivh libdnet-devel-1.12-6.el6.x86_64.rpm | cs |
다음 명령어로 각 파일을 설치한다.
4-2. daq, snort 설치
1 2 3 4 5 6 7 8 9 10 11 | wget https://www.snort.org/downloads/snort/daq-2.0.6.tar.gz wget https://www.snort.org/downloads/snort/snort-2.9.9.0.tar.gz cd /usr/local/src/ tar -zxvf /home/test/Desktop/daq-2.0.6.tar.gz tar -zxvf /home/test/Desktop/snort-2.9.9.0.tar.gz cd daq-2.0.6/ ./configure make && make install cd .. cd snort-2.9.9.0/ ./configure --enable-sourcefire && make && sudo make install | cs |
4-3. rule 설치, user 생성
1 2 3 4 5 6 7 8 9 10 11 | cd /etc mkdir snort cd snort cp /usr/local/src/snort-2.9.9.0/etc/* . tar -zxvf /home/test/Desktop/snortrules-snapshot-2962.tar.gz touch /etc/snort/rules/white_list.rules /etc/snort/rules/black_list.rules groupadd -g 40000 snort useradd snort -u 40000 -d /var/log/snort -s /sbin/nologin -c SNORT_IDS –g snort cd /etc/snort chown -R snort:snort * chown -R snort:snort /var/log/snort | cs |
4-4. conf 설정
1 | vi /etc/snort/snort.conf | cs |
자기가 모니터할 네크워크를 적어준다. (ex -192.168.1.0/24)
그 후 /RULE_PATH를 검색해 이동해준다.
위의 rules위치를 맞게 고쳐준다.
4-5. 권한 설정
권한은 755로 해도 무방해보인다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | cd /usr/local/src chown -R snort:snort daq-2.0.6 chmod -R 700 daq-2.0.6 chown -R snort:snort snort-2.9.9.0 chmod -R 700 snort-2.9.9.0 chown -R snort:snort snort_dynamicsrc chmod -R 700 snort_dynamicsrc cd /usr/local/src/snort-2.9.9.0/rpm cp snortd /etc/init.d/snort chkconfig --add /etc/init.d/snort cd /usr/sbin ln -s /usr/local/bon/snort snort cd /var/log chmod 755 snort chown -R snort:snort snort cd /usr/local/lib chown -R snort:snort snort* chown -R snort:snort snort_dynamic* chown -R snort:snort pkgconfig chmod -R 700 snort* chmod -R 700 pkgconfig cd /usr/local/bin chown -R snort:snort daq-modules-config chown -R snort:snort u2* chmod -R 700 daq-modules-config chmod 700 u2* cd /etc chown -R snort:snort snort chmod -R 700 snort | cs |
4-6. snort 실행
1 2 | cd /usr/local/bin ./snort -T -i eth0 -u snort -g snort -c /etc/snort/snort.conf | cs |
만약 ERROR: /etc/snort/snort.conf(253) Could not stat dynamic module path "/usr/local/lib/snort_dynamicrules": No such file or directory. 한 에러가 발생하면 디렉토리를 만들어 준다.
1 2 3 | mkdir -p /usr/local/lib/snort_dynamicrules chown -R snort:snort /usr/local/lib/snort_dynamicrules chmod -R 700 /usr/local/lib/snort_dynamicrules | cs |
성공
//참고
https://s3.amazonaws.com/snort-org-site/production/document_files/files/000/000/091/original/snort-centos6x-7x-298x.pdf?AWSAccessKeyId=AKIAIXACIED2SPMSC7GA&Expires=1489656188&Signature=iaDhrzaJxoHVS0olMrMY5JTiyFA%3D
https://www.youtube.com/watch?v=-aQj1s_mPkY
https://brunch.co.kr/@leesmain/34
1. PEDA
PEDA는 'PEDA - Python Exploit Development Assistance for GDB'으로 BlackHat에서 2012년에 공개되었다.
기존 GDB의 기능을 확장하여 리눅스 상의 Exploit을 도와준다.
사용요건
1. Linux
2. GDB 7.x (하지만 GDB 7.7버전에서는 동작하지 않으니 버전을 낮추어야 한다.)
3. Python 2.6 이상 (3.x는 안된다.)
4. Utilities: nasm, readelf, objdump
2. 설치
2-1. wget 명령어로 압축파일을 받아준다.
# wget http://ropshell.com/peda/peda.tar.gz
2-2. 압축을 풀어준다.
$ tar zxvf peda.tar.gz
2-3. PEDA를 GDB에 연동시킨다.
$ echo “source ~/peda/peda.py” >> ~/.gdbinit
이제 .gdbinit파일이 존재하는 위치에서 GDB를 실행하면 PEDA가 실행되어야 한다.
하지만 PEDA가 실행이 되지 않을 때가 있다.
3. 실행이 안될 시
GDB 7.7버전에서는 PEDA가 실행이 되지 않는다. GDB 7.7이 Python 3을 사용하기 때문이다.
3-1. synaptic으로 GDB 버전 낮추기
$ apt-get install synaptic
여기서 왼쪽 위의 Settings - Repositories - Other Software에서
deb http://kr.archive.ubuntu.com/ubuntu/ precise main 를 추가해 준다.
이후 창읃 닫고 Reload를 눌러준다.
오른쪽 위의 검색창에서 GDB를 검색해 선택한 후
Package - Force Version을 누른 후 7.4버전으로 바꾸어준다.
선택한 후 Apply를 눌러 적용해 준다.
적용 후 설치된 버전이 7.4로 바뀐 것을 확인 할 수 있다.
이후 Package - Lock Version으로 버전을 고정해도 되고 안해도 된다.
다시 GDB를 실행해보면 PEDA가 동작하는 것을 볼 수 있다.
* 만약 Linux의 Python 버전이 2.6.x 미만, 3이상이면 Python을 맞는 버전으로 재설치를 해준다.
참고
- https://pypi.python.org/pypi/peda/1.0
- http://kblab.tistory.com/220 //GDB 버전
- https://hexa-unist.github.io/2015/02/25/PEDA-Introduction-Installation/ //Python 버전
'System' 카테고리의 다른 글
linux 메모리 보호 기법 해제(우분투) (0) | 2015.08.01 |
---|
보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.
보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.
보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.
보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.
보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.
보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.
Sublime Text 2 error (UnicodeDecodeError)
sublime Text2를 새로 설치하고 테마와 package를 설치한 뒤 테스트를 하는데 아무런 반응이 나타나지 않았다.
ctrl + `를 이용해 보니
Running python -u C:\Users\absinthe\Desktop\파일\test.pyTraceback (most recent call last):File ".\sublime_plugin.py", line 337, in run_File ".\exec.py", line 154, in runFile ".\exec.py", line 45, in __init__UnicodeDecodeError: 'ascii' codec can't decode byte 0xc7 in position 9: ordinal not in range(128)
와 같은 내용이 나타나 있었다.
Windows 8.1기준으로 C:\Users\username\AppData\Roaming\Sublime Text 2\Packages 으로 가서 exec.py의 45번째 줄의
os.path.expandvars(v).encode(sys.getfilesystemencoding()) 부분을
os.path.expandvars(v.decode(sys.getfilesystemencoding())).encode(sys.getfilesystemencoding())으로 바꾸어 준다.
//다음날 다시 해보니 다른 에러가 나타났다. 파일을 python폴더에 넣으니 에러가 사라진것을 보아 경로중 인코딩이 되지 않는 부분이 있는 것 같다.
Traceback (most recent call las):File ".\sublime_plugin.py", line 337, in run_File ".\exec.py", line 155, in runFile ".\exec.py", line 49, in __init__File ".\subprocess.py", line 633, in __init__File ".\subprocess.py", line 842, in _execute_childUnicodeEncodeError: 'ascii' codec can't encode characters in position 19-20: ordinal not in range(128)
http://stackoverflow.com/questions/14715918/sublime-text-2-build-tools-nothing-happens
--자꾸 까먹는 brogrammer 테마
{
"theme": "Brogrammer.sublime-theme",
"color_scheme": "Packages/Theme - Brogrammer/brogrammer.tmTheme"
}
'Manage' 카테고리의 다른 글
xe 로그인 옵션 및 파일 업로드 에러 (0) | 2015.08.15 |
---|
패킷 분할 방법
1. editcap
와이어샤크를 설치할 때 같이 설치되는 파일로 와이어샤크가 설치된 폴더에 들어가면 있는 걸 볼 수 있다.
Editcap 1.12.4 (v1.12.4-0-gb4861da from master-1.12) Edit and/or translate the format of capture files. See http://www.wireshark.org for more information. Usage: editcap [options] ... <infile> <outfile> [ <packet#>[-<packet#>] ... ] <infile> and <outfile> must both be present. A single packet or a range of packets can be selected. Packet selection: -r keep the selected packets; default is to delete them. -A <start time> only output packets whose timestamp is after (or equal to) the given time (format as YYYY-MM-DD hh:mm:ss). -B <stop time> only output packets whose timestamp is before the given time (format as YYYY-MM-DD hh:mm:ss). Duplicate packet removal: -d remove packet if duplicate (window == 5). -D <dup window> remove packet if duplicate; configurable <dup window> Valid <dup window> values are 0 to 1000000. NOTE: A <dup window> of 0 with -v (verbose option) is useful to print MD5 hashes. -w <dup time window> remove packet if duplicate packet is found EQUAL TO OR LESS THAN <dup time window> prior to current packet. A <dup time window> is specified in relative seconds (e.g. 0.000001). NOTE: The use of the 'Duplicate packet removal' options with other editcap options except -v may not always work as expected. Specifically the -r, -t or -S options will very likely NOT have the desired effect if combined with the -d, -D or -w. Packet manipulation: -s <snaplen> truncate each packet to max. <snaplen> bytes of data. -C [offset:]<choplen> chop each packet by <choplen> bytes. Positive values chop at the packet beginning, negative values at the packet end. If an optional offset precedes the length, then the bytes chopped will be offset from that value. Positive offsets are from the packet beginning, negative offsets are from the packet end. You can use this option more than once, allowing up to 2 chopping regions within a packet provided that at least 1 choplen is positive and at least 1 is negative. -L adjust the frame length when chopping and/or snapping -t <time adjustment> adjust the timestamp of each packet; <time adjustment> is in relative seconds (e.g. -0.5). -S <strict adjustment> adjust timestamp of packets if necessary to insure strict chronological increasing order. The <strict adjustment> is specified in relative seconds with values of 0 or 0.000001 being the most reasonable. A negative adjustment value will modify timestamps so that each packet's delta time is the absolute value of the adjustment specified. A value of -0 will set all packets to the timestamp of the first packet. -E <error probability> set the probability (between 0.0 and 1.0 incl.) that a particular packet byte will be randomly changed. Output File(s): -c <packets per file> split the packet output to different files based on uniform packet counts with a maximum of <packets per file> each. -i <seconds per file> split the packet output to different files based on uniform time intervals with a maximum of <seconds per file> each. -F <capture type> set the output file type; default is pcapng. An empty "-F" option will list the file types. -T <encap type> set the output file encapsulation type; default is the same as the input file. An empty "-T" option will list the encapsulation types. Miscellaneous: -h display this help and exit. -v verbose output. If -v is used with any of the 'Duplicate Packet Removal' options (-d, -D or -w) then Packet lengths and MD5 hashes are printed to standard-error. | cs |
이런식으로 옵션에 맞게 패킷이 잘린다.
2. 패킷을 초 단위로 분할
참고 : http://apollo89.com/wordpress/?p=6900
'Network' 카테고리의 다른 글
CentOS 6.8 snort 설치 (0) | 2017.03.09 |
---|