
누군가 루트가 아닌 계정을 사용하여 내 서버에 액세스했다면 그 사람이 얼마나 많은 피해를 입힐 수 있는지 알고 싶었습니다.
그런 다음 su someuser
이 명령을 사용하여 쓰기 가능한 모든 파일과 폴더를 찾았습니다.
find / -writable >> list.txt
결과는 다음과 같습니다.. 대부분의 /dev/something 및 /proc/something 그리고 이것들
/var/lock
/var/run/mysqld/mysqld.sock
/var/tmp
/var/lib/php5
내 시스템은 안전한가요? /var/tmp는 의미가 있지만 이 사용자가 왜 해당 폴더에 대한 쓰기 액세스 권한을 갖고 있는지 잘 모르겠습니다. 바꿔야 할까요?
stat /var/lib/php5
이상한 1733을 제공합니다. 쓰기 액세스 권한이 필요한 이유는 무엇입니까? 왜 읽지 않습니까? 임시 파일을 이상한 용도로 사용하는 건가요?
답변1
사용자는 특정 소프트웨어를 실행하려면 특정 시스템 수준 영역에 액세스해야 합니다. 예를 들어 /var/run/mysqld/mysqld.sock
데이터베이스와 상호 작용하려면 액세스할 수 있어야 합니다.
/var/run에는 일반적으로 Unix 소켓 및 pid 파일과 같은 런타임 데이터가 있습니다.
/var/lock에는 소프트웨어가 읽기/쓰기 충돌 등을 방지하고 파일의 단독 열기(파일 잠금 등)를 허용하는 잠금 파일이 포함되어 있습니다.
/var/lib/php5에는 매우 특별한 파일 액세스 모드(1733)가 있습니다. 시작 부분의 1이 중요합니다.
에서man chmod
1000 (the sticky bit). See chmod(2) and sticky(8).
따라서 man sticky
우리는 다음을 얻습니다.
STICKY DIRECTORIES
A directory whose `sticky bit' is set becomes an append-only directory,
or, more accurately, a directory in which the deletion of files is
restricted. A file in a sticky directory may only be removed or renamed
by a user if the user has write permission for the directory and the user
is the owner of the file, the owner of the directory, or the super-user.
This feature is usefully applied to directories such as /tmp which must
be publicly writable but should deny users the license to arbitrarily
delete or rename each others' files.
즉, 사용자가 디렉터리에서 파일을 생성하거나 편집할 수 있지만 파일 자체의 소유자만 삭제할 수 있는 특수 보안 모드라는 의미입니다.