728x90

[1,2교시 - 데이터베이스 보안]

 

 


[3,4,5교시 - 시스템 보안 운영]

/ 과목
- 시스템 보안 구축
- 시스템 보안 운영 ~ 6/29
- 정보시스템 진단
- 모의해킹
- 보안 운영관리
- 보안로그 분석
- SW개발 보안 구축
- 애플리케이션 보안 운영 ~2/3

/ FTP
- File Transfer Protocol, tcp 사용
- 20/tcp 데이터전송포트
- 21/tcp 컨트롤 포트
* 22/tcp sshd Openssh-server
* 443/tcp ssl Secure socket Layer https

/ FTP 패키지
- vsFTPd(very secure)
- sFTP : 22/tcp포트를 사용한다. 
- scp : 22/tcp 포트를 사용한다.

/ 버전확인
- 우분투 : cat /etc/issue
- centOS : cat /etc/*release*

 

/ 커널 버전 확인
- cat /proc/version
- uname -r
- uname -a

/ vFTPd 설치
# rpm -qa |  grep vsftpd : 확인
# yum list vsftpd : 확인
# yum -y install vsftpd

- 설치 확인
# yum list installed | grep vsftpd

 

/ vsftpd 실행
# systemctl start vsftpd
# systemctl enable vsftpd
# systemctl status vsftpd : 확인

# ps -ef | grep vsftpd

# netstat -antp | grep vsftpd

- 설정파일 찾기
# rpm -qc vsftpd
- 설정파일 : /etc/vsftpd/vsftpd.conf

- 설치된 패키지의 경로
# rpm -ql vsftpd

/ vsftpd 방화벽 설정
# firewall-cmd --permanent --add-port=20/tcp
# firewall-cmd --permanent --add-port=21/tcp
# firewall-cmd --permanent --add-service=ftp
# firewall-cmd --reload

# firewall-cmd --list-all

- 호스트pc에서 tcping으로 확인
- cmd에서 'tcping 192.168.111.101 21'


/ vsftpd 설정파일
# rpm -qc vsftpd

# ls -al /etc/vsftpd/

- ftpusers :  무엇인지 조사

- user_list : 무엇인지 조사


# vi vsftpd.conf
- anonymous_enable=YES : 익명으로 접근 할 수 있는지 여부(안할때는 주석처리 함)
- local_enable=YES : 무엇인지 조사
- write_enable=YES : 무엇인지 조사
- local_umask=022 : 무엇인지 조사
- anon_upload_enable=YES : 무엇인지 조사
- anon_mkdir_write_enable=YES : 무엇인지 조사
- xferlog_enable=YES : fpt로그 기록 여부
- connect_from_port_20=YES

# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
xferlog_file=/var/log/xferlog
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode. The vsftpd.conf(5) man page explains
# the behaviour when these options are disabled.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=NO
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

- 설정파일을 수정 한 수 restart를 한번 해준다.
# systemctl restart vsftpd

/ vsftpd의 설치 위치
# rpm -ql vsftpd


- pub폴더의 권한을 보면 other유저의 권한은 쓰기(r), 실행(x)권한만 있다.
- 해서 쓰기 권한을 줘야만 ftp로 파일을 업로드할 수 있다.


- other유저에 스기 권한을 주기
# chmod o+w pub

- pub폴더의 소유를 root에서 other유저인 ftp로 변경한다.
# chown ftp.ftp pub
# chown ftp:ftp pub


- ftp로 접속했는데 아무파일도 없으면 내가 어디에 있는것인지 잘 모를 수 있으므로 임의의 파일을 만든다.
# ./pub
# touch vsftpd_server


- 임의의 내용 넣어보기
# echo blabla > vsftpd_server : 내용 변경
# echo blabla >> vsftpd_server : 내용 추가

 

/ 파일질라 설치
- https://filezilla-project.org/download.php 접속 후 초록 버튼 말고 밑에 있는 'Show additional download options'클릭

- Windows환경에서 설치 시 FileZilla_3.59.0_win64-setup.exe클릭

- 설치는 그냥 넥스트 넥스트 하면 된다.

 

/ 파일질라 실행
- 익명접속 시 로그인 유형을 '일반'으로 놓고 사용자에 'anonymous'으로 놓으면 된다.


- 확인

- 접속 성공


/ ftp 업로드 시도
- pub파일 안쪽으로는 파일을 업로드하거나 폴더를 생성할 수 있는데, 바깥쪽에는 업로드하거나 파일 생성이 되지 않는다.
- pub폴더 안의 파일이나 폴더 삭제는 되지 않는다.

 

/ vsftpd 로그확인
- 위치 및 파일명 : /var/log/xferlog
# cat /var/log/xferlog

- 파일명 뒤에 a : 전송모드가 아스키 모드였을 때(아스키는 cat으로 읽을 수 있는것, b는 바이너리 모드. 바이너리 모드는 cat으로 읽을 수 없다.)
- '_'(언더바)뒤의 i : input의 i이다. 클라이언트에서 서버측으로 업로드 하였을때
- '_'(언더바)뒤의 o : output의 o이다. 클라이언트에서 다운로드 받았을때
- 그 뒤의 알파벳
    > a : 익명계정
    > g : 패스워드 인증을 거친 익명계정
    > r : 패스워드로 인증된 사용자
- 물음표 : 익명
- 물음표뒤의 ftp : ftp방식
- 그 뒤는 계정이름
- * 뒤의 i or c
    > i : 작업 미완료(Incomplete)
    > c : 작업완료(complete)

/ root 연결 시도
- 계정을 root / password로 입력하고 접속해보기

- 서버에서 설정을 다시 해줘야 한다.
- ftpusers, user_list에서 root를 주석처리 해준다.
# vi /etc/vsftpd/ftpusers
# vi /etc/vsftpd/user_list
# systemctl restart vsftpd

- 파일질라에서 다시 root / password로 접속해본다.

- root계정이기 때문에 업로드/다운로드가 자유롭게된다.

/ 로그확인
* w, who로는 보이지 않는다.
* netstat에서는 접속을 확인할 수 있다.
* ps -ef | grep vsftpd
# cat /var/log/xferlog

 

​/ FTP 모드(능동 vs 수동)
- 능동모드의 주체는 서버이다.
- 수동모드의 주체는 클라이언트다.
- 방화벽이 있을때 수동모드를 쓴다.

 

 

728x90

+ Recent posts