상단에는 현재 사용자 프로세스만 표시됩니다.

상단에는 현재 사용자 프로세스만 표시됩니다.

최근 CentOS 6.7을 실행하는 전용 서버가 생겼고 업데이트를 실행한 결과 top에는 현재 사용자에 대한 프로세스만 표시되는 것으로 확인되었습니다.

[myuser@server2 ~]$ top -b -n1 
top - 20:19:20 up 1 day, 10:09,  3 users,  load average: 0.80, 0.50, 0.41
Tasks:  11 total,   1 running,  10 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.2%us,  0.0%sy,  0.0%ni, 99.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  32880988k total, 26893324k used,  5987664k free,   140872k buffers
Swap:  1046520k total,        0k used,  1046520k free, 19532120k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND               
 1648 myuser  20   0 98.8m 1020  688 S  0.0  0.0   0:00.00 man                   
 1651 myuser  20   0  103m 1184 1016 S  0.0  0.0   0:00.00 sh                    
 1652 myuser  20   0  103m  684  500 S  0.0  0.0   0:00.00 sh                    
 1656 myuser  20   0  103m  912  752 S  0.0  0.0   0:00.07 less                  
 3363 myuser  20   0  100m 1708  700 S  0.0  0.0   0:00.04 sshd                  
 3364 myuser  20   0  105m 1916 1524 S  0.0  0.0   0:00.00 bash                  
 8337 myuser  20   0 14940 1096  880 R  0.0  0.0   0:00.00 top                   
30429 myuser  20   0  100m 1696  696 S  0.0  0.0   0:00.16 sshd                  
30430 myuser  20   0  105m 1924 1536 S  0.0  0.0   0:00.01 bash                  
31132 myuser  20   0  100m 1692  692 S  0.0  0.0   0:00.05 sshd                  
31133 myuser  20   0  105m 1928 1536 S  0.0  0.0   0:00.04 bash            

그러나 sudo로 실행하면 예상한 정상적인 출력을 얻습니다.

[myuser@server2 ~]$ sudo top -bn1
top - 20:22:08 up 1 day, 10:12,  3 users,  load average: 0.36, 0.40, 0.39
Tasks: 166 total,   1 running, 165 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.2%us,  0.0%sy,  0.0%ni, 99.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  32880988k total, 26898188k used,  5982800k free,   141196k buffers
Swap:  1046520k total,        0k used,  1046520k free, 19532188k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND               
32705 otherusr  20   0 21.9g 5.8g  15m S 39.8 18.3  28:47.76 java                  
    1 root      20   0 19280 1524 1232 S  0.0  0.0   0:00.76 init                  
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd              
    3 root      20   0     0    0    0 S  0.0  0.0   0:00.40 ksoftirqd/0           
    5 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 kworker/0:0H          
    6 root      20   0     0    0    0 S  0.0  0.0   0:03.20 kworker/u16:0  
~~~~~omitted~~~~~

나는 배치 모드가 아닌 "u" & "U"를 사용하여 top을 실행하고 공백으로 두고 [enter]를 눌러 보았습니다. 운이 없었습니다.

나는 실제 최고 경로를 실행하고 있다고 확신하며 절대 경로로 실행해도 아무런 영향을 미치지 않았습니다.

$ which top
/usr/bin/top
$ file /usr/bin/top
/usr/bin/top: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
$ alias
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias vi='vim'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

/etc/에 toprc가 없습니다.

$ ls -a /etc | grep -c toprc
0

proc은 다음과 같이 마운트됩니다.

$ sudo cat /proc/mounts | grep proc
none /proc proc rw,relatime 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
$ sudo cat /etc/fstab | grep proc
proc        /proc   proc    defaults        0   0

Procs에 대한 자세한 내용

[myuser@server2 ~]$ sudo -u otherusr ps -A
  PID TTY          TIME CMD
