sudo的侮辱在哪里存放?

对于那些喜欢幽默的人来说, sudo可以被配置为打印随机或多或少的侮辱性或有趣的短语而不是中立Sorry, try again. 通过将以下行添加到/etc/sudoers (使用命令sudo visudo ,而不是手动编辑!):

 Defaults insults 

这里有些例子:

 [sudo] password for bytecommander: The more you drive -- the dumber you get. [sudo] password for bytecommander: I've seen penguins that can type better than that. [sudo] password for bytecommander: This mission is too important for me to allow you to jeopardize it. [sudo] password for bytecommander: He has fallen in the water! [sudo] password for bytecommander: Hold it up to the light --- not a brain in sight! 

现在只是为了好玩,我想阅读所有这些,但是整天输入错误的密码并不是最好的方法(每次尝试后延迟,每3次尝试只有2条消息,3次尝试后中止,……)。

那么……这些侮辱实际存放在哪里? 我可以直接阅读的任何纯文本文件? 或者源代码中的硬编码字符串?

如何获取所有可用的sudo insult消息列表?

它们位于二进制文件中

 /usr/lib/sudo/sudoers.so 

(发现者: find /usr/lib/sudo -type f | xargs grep "fallen in the water"

如果启用源下载并执行此操作

 apt source sudo 

您可以在源目录下找到insults文件

 plugins/sudoers 

文件是

 ins_2001.h ins_classic.h ins_csops.h ins_goons.h insults.h 

这些文件的示例:

 #ifndef SUDOERS_INS_GOONS_H #define SUDOERS_INS_GOONS_H /* * Insults from the "Goon Show." */ "You silly, twisted boy you.", "He has fallen in the water!", "We'll all be murdered in our beds!", "You can't come in. Our tiger has got flu", 

等等…它们非常易读。

 dpkg -L sudo | xargs grep dumber 

我们可以搜索包sudo中的哪些文件包含单词dumber

唯一的匹配是在文件/usr/lib/sudo/sudoers.so 。 这是一个二进制文件,所以我们使用strings命令只能获得看起来像人类可读的东西。 因为它很多,我们将结果输入less

 strings /usr/lib/sudo/sudoers.so | less 

我们可以less

 /dumber 

再次搜索“dumber”这个词。 这让我们陷入了侮辱之中。 使用光标键向上和向下滚动,然后使用q退出

所有侮辱名单

当我们看到所有的侮辱时,我们发现了一个有趣的小窍门:说西兰花在政治上是正确的,但是说Burrito不是。 所有的侮辱都列在下面。

ins_2001.h (2001太空奥德赛侮辱):

 . /* * HAL insults (paraphrased) from 2001. */ "Just what do you think you're doing Dave?", "It can only be attributed to human error.", "That's something I cannot allow to happen.", "My mind is going. I can feel it.", "Sorry about this, I know it's a bit silly.", "Take a stress pill and think things over.", "This mission is too important for me to allow you to jeopardize it.", "I feel much better now.", 

ins_classic.h (Original Sudo 8侮辱):

  /* * Insults from the original sudo(8). */ "Wrong! You cheating scum!", #ifdef PC_INSULTS "And you call yourself a Rocket Scientist!", #else "No soap, honkie-lips.", #endif "Where did you learn to type?", "Are you on drugs?", "My pet ferret can type better than you!", "You type like i drive.", "Do you think like you type?", "Your mind just hasn't been the same since the electro-shock, has it?", 

ins_csops.h (CSOps侮辱):

  /* * CSOps insults (may be site dependent). */ "Maybe if you used more than just two fingers...", "BOB says: You seem to have forgotten your passwd, enter another!", "stty: unknown mode: doofus", "I can't hear you -- I'm using the scrambler.", "The more you drive -- the dumber you get.", #ifdef PC_INSULTS "Listen, broccoli brains, I don't have time to listen to this trash.", #else "Listen, burrito brains, I don't have time to listen to this trash.", #endif "I've seen penguins that can type better than that.", "Have you considered trying to match wits with a rutabaga?", "You speak an infinite deal of nothing", 

ins_goons.h (Goon Show ins_goons.h ):

 . /* * Insults from the "Goon Show." */ "You silly, twisted boy you.", "He has fallen in the water!", "We'll all be murdered in our beds!", "You can't come in. Our tiger has got flu", "I don't wish to know that.", "What, what, what, what, what, what, what, what, what, what?", "You can't get the wood, you know.", "You'll starve!", "... and it used to be so popular...", "Pauses for audience applause, not a sausage", "Hold it up to the light --- not a brain in sight!", "Have a gorilla...", "There must be cure for it!", "There's a lot of it about, you know.", "You do that again and see what happens...", "Ying Tong Iddle I Po", "Harm can come to a young lad like that!", "And with that remarks folks, the case of the Crown vs yourself was proven.", "Speak English you fool --- there are no subtitles in this scene.", "You gotta go owwwww!", "I have been called worse.", "It's only your word against mine.", "I think ... err ... I think ... I think I'll go home", 

文件insults.h包含编译器指令,说明要包含在编译内核中的上述哪些内容。 实际上,您可以创建自己的insults文件,将名称添加到insults.h并重新编译以获得诸如“你是ArchLinux用户的什么?”之类的消息。 或者“这不是Windows的常见错误!”等。

注意一些i​​nsult文件中的#ifdef PC_INSULTS 。 这并不意味着“如果你有个人电脑”,这意味着“如果你想要在政治上正确。”

以上答案非常适合离线搜索。 但我们在线。 所以打开Debian代码搜索并尝试其中一个侮辱。 它会立即告诉你它在sudo_1.8.12-1/plugins/sudoers/ins_csops.h 。 这样做的好处是可以在任何地方找到它, 无论是部署在/etc的配置文件还是其他什么。 因为它是一个.h文件,所以它在源代码中可见,而不是你可以修改的东西。

要添加到其他答案,侮辱似乎在.rodata部分。 你可以使用objcopy来限制输出,尽管仍会有很多误报:

 $ objcopy /usr/lib/sudo/sudoers.so /dev/null --dump-section .rodata=/dev/stdout | strings | head /build/sudo-g3ghsu/sudo-1.8.16/plugins/sudoers/auth/sudo_auth.c invalid authentication methods Invalid authentication methods compiled into sudo! You may not mix standalone and non-standalone authentication. There are no authentication methods compiled into sudo! If you want to turn off authentication, use the --disable-authentication configure option. Unable to initialize authentication methods. Just what do you think you're doing Dave? It can only be attributed to human error. That's something I cannot allow to happen. My mind is going. I can feel it. Sorry about this, I know it's a bit silly. $