Почему `cat / dev / urandom` ломает ваш терминал?

14885
enthdegree

В связи с этим вопросом: https://serverfault.com/questions/534449

Как cat /dev/urandomзаставить некоторые эмуляторы терминала работать так, как надо?

13

4 ответа на вопрос

20
Darth Android

While there are your normal, printable ASCII characters that are sent back and forth on a terminal, there are also many unprintable characters that are used for the system to communicate with the terminal. For example, if a program sends the character 0x07 ("ASCII Bell character"), your terminal should beep.

Other special sequences can be used to change the color of text being displayed, which direction it's displayed, the title of the window, the size of the window, etc., among many other things.

When you

cat /dev/urandom 

A bunch of random characters are dumped to your terminal, and the terminal can't tell that it's not real control codes.

Because the program is effectively sending random commands to the terminal, the terminal ends up in a random, often unusable state.

15
c4b3r42

Фактически использование этой команды покажет, есть ли АНБ на вашем компьютере в данный момент:

strings < /dev/urandom | grep nsa -i 

Если вы получаете какие-либо положительные результаты, это явный признак того, что они просматривают на вашем компьютере. Это даже работает на машинах с воздушным зазором, и причина, по которой ваш удар иногда становится "вялым", заключается в контрмеры АНБ. Быть осторожен!

Веселый, но, очевидно, неправда, на случай, если мимо пройдут какие-то новички! EngineerBetter_DJ 8 лет назад 8
Лучший! Ответ! Когда-либо! https://imgflip.com/i/1ep8ch Mawg 7 лет назад 1
Кто-нибудь знает, будет ли это работать на ЦРУ и как это проверить? Mawg 7 лет назад 1
Там удивительное количество матчей, я не ожидал, что так много. Brandon Ibbotson 6 лет назад 0
4
vbraun

Some of the random output will be ANSI escape codes (http://en.wikipedia.org/wiki/ANSI_escape_code), which can do fun stuff like hide the cursor or select alternate fonts. Another possibility are unicode sequences: A random bytestream will not be valid UTF-8, and probably not all unicode-aware terminals handle that gracefully.

1
Scott Chamberlain

cat /dev/urandom will give you a stream of random bytes between 0 and 255, not all of those values are valid text characters. Because the terminal window was feed invalid data it was never expected to handle it could get the terminal application in to a "broken" state.

Похожие вопросы