sudo 的侮辱存储在哪里?

Byt*_*der 258 sudo

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

Defaults insults
Run Code Online (Sandbox Code Playgroud)

这里有些例子:

[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!
Run Code Online (Sandbox Code Playgroud)

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

那么......这些侮辱实际上存储在哪里?我可以直接读取任何纯文本文件吗?还是源代码中的硬编码字符串?

如何获取所有可用sudo侮辱信息的列表?

Zan*_*nna 206

它们在二进制文件中

/usr/lib/sudo/sudoers.so
Run Code Online (Sandbox Code Playgroud)

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

如果您启用源下载并执行

apt source sudo
Run Code Online (Sandbox Code Playgroud)

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

plugins/sudoers
Run Code Online (Sandbox Code Playgroud)

这些文件是

ins_2001.h
ins_classic.h
ins_csops.h
ins_goons.h
insults.h
Run Code Online (Sandbox Code Playgroud)

这些文件的示例:

/usr/lib/sudo/sudoers.so
Run Code Online (Sandbox Code Playgroud)

等等……它们的可读性很强。

  • 现在 Zanna 告诉我们它们在 sudoers.so 中,您还可以使用字符串而不是源代码“读取”它们。运行这个:`strings /usr/lib/sudo/sudoers.so` (30认同)
  • [ins_2001.h](https://www.sudo.ws/repos/sudo/file/2e847ce3f02f/plugins/sudoers/ins_2001.h) [ins_classic.h](https://www.sudo.ws/repos/ sudo/file/2e847ce3f02f/plugins/sudoers/ins_classic.h) [ins_csops.h](https://www.sudo.ws/repos/sudo/file/2e847ce3f02f/plugins/sudoers/ins_csops.h) [ins_goons.h ](https://www.sudo.ws/repos/sudo/file/2e847ce3f02f/plugins/sudoers/ins_goons.h) (27认同)
  • 在我看到 Goon Show insults 之前我不会真的这样做,在这一点上我不能足够快地键入 (10认同)
  • @Stéphane 那是真的,尽管`strings` 不会告诉你所有的侮辱是否都是平等的。阅读实际来源可以揭示某些标准是否会影响侮辱的选择。 (3认同)
  • @Stéphane Plus 在可执行文件上运行 *strings* 会产生大量冗长乏味的误报。 (3认同)

Win*_*nix 88

侮辱自己

您可以更改 sudo 侮辱,而无需重新编译 sudo。

请参阅:添加新的 sudo 侮辱


带有侮辱性的头文件

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

ins_2001.h (2001 Space Odyssey 侮辱):

.
    /*
     * 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.",
Run Code Online (Sandbox Code Playgroud)

ins_classic.h (原文须藤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?",
Run Code Online (Sandbox Code Playgroud)

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",
Run Code Online (Sandbox Code Playgroud)

ins_goons.h (Goon Show 侮辱):

.
    /*
     * 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",
Run Code Online (Sandbox Code Playgroud)

该文件insults.h包含编译器指令,说明要在编译的 sudo 程序中包含上述哪些侮辱。实际上,您可以创建自己的 insults 文件,将名称添加到 insults.h 并重新编译以显示诸如“什么,您是 ArchLinux 用户吗?”之类的消息。或“这不是错误司空见惯的 Windows!”等。

请注意#ifdef PC_INSULTS某些侮辱文件中的 。这并不意味着“如果你有一台个人电脑”,而是“如果你想在政治上保持正确”。


列出对您的终端的所有侮辱

对于 Ubuntu 16.04.6 LTS,您可以使用:

strings /usr/lib/sudo/sudoers.so | head -n1670 | tail -n49
Run Code Online (Sandbox Code Playgroud)

对于其他 Ubuntu 版本,传递给headcommand的行号可能会改变。希望其他人可以验证他们的版本。

  • 我不知道“西兰花”被认为比“墨西哥卷饼”在政治上更正确。 (50认同)
  • 美国以外的大多数人,可能还有一些在美国的人不会认为这是“明显的种族诽谤”。对我来说,有趣的是,无论是谁写了这份蓄意的**侮辱**(这是特征名称!)实际上关心的是特定的人真的被冒犯了......它没有尽头,如果你真的很担心,不要不启用此功能...?! (21认同)
  • @fluffy 我认为这是对国民饮食包括墨西哥卷饼的人的参考。我现在后悔没有审查代码。我应该只使用 PC_INSULT 选项并删除另一半。另一方面,我不喜欢像 Tom Sawyer 和诸如此类的书那样对历史进行审查。由于这些侮辱来自 2004 年,如果我删除了 #ifdef 部分,我会因审查历史而感到内疚。 (10认同)
  • 在谈论我们现在应该使用哪些术语时,不要太担心“审查历史”。我能想到 40 年前我用过的许多词,这些词是种族侮辱、性别歧视等。我很高兴在它们的历史背景下提及它们,但谢天谢地,社会已经向前发展并认识到其中许多词的危害. 是的,如果你愿意,请大声谈论政治正确。请先尝试成为被言语伤害的穷人。 (8认同)
  • PC 的正确性永无止境。任何词都可以被认为是冒犯性的,例如,西兰花在秘鲁不会成为 PC ……但墨西哥卷饼显然是一种种族诽谤。 (5认同)

Flo*_*sch 84

dpkg -L sudo | xargs grep dumber
Run Code Online (Sandbox Code Playgroud)

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

唯一的匹配在 file 中/usr/lib/sudo/sudoers.so。这是一个二进制文件,因此我们使用该strings命令只获取看起来人类可读的内容。由于它很多,我们将结果通过管道传输到less

strings /usr/lib/sudo/sudoers.so | less
Run Code Online (Sandbox Code Playgroud)

less我们可以使用

/dumber
Run Code Online (Sandbox Code Playgroud)

再次搜索单词“dumber”。这让我们直接受到了侮辱。使用光标键上下滚动并退出q

  • 因展示了一种简单的通用技术来发现这些问题的答案而被点赞。 (8认同)
  • 使用 `strings -n10` 来减少误报。另请参阅 [@DigitalTrauma 的回答](http://askubuntu.com/questions/837558/where-are-sudos-insults-stored/838534#838534),它使用 objcopy 仅将 `.rodata` 部分提供给 `strings` ,再次降低噪音。 (2认同)

小智 13

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


Dig*_*uma 8

要添加到其他答案,侮辱似乎在.rodatasudoers.so 部分。您可以使用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.
$ 
Run Code Online (Sandbox Code Playgroud)