21921 pts/0    00:00:00 ps
32703 ?        00:00:00 screen
32705 pts/3    01:08:01 java
[myuser@server2 ~]$ sudo ls -l /proc/ | grep 32705
dr-xr-x---  7 otherusr root     0 Sep 23 19:27 32705
[myuser@server2 ~]$ sudo ls -l /proc/32705/ | grep stat
-r--------  1 otherusr root 0 Sep 23 21:54 mountstats
-r--r--r--  1 otherusr root 0 Sep 23 19:27 stat
-r--r--r--  1 otherusr root 0 Sep 23 19:27 statm
-r--r--r--  1 otherusr root 0 Sep 23 19:27 status
[myuser@server2 ~]$ ls /proc/ | egrep "[0-9]{1,9}";
17363
17364
26124
26125
3363
3364
[myuser@server2 ~]$ sudo -u otheruser ls /proc/ | egrep "[0-9]{1,9}"
26132
32703
32705
[myuser@server2 ~]$ umask
0002
[root@server2 ~]# umask
0022

어떤 아이디어가 있나요?

답변1

한 가지 가능성은 또는 /proc로 마운트 됩니다 . 이 마운트 옵션은 최신 Linux 커널에 추가되었으며 CentOS 5.9 및 6.3쯤에 백포팅되었습니다. hidepid=1hidepid=2

Mount options
   The proc filesystem supports the following mount options:

   hidepid=n (since Linux 3.3)
          This option controls who can access the information in
          /proc/[pid] directories.  The argument, n, is one of the
          following values:

          0   Everybody may access all /proc/[pid] directories.  This is
              the traditional behavior, and the default if this mount
              option is not specified.

          1   Users may not access files and subdirectories inside any
              /proc/[pid] directories but their own (the /proc/[pid]
              directories themselves remain visible).  Sensitive files
              such as /proc/[pid]/cmdline and /proc/[pid]/status are now
              protected against other users.  This makes it impossible
              to learn whether any user is running a specific program
              (so long as the program doesn't otherwise reveal itself by
              its behavior).

          2   As for mode 1, but in addition the /proc/[pid] directories
              belonging to other users become invisible.  This means
              that /proc/[pid] entries can no longer be used to discover
              the PIDs on the system.  This doesn't hide the fact that a
              process with a specific PID value exists (it can be
              learned by other means, for example, by "kill -0 $PID"),
              but it hides a process's UID and GID, which could
              otherwise be learned by employing stat(2) on a /proc/[pid]
              directory.  This greatly complicates an attacker's task of
              gathering information about running processes (e.g.,
              discovering whether some daemon is running with elevated
              privileges, whether another user is running some sensitive
              program, whether other users are running any program at
              all, and so on).

또 다른 가능성(포스터에서 발견되어 이 답변에 참조 정보로 추가됨)은 다음과 같습니다.보안권한이 없는 사용자로부터 다른 사용자의 프로세스를 숨기는 기능이 있습니다.파일 시스템 강화.

권한이 없는 사용자를 위해 다른 사용자의 프로세스 숨기기

이제 업스트림 커널은 권한이 없는 다른 사용자의 프로세스를 숨기기 위해 /proc에 대한 마운트 옵션을 제공하지만, grsecurity는 기본적으로 이러한 정보를 숨기고 /proc에서 커널이 제공하는 중요한 정보의 추가 소스를 숨기고 개인 네트워크를 숨김으로써 이를 뛰어넘습니다. 모든 사용자의 관련 정보. 네트워킹 정보는 시스템에 있는 다른 사용자의 개인 정보를 침해할 뿐만 아니라 과거에는 TCP 하이재킹 공격에도 유용했습니다.

답변2

다음 게시물의 정보를 바탕으로 3가지 가능한 해결 방법을 확인했습니다.

grsecurty로 인해 사용자가 다른 사용자의 PID를 볼 수 없게 될 수 /proc/있으며 OVH(내 호스팅 회사)가 Grsecurity로 컴파일된 사용자 정의 커널을 사용한다는 내용은 무엇입니까?

$ uname -r
3.14.32-xxxx-grs-ipv6-64

가능한 해결 방법은 다음과 같습니다.

  1. 보안 제거
  2. 그러한 사용을 허용하도록 정책을 편집하십시오.
  3. 다른 관리자에게 새로운 보안 조치가 적용되었음을 알립니다.

보안이 최우선이므로 다른 관리자를 교육하는 것이 최선의 선택입니다. 그래도 그들이 우리에게 이와 같은 것을 알려줬으면 좋았을 텐데요. 모든 도움에 감사드립니다!

답변3

루트 사용자로 로그인하여 여러 단계를 거쳐 수행합니다.

  1. 로그인한 모든 사용자를 찾으려면last | grep 'logged'

  2. top -u username1등 의 특정 사용자의 활동을 확인합니다 top -u username2.

관련 정보