当前位置: 首页>>技术问答>>正文


sudo的侮辱存储在哪里?

,

问题描述

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

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退出

第三种解决方案

所有侮辱清单

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

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):

    /*
     * 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辱骂):

.
    /*
     * 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文件,将名称添加到insults.h,然后重新编译以获得如下信息:“你是ArchLinux用户?”或者“这不是Windows错误很普遍的地方!”等。

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

第四种方案

以上答案适用于离线搜索。但我们在线。因此打开Debian code search并尝试其中一个here。它立即告诉你它在sudo_1.8.12-1/plugins/sudoers/ins_csops.h。这有一个好处,就是可以在/etc或其他地方部署配置文件。因为它是一个.h文件,所以它是可见的,它在源代码中,而不是你可以修改的东西。

第五种方案

要添加到其他答案,这些侮辱似乎在sudoers.so的.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.
$ 

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/165.html,未经允许,请勿转载。