Linux/모의해킹

웹 서버 접속 룰 탐지하기

GGkeeper 2022. 1. 14. 01:09

실습> 웹서버 접속 룰 탐지하기

ipvar HOME_NET 192.168.108.100/24  : snort에서 탐지할 목적지 IP주소 192.168.108.100
ipvar EXTERNAL_NET any  : snort에서 탐지할 출발지 IP주소 any(모든 IP주소)
ipvar HTTP_SERVERS $HOME_NET : HOME_NET에 설정된 목적지 IP주소

-- /etc/snort/snort.conf 에 설정된 내용 --
ipvar HOME_NET 192.168.108.100/24  
ipvar EXTERNAL_NET any 
ipvar HTTP_SERVERS $HOME_NET

1. 룰 추가
local.rules 파일에 http 탐지 룰을 추가한다.
Victim1# vi /etc/snort/rules/local.rules
-- /etc/snort/rules/local.rules --
alert icmp any any -> any any (msg:"ICMP ping test"; sid: 1000001;)
alert tcp  $EXTERNAL_NET any -> $HTTP_SERVERS 80 (msg:"WEB test"; content:"GET ";sid: 1000002;)
-- /etc/snort/rules/local.rules --

2. snort 실행
쉘스크립트를 작성해서 snort를 시작한다.
스크립트 파일명 : snort.sh
Victim2# vi snort.sh
# cat snort.sh
#!/bin/sh
# 파일명 : snort.sh
# 프로그램 설명 : snort를 실행하는 스크립트
# 작성자 : KH
# 작성일 : 2021. 08. 16. (월) 17:26:25 KST

interface="-i ens33"
console="-A console"
conf="-c /etc/snort/snort.conf"
user="-u snort -g snort"
option="-q $console $interface $user $conf"
snort $option

Victim2# chmod 755 snort.sh
Victim2# ./snort.sh

다른 터미널에서 확인하면 snort 사용자로 snort가 실행된 것을 확인할 수 있다.
Victim2# ps aux | grep snort
root      22077  0.0  0.1 113280  1388 pts/1    S+   17:38   0:00 /bin/sh ./snort.sh
snort     22078  0.6  4.6 136416 45996 pts/1    Sl+  17:38   0:00 snort -q -A console -i ens33 -u snort -g snort -c /etc/snort/snort.conf
root      22081  0.0  0.1 116972  1020 pts/0    R+   17:38   0:00 grep --color=auto snort

3. 웹서버 접속
Attacker/Host OS 에서 Victim2 웹서버로 접속한다.
http://192.168.108.100

4. 로그 확인
콘솔에 로그를 확인한다.

Attacker에서 웹서버로 접속하면 아래처럼 로그가 기록된다.
08/16-17:30:27.241180  [**] [1:1000002:0] WEB test [**] [Priority: 0] {TCP} 192.168.108.102:43052 -> 192.168.108.100:80

Host OS에서 웹서버로 접속하면 아래처럼 로그가 기록된다.
08/16-17:31:27.743203  [**] [1:1000002:0] WEB test [**] [Priority: 0] {TCP} 192.168.108.1:1028 -> 192.168.108.100:80

'Linux > 모의해킹' 카테고리의 다른 글

피해자(Victim) 사이트 생성 * proxy 실습에 사용 *  (0) 2022.01.19
모의해킹 체크리스트  (0) 2022.01.19
snort rule 설정  (0) 2022.01.14
snort rule 설정 시 주의할 점  (0) 2022.01.13
-A console 사용하기  (0) 2022.01.13