티스토리 뷰
시스템 진단메세지 권한 문제와 링크파일들 접근 권한 문제에 대하여
1 시스템 진단메세지 일반유저들 사용 못하게 하기
# 우선 나의 이름과 기존 제한 변수 확인, 0인경우 일반 유저도 진단메세지를 읽을 수 있게 된다. 문제가 있을 수 있다. 시스템에 어떤 장치가 장착되어있고 시스템에 어떤 변경점이 있는지 모두 읽을 수 있음.
[root@localhost ~]# id -un
root
[root@localhost ~]# cat /proc/sys/kernel/dmesg_restrict
0
# 일반 유저로 변경해보고 dmesg를 수행해보았다.
[root@localhost ~]# su guru
[guru@localhost root]$ dmesg
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 3.10.0-514.26.1.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Thu Jun 29 16:05:25 UTC 2017
[ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-514.26.1.el7.x86_64 root=/dev/mapper/cl-root ro crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet LANG=ko_KR.UTF-8
[ 0.000000] e820: BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009
...
# 다시 root 계정으로 나와 sysctl을 활용하여 시스템 변수를 바꿔보았다.
[guru@localhost root]$ exit
exit
[root@localhost ~]# sysctl -w kernel.dmesg_restrict=1
kernel.dmesg_restrict = 1
# 파일 권한을 확인해보면 파일은 여전히 owner, group, other에게 모두 readable하다. 그러나 일반 유저로 접속하면 dmesg 수행 불가능.
[root@localhost ~]# ls -l /dev/kmsg
crw-r--r--. 1 root root 1, 11 Jul 17 17:03 /dev/kmsg
[root@localhost ~]# su guru
[guru@localhost root]$ dmesg
dmesg: read kernel buffer failed: Operation not permitted
[guru@localhost root]$ cat /dev/kmsg
cat: /dev/kmsg: Operation not permitted
2 링크 보호하기 / Link Protection
# systcl 을 활용하여 하드링크, 심볼릭링크 의 값을 파일에 리디렉트 출력하였다. 1이라면, Link protection이 활성화 되어있으며 다른 유저가 링크 파일을 참조할 수없다.
[root@localhost ~]# sysctl fs.protected_{hard,sym}links > /etc/sysctl.d/50-link.conf
[root@localhost ~]# cat /etc/sysctl.d/50-link.conf
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
# 파일을 line by line 으로 패턴매칭하는 sed를 이용하여 설정값을 0으로 바꿔보았다.
[root@localhost ~]# sed -i s/1/0/ /etc/sysctl.d/50-link.conf
[root@localhost ~]# cat /etc/sysctl.d/50-link.conf
fs.protected_hardlinks = 0
fs.protected_symlinks = 0
# sysctl 서비스를 재시작하고 커널 옵션이 잘 변경이 되었는지 확인하였다.
[root@localhost ~]# systemctl restart systemd-sysctl
[root@localhost ~]# sysctl fs.protected_{hard,sym}links
fs.protected_hardlinks = 0
fs.protected_symlinks = 0
# guru 사용자로 심볼릭 링크 파일을 생성해보았다.
# link : 이름 경로 다른 파일/디렉토리가 늘 같은 내용을 참조하게
# hard link :inode number 공유(같은파티션에서만 공유)
# symbolic link : 원본 파일의 경로를 따라가는 파일 (=윈도우 바로가기)
[root@station16 ~]# su -c 'ln -s /etc/passwd /tmp/passwd.guru' guru
[root@station16 ~]# ls -l /tmp/passwd
ls: cannot access /tmp/passwd: No such file or directory
[root@station16 ~]# ls -l /tmp/passwd.guru
lrwxrwxrwx. 1 guru guru 11 Jul 18 09:56 /tmp/passwd.guru -> /etc/passwd
추후 작성해야함 ... 어제랑 내용이 겹쳐서 vm에서 햇던거랑 메인에서한거랑 혼합된듯
3 Dropping VM Caches
4 ICMP 브로드캐스트 응답 설정하기
# 브로드 캐스트 핑에 응답할지 안할지 결정하는 변수, 1이면 응답안함이다. 응답함으로 설정할 것이다.
[root@station16 ~]# sysctl net.ipv4.icmp_echo_ignore_broadcasts
net.ipv4.icmp_echo_ignore_broadcasts = 1
[root@station16 ~]# sysctl net.ipv4.icmp_echo_ignore_broadcasts=0
net.ipv4.icmp_echo_ignore_broadcasts = 0
#ip addr 명령어를 통해 브로드캐스트 아이피를 확인하고 핑을 날리면 안된다.
[root@station16 ~]# sysctl net.ipv4.icmp_echo_ignore_broadcasts
net.ipv4.icmp_echo_ignore_broadcasts = 0
[root@station16 ~]# ping -b -c 3 59.29.224.225
PING 59.29.224.225 (59.29.224.225) 56(84) bytes of data.
From 59.29.224.102 icmp_seq=1 Destination Host Unreachable
From 59.29.224.102 icmp_seq=2 Destination Host Unreachable
From 59.29.224.102 icmp_seq=3 Destination Host Unreachable
--- 59.29.224.225 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 1999ms
pipe 3
# 다시 설정을 되돌리고 핑을 확인해보았다.
[root@station16 ~]# sysctl net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.icmp_echo_ignore_broadcasts = 1
[root@station16 ~]# ping -b -c 3 59.29.224.255
WARNING: pinging broadcast address
PING 59.29.224.255 (59.29.224.255) 56(84) bytes of data.
64 bytes from 59.29.224.120: icmp_seq=1 ttl=64 time=0.213 ms
64 bytes from 59.29.224.115: icmp_seq=1 ttl=64 time=0.351 ms (DUP!)
64 bytes from 59.29.225.254: icmp_seq=1 ttl=255 time=0.382 ms (DUP!)
64 bytes from 59.29.224.130: icmp_seq=1 ttl=64 time=0.417 ms (DUP!)
64 bytes from 59.29.224.116: icmp_seq=1 ttl=64 time=0.486 ms (DUP!)
64 bytes from 59.29.224.218: icmp_seq=1 ttl=64 time=1.15 ms (DUP!)
64 bytes from 59.29.224.216: icmp_seq=1 ttl=64 time=1.21 ms (DUP!)
'IoT 과정' 카테고리의 다른 글
GRUB 관련 (0) | 2017.07.18 |
---|---|
SYSTEMD OVERVIEW (0) | 2017.07.18 |
LINUX KERNEL & DEVICES (0) | 2017.07.17 |
Enterprise Linux System - Adnministration 시작 (0) | 2017.07.17 |
Managing Input and Output (0) | 2017.07.07 |
- Total
- Today
- Yesterday
- 아레나시뮬레이션
- 이산 수학
- 로젠
- 명제논리
- 대규모 시스템 설계 기초
- 시뮬레이션
- arena simulation
- 자바스크립트 예제
- javascript
- Grafana
- paul wilton
- 아레나
- 백준
- Discrete Mathematics
- Simulation
- flutter
- rosen
- 이산수학
- grafana cloud
- beginning javascript
- 데이터 중심 애플리케이션 설계
- 가상 면접 사례로 배우는 대규모 시스템 설계 기초
- Propositional and Predicate Logic
- 항해99
- 아레나 시뮬레이션
- 최단경로 알고리즘
- 그라파나
- Arena
- 자바스크립트
- 엄청난 인내심과 시뮬레이션을 위한 아레나 툴
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |