📄 ch22_17.htm
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 22] 22.17 Ways of Improving the Security of crypt </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly & Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly & Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:40:38Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch22_01.htm"TITLE="22. File Security, Ownership, and Sharing"><LINKREL="prev"HREF="ch22_16.htm"TITLE="22.16 Copying Permissions with cpmod "><LINKREL="next"HREF="ch22_18.htm"TITLE="22.18 Clear Your Terminal for Security, to Stop Burn-in "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch22_16.htm"TITLE="22.16 Copying Permissions with cpmod "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 22.16 Copying Permissions with cpmod "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 22<BR>File Security, Ownership, and Sharing</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch22_18.htm"TITLE="22.18 Clear Your Terminal for Security, to Stop Burn-in "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 22.18 Clear Your Terminal for Security, to Stop Burn-in "BORDER="0"></A></TD></TR></TABLE> <HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-3040">22.17 Ways of Improving the Security of crypt </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-24716"></A><ACLASS="indexterm"NAME="AUTOID-24718"></A><ACLASS="indexterm"NAME="AUTOID-24720"></A>Files encrypted with<EMCLASS="emphasis">crypt</EM> are exceedingly easy for a cryptographer to break.For several years, it has been possible for noncryptographersto break messages encrypted with <EMCLASS="emphasis">crypt</EM> as well,<ACLASS="indexterm"NAME="AUTOID-24726"></A><ACLASS="indexterm"NAME="AUTOID-24728"></A><ACLASS="indexterm"NAME="AUTOID-24730"></A><ACLASS="indexterm"NAME="AUTOID-24732"></A>thanks to a program developed in 1986 by Robert Baldwin at the MIT Laboratory for Computer Science. Baldwin's program, Crypt Breaker's Workbench (<EMCLASS="emphasis">cbw</EM>),automatically decrypts text files encrypted with<EMCLASS="emphasis">crypt</EM> within a matter of minutes.</P><PCLASS="para"><EMCLASS="emphasis">cbw</EM> has been widely distributed; as a result, files encryptedwith <EMCLASS="emphasis">crypt</EM> should not be considered secure. (They weren'tsecure before <EMCLASS="emphasis">cbw</EM> was distributed; fewer people simply had the technical skill necessary to break them.)</P><PCLASS="para">Although we recommend that you do not use <EMCLASS="emphasis">crypt</EM> to encrypt filesmore than 1 k long. Nevertheless, youmay have no other encryption system readily available to you. If this isthe case, you are better off using <EMCLASS="emphasis">crypt</EM> than nothing atall. You can also take a few simple precautions todecrease the chances that your encrypted files will be decrypted:</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para">Encrypt the file multiple times, using different keys at each stage.This essentially changes the transformation.</P></LI><LICLASS="listitem"><PCLASS="para"><SPANCLASS="link">Compress (<ACLASS="linkend"HREF="ch24_07.htm"TITLE="Compressing Files to Save Space ">24.7</A>)</SPAN>your files before encrypting them.Compressing a filealters the information - the plain<SPANCLASS="link">ASCII (<ACLASS="linkend"HREF="ch51_03.htm"TITLE="ASCII Characters: Listing and Getting Values ">51.3</A>)</SPAN>text - that programs such as<EMCLASS="emphasis">cbw</EM> use to determine when they have correctly assembled part ofthe encryption key. If your message does not decrypt into plain text,<EMCLASS="emphasis">cbw</EM> will not determine when it has correctly decrypted your message.However, if your attackers know you have done this, they can modify theirversion of <EMCLASS="emphasis">cbw</EM> accordingly.</P></LI><LICLASS="listitem"><PCLASS="para">If you use <EMCLASS="emphasis">compress</EM> or <EMCLASS="emphasis">pack</EM> to compress your file, remove the three-byte header.Files compressed with <EMCLASS="emphasis">compress</EM> contain a three-byte signature,or header, consisting of the hexadecimal values <CODECLASS="literal">1f</CODE>, <CODECLASS="literal">9d</CODE>,and <CODECLASS="literal">90</CODE> (in that order). If your attacker believes thatyour file was compressed before it was encrypted, knowing how the first three bytes decrypt can help him to decryptthe rest of the file. You can strip these three bytes with the<SPANCLASS="link"><EMCLASS="emphasis">dd</EM> (<ACLASS="linkend"HREF="ch35_06.htm"TITLE="Low-Level File Butchery with dd ">35.6</A>)</SPAN>command: [2]</P><BLOCKQUOTECLASS="footnote"><PCLASS="para">[2] Using <EMCLASS="emphasis">dd</EM> this way is very slow and inefficient. If you aregoing to be encrypting a lot of compressed files, you may wish towrite a small program to remove the header more efficiently.</P></BLOCKQUOTE><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>compress -c <plain | dd bs=3 skip=1 | crypt >encrypted</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">Of course, you must remember to replace the three-byte header before youattempt to uncompress the file.You can get a headerby compressing<SPANCLASS="link"><EMCLASS="emphasis">/dev/null</EM> (<ACLASS="linkend"HREF="ch13_14.htm"TITLE="What Can You Do with an Empty File? ">13.14</A>)</SPAN>:</P><PCLASS="para"><TABLECLASS="screen.co"BORDER="1"><TR><THVALIGN="TOP"><PRECLASS="calloutlist"><ACLASS="co"HREF="ch13_07.htm"TITLE="13.7 The () Subshell Operators ">( )</A> </PRE></TH><TDVALIGN="TOP"><PRECLASS="screen">% <CODECLASS="userinput"><B>(compress -cf /dev/null;crypt <encrypted) | uncompress -c >plain</B></CODE></PRE></TD></TR></TABLE></P><PCLASS="para"></P></LI><LICLASS="listitem"><PCLASS="para">If you do not have <EMCLASS="emphasis">compress</EM>, use<SPANCLASS="link"><EMCLASS="emphasis">tar</EM> (<ACLASS="linkend"HREF="ch19_05.htm"TITLE="Using tar to Create and Unpack Archives ">19.5</A>)</SPAN>to bundle your file tobe encrypted with other files containing random data; then encrypt the<EMCLASS="emphasis">tar</EM> file.The presence of random data will make it more difficult for decryptionprograms such as <EMCLASS="emphasis">cbw</EM> to isolate your plain text.</P></LI></UL><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">SG</SPAN>, <SPANCLASS="authorinitials">GS</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch22_16.htm"TITLE="22.16 Copying Permissions with cpmod "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 22.16 Copying Permissions with cpmod "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch22_18.htm"TITLE="22.18 Clear Your Terminal for Security, to Stop Burn-in "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 22.18 Clear Your Terminal for Security, to Stop Burn-in "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">22.16 Copying Permissions with cpmod </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">22.18 Clear Your Terminal for Security, to Stop Burn-in </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed & awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -