DAY38
DAY38

서버 모니터링 시스템 설치하기


http://st.kr index.html을 수정한다.
st.kr > /var/www/html > root
index.html
	< a href="web1.st.kr">web1.st.kr
	< a href="web2.st.kr">web2.st.kr
	< a href="word.st.kr">word.st.kr
	< a href="dvwa.st.kr">dvwa.st.kr
	< a href="ci4.st.kr">ci4.st.kr
	< a href="lms.st.kr">lms.st.kr
	< a href="shop.st.kr">shop.st.kr
	< a href="sir.st.kr">sir.st.kr

nat설정
dns확인 :168.126.63.1

netdata 설치
sudo apt -y install netdata
nano /etc/netdata/netdata.conf
	bind socket to IP = 0.0.0.0으로 수정
sudo systemctl restart netdata
netstat -ant | grep 19999
virtualbox 포트포워딩 19999 열어주기
192.168.0.214:19999/ 접속

awstats 설치
nano /etc/awstats/awstats.conf
	LogFile="/var/log/apache2/access.log" > st.kr 로그이므로 나중에 변경
	LogFormat=1
	SiteDomain="st.kr"
	HostAliases="locatlhost 127.0.0.1 REGEX[^.*www\.st\.kr$]"
nano /etc/apache2/conf-available/awstats.conf
	Alias /awstatsicon /usr/shae/awstats/icon/
	Alias /awstatsclasses /usr/share/java/awstats/
	< Directory /usr/share/awstats>
		Options FollowSymLinks
		AllowOverride None
		# access permission for your local network
		Require ip 127.0.0.1 0.0.0.0/24
	< /Directory>
a2enconf awstats
a2enmod cgid
systemctl restart apache2
/usr/share/awstats/tools/update.sh 
/usr/share/awstats/tools/buildstatic.sh 
=> 접속: 192.168.0.214/cgi-bin/awstats.pl

그외 설치
sudo apt -y install sysstat
sudo apt -y install prometheus prometheus-node-exporter
apt update
sudo apt -y install aide

용량 확보 하기

df -h
저장소 > 연결추가 > 하드디스크
fdisk -l
fdisk /dev/sdf
mkfs.ext4 /dev/sdf1
vgs 로 여유공간 확인
pvcreate /dev/sdf1
	wipe it? yes!
vgextend /dev/ubuntu-vg /dev/sdf1
lvextend -L +25G /dev/ubuntu-vg/ubuntu-lv
resize2fs /dev/ubuntu-vg/ubuntu-lv
df -h

백업 지우기
rm -rf *.tar.gz

* : 와일드 카드
tripwire 설치 sudo apt update sudo apt-get install tripwire ok > yes > yes > yes >123456/123456/123456/123456 > ok 설치완료 nano /etc/tripwire/twcfg.txt reportlevel =3 man twadmin twadmin -m F -c tw.cfg -S site.key twcfg.txt (123456)

nano twpolmake.pl


아래 내용 붙이기
#!/usr/bin/perl
# Tripwire Policy File customize tool
# ----------------------------------------------------------------
# Copyright (C) 2003 Hiroaki Izumi
# 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.
# ----------------------------------------------------------------
# Usage:
#     perl twpolmake.pl {Pol file}
# ----------------------------------------------------------------
#
$POLFILE=$ARGV[0];

open(POL,"$POLFILE") or die "open error: $POLFILE" ;
my($myhost,$thost) ;
my($sharp,$tpath,$cond) ;
my($INRULE) = 0 ;

while (< POL>) {
    chomp;
    if (($thost) = /^HOSTNAME\s*=\s*(.*)\s*;/) {
        $myhost = `hostname` ; chomp($myhost) ;
        if ($thost ne $myhost) {
            $_="HOSTNAME=\"$myhost\";" ;
        }
    }
    elsif ( /^{/ ) {
        $INRULE=1 ;
    }
    elsif ( /^}/ ) {
        $INRULE=0 ;
    }
    elsif ($INRULE == 1 and ($sharp,$tpath,$cond) = /^(\s*\#?\s*)(\/\S+)\b(\s+->\s+.+)$/) {
        $ret = ($sharp =~ s/\#//g) ;
        if ($tpath eq '/sbin/e2fsadm' ) {
            $cond =~ s/;\s+(tune2fs.*)$/; \#$1/ ;
        }
        if (! -s $tpath) {
            $_ = "$sharp#$tpath$cond" if ($ret == 0) ;
        }
        else {
            $_ = "$sharp$tpath$cond" ;
        }
    }
    print "$_\n" ;
}
close(POL) ;
perl twpolmake.pl twpol.txt > twpol.txt.new twadmin -m P -c tw.cfg -p tw.pol -S site.key twpol.txt.new tripwire -m i -s -c tw.cfg 오류시 ls -l /var/lib/tripwire/ (twd 파일 생성 확인) 파일 생성 문제 아닐경우 tw.cfg 다시 생성 sudo twadmin --create-cfgfile -S /etc/tripwire/site.key /etc/tripwire/twcfg.txt tripwire -m c -s -c /etc/tripwire/tw.cfg tripwire -m c -s -c /etc/tripwire/tw.cfg > tw_report.txt tw_report.txt 확인해보기 참고사이트 https://www.server-world.info/en/note=?os=Ubuntu_18.04&p=tripwire

Bootstrap Example

무결성 검증 프로그램 설치


http://st.kr
웹 방화벽 mod_security (Web Application Firewall) 설치하기
sudo apt -y install libapache2-mod-security2 (방화벽 설치)
sudo apt -y install roundcube roundcube-mysql (웹메일 설치) (이미 설치됨)

https://st.kr
self https: 자체 인증서 (이미 설치됨)
sudo apt -y install openssl

진짜 서버 운영시!!
공인 인증서 : 대행 업체 (letsencrypt.org)
sudo apt -y install certbot
cerbot certonly --webroot -w /home/web1/public_html -d web1.st.kr

zabbix 설치하기
wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-3+ubuntu22.04_all.deb 
dpkg -i zabbix-release_6.0-3+ubuntu22.04_all.deb 

apt update
sudo apt update && sudo apt upgrade -y

apt -y install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent2 php-mysql php-gd php-bcmath php-net-socket 


Bootstrap Example

시나리오2 분석 일지 작성


시나리오2
1) 컴퓨터는 언제 부팅되었는가?
2025-02-08 14:42

2) 사용자는 누구인가?
manager

3) 관리자는 몇번 시스템에 로그인 했는가?
레지스트리 확인

4) 해커가 정보 수집을 하는 시간은 언제인가?
netdata 공격 시점 확인


5) 무슨 정보를 수집하려고 했는가?
> 패킷 분석하기(방화벽 네트워크 확인)
192.168.0.223 > 
naver.com
google.com
생성

/etc/hosts
/etc/bind/named.conf.default-zones
/etc/bind
cp db.local naver.com.zone(google.com.zone)

tar xvzf page.tar.gz (압축해제)
페이지 만들어짐 


방화벽 > 웹 보호 
> 웹 필터링 > inside 추가
>웹 필터 프로필 >필터 동작 > 필터 동작 추가 > 전부 차단 > 이 웹사이트를 차단
	도메인: google.com(naver.com)
>웹 필터 프로필 >필터 동작 > 필터 동작 추가>다운로드>차단된 파일 확장자> exe, .exe추가

6) 공격을 했는가?

7) 공격을 했다면 무슨 흔적들이 남는가?
8) 웹서버에 파일이 업로드 되었는가?
9) 관리자가 파일을 다운로드 받았는가?


시나리오 분석 정리표 프린트 확인

ping
nmap
attack.py