发现可疑行为

发现可疑行为

我在当前目录中查找所有可由所有者和/或组写入但并非所有人都可写入的文件:

find . -type f -perm /220 ! -perm /002 -exec ls -l {} \; | tr -d '\.\/' | sort -k 9 -u

-rws--S--- 1 root root 15 Sep 21 16:51 File0
-r--rw---x 1 root root 15 Sep 21 16:51 file01
-rwSr--r-- 1 achille achille 32 Sep 21 16:51 file1
-rwSr--r-- 1 achille achille 15 Sep 21 16:51 file2
-rw-r-Sr-- 1 achille achille 15 Sep 21 16:51 file3
-rw-r--r-- 1 root root 2254727 Sep 21 16:51 Open2_O
-rw-r--r-- 1 root root 183 Sep 21 16:51 test0

一切看起来都不错,但是……

find . -perm /220 ! -perm /002 -exec ls -l {} \; | tr -d '\.\/' | sort -k 9 -u

-rws--S--- 1 root    root         15 Sep 21 16:51 File0
-r--r----x 1 root    root         15 Sep 21 16:51 file00
-r--rw---x 1 root    root         15 Sep 21 16:51 file01
-rwSr--r-- 1 achille achille      32 Sep 21 16:51 file1
-rwxrwxrwx 1 root    root         15 Sep 21 16:51 File1
-rwSr--r-- 1 achille achille      15 Sep 21 16:51 file2
-rw-r-Sr-- 1 achille achille      15 Sep 21 16:51 file3
-rw-r--r-- 1 root    root    2254727 Sep 21 16:51 Open2_O
-rw-r--r-- 1 root    root        183 Sep 21 16:51 test0

如果没有“-type f”开关,则会出现另外 2 个意外文件:file00 和 File1


file -i file00

file00: text/plain; charset=us-ascii

stat file00
  File: file00
  Size: 15          Blocks: 8          IO Block: 4096   regular file

[..]

file -i File1
File1: text/plain; charset=us-ascii

stat File1
  File: File1
  Size: 15          Blocks: 8          IO Block: 4096   regular file
[..]

file -i File0
File0: text/plain; charset=us-ascii

stat File0 
  File: File0
  Size: 15          Blocks: 8          IO Block: 4096   regular file
[..] 

file00 和 File1(有问题的)看起来像其他文件(例如 File0),所以:

  1. 为什么 file00 和 File1 出现在第二个实例中(没有 -type f 开关)!?
  2. 为什么他们的烫发与我要找的烫发不符?

真的谢谢各位了!

答案1

我猜有一个目录(甚至可能是.当前目录)符合您的条件,并且它包含file00File1ls目录上的命令会显示其内容,无论其权限如何,并且您的过滤会sort隐藏重复项(从多次ls调用中)。

-d如果添加到ls调用中并sort(暂时)删除,您将更好地了解发生了什么。

相关内容