18일차

18일차

홈으로 돌아가기



계정을 일시적으로 락걸기
usermod -L username
	-U	(해제)

홈페이지 리스팅 막기 
<Directory /home/competition/public_html/>
Options none
</Directory>

특정 아이피만 막기
<Directory "">
	Order Allow,Deny
	Allow from all
	Deny from 100.100.100.1
</Directory

root계정에 대한 자동 로그아웃
vi /root/.bashrc
export TMOUT=180
source /root/.bashrc

특정 아이피 메일 못보내게 하기
vi /etc/mail/access
100.100.100	REJECT
makemap hash /etc/mail/access < /etc/mail/access
systemctl restart sendmail
systemctl restart dovecot

공격의 시작
ping shop.st.kr (icmp)
100.100.100.1 쉽게 노출
hping3 shop.st.kr -S -i u50 -c 5
hping3 shop.st.kr -a st.kr -S -c 100 -u 5
hping3 125.246.95.254 -a 125.246.95.254 -S -c 10
hping3 --flood --rand-source st.kr

nikto -host shop.st.kr
shop의 로그에서 확인 가능함
wpscan --url shop.st.kr -U user.txt -P passwd.txt
미션1
shop 로그에 기록된 access.log 데이터에 100.100.100.1은 총 몇번 접속 시도 했는지 계산하시오
ftp로 로그 받아오기
win에서 cmd 
ftp 10.0.2.15 
cd public_html 
cd logs 
get access.log
bye
공격후에 대한 로그 확보
미션2
shop에 대한 웹 파일과 데이터베이스 백업후 관리자 PC에 저장

미션2
해커가 실행했던 명령어가 무엇인지 알수 있는가?
php.st.kr/monitor.php에서 확인가능하도록 하려면?

미션3
복원작업
adduser shop
tar xzvf backup.tar.gz

1. apm 설치
apt install lamp-server^
a2enmod userdir
apt install php8.3-fpm
a2enmod proxy_fcgi setenvif
a2enconf php8.3-fpm
systemctl restart php8.3-fpm apache2
/etc/apache2/sites-availablee/hosting.conf 생성
<VirtualHost *:80>
	DocumentRoot /home/st/public_html
	ServerName st.kr
	ServerAdmin st@st.kr
	ErrorLog /home/st/public_html/logs/error.log
	CustomLog /home/st/public_html/logs/access.log combined
</virtualHost>
a2ensite hosting
systemctl restart apache2
chmod 711 $HOME
chmod 755 ~/public_html

2.dns설치
apt install bind9
/etc/hosts에 10.0.2.15 st.kr추가
named.conf.default.zone에 로컬밑에 st.kr추가
cp db.local st.kr.zone
st.kr.zone 수정
@       IN      NS      ns.st.kr.
@       IN      A       125.246.95.152
ns      IN      A       125.246.95.152
www     IN      A       125.246.95.152
mail    IN      A       125.246.95.152
php     IN      A       125.246.95.152
study   IN      A       125.246.95.152
*       IN      A       125.246.95.152
/etc/resolv.conf 변경
systemctl restart named

3.DB복구
create database shop;
create user shop@localhost identified by '123456';
grant all on shop.* to shop@localhost;
flush privileges;
mysql -u shop -p shop < backup.sql

create database dvwa;
create user dvwa@localhost identified by '123456';
grant all on dvwa.* to dvwa@localhost;
flush privileges;