gzip:stdin:不是 gzip 格式

gzip:stdin:不是 gzip 格式

当我跑步时:

tar -zxvf john-1.7.0.2.tar.gz

我明白了:

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

它应该开始解包。

有人告诉我不要使用,z但我遇到了同样的错误。

这是我通过以下方式下载的文件:

wget http://openwall.com/john/f/john-1.7.0.2.tar.gz

答案1

诊断错误类型的下载文件

作为steeldriver 说,这意味着该文件实际上并不是一个 gzip 压缩的 tar 文件——或者任何类型的 gzip 压缩文件——尽管它被命名为 gzip 压缩文件。

当您使用 下载文件时wget,经常会有迹象表明您最终得到的文件类型与您想要的文件类型不同:

ek@Io:~$ wget http://openwall.com/john/f/john-1.7.0.2.tar.gz
--2017-01-28 23:57:33--  http://openwall.com/john/f/john-1.7.0.2.tar.gz
Resolving openwall.com (openwall.com)... 195.42.179.197
Connecting to openwall.com (openwall.com)|195.42.179.197|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.openwall.com/john/ [following]
--2017-01-28 23:57:40--  http://www.openwall.com/john/
Resolving www.openwall.com (www.openwall.com)... 195.42.179.202
Connecting to www.openwall.com (www.openwall.com)|195.42.179.202|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘john-1.7.0.2.tar.gz’

john-1.7.0.2.tar.gz                          [      <=>                                                                        ]  15.27K  3.61KB/s    in 4.2s

2017-01-28 23:57:51 (3.61 KB/s) - ‘john-1.7.0.2.tar.gz’ saved [15633]

在这种情况下,主要迹象是:

  • 301 Moved Permanently消息重定向到以 结尾的地址/。这将加载服务器上某个目录的默认页面,该页面通常index.html且几乎总是 HTML 文件。
  • Length: unspecified [text/html],告诉您您收到的是纯文本 ( text),并且它应该被解释为html。这实际上不仅仅是一个标志——您可以根据这一点确信您没有收到真正的 gzip 文件。

您还可以使用该file实用程序,它会检查文件并告诉您它看起来是什么类型的文件:

ek@Io:~$ file john-1.7.0.2.tar.gz
john-1.7.0.2.tar.gz: HTML document, ASCII text, with very long lines

当然,您也可以自己检查文件,使用headless和等工具view

ek@Io:~$ head john-1.7.0.2.tar.gz
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>John the Ripper password cracker</TITLE>
<link href="/style.css" type="text/css" rel="stylesheet">
<META name="keywords" content="John the Ripper, password cracker, JtR, password checker, password recovery, password, cracker, crackers, cracking, crack, crypt, passwd, shadow, Unix, Linux, Windows, Win32, Mac OS X, Mac OSX, MacOS X, OS X, OSX, DOS, VMS, OpenVMS, hash, DES, MD5, Blowfish, Kerberos, AFS, LM, LanMan, LanManager, NT, 2000, XP, 2003, Vista, 7, NTLM, NTLMv1, MD4, Netscape LDAP, SHA, SSHA, MySQL, TGT, s/key, Eggdrop, Apache, apr1, SYSUAF, SYSUAF.DAT, AltiVec, MMX, SSE, SSE2, AVX, XOP, wordlist, wordlists, dictionary, brute force, decrypt, challenge, response, John, Ripper, john, jhon, jonh, jack, Jack the Ripper">
<META name="description" content="A fast password cracker for Unix, Windows, DOS, and OpenVMS, with support for Unix, Windows, and Kerberos AFS passwords, plus a lot more with contributed patches">
</HEAD>

<BODY bgcolor="#E0E0E0" text="black" link="blue" alink="red" vlink="navy">

如果这真的是一个二进制文件,那么您得到的将是一堆毫无意义的垃圾,因为无论您使用什么寻呼机或查看器,都会徒劳地尝试将某些内容解释为纯文本,而实际上并非如此。例如,在正确的文件上:

ek@Io:~$ head john-1.8.0.tar.gz
WӦQ♥john-1.8.0.tar ▒▒kw▒ر&▒▒ٿ▒▒▒▒4E]|▒v▒NF▒d[▒n▒▒▒L&▒HB▒$▒ ▒df͚▒▒▒▒▒ꩪ▒7@▒▒▒9ӳf▒▒J▒m     ▒ؗ▒u▒▒~,▒ї▒▒▒ˣ▒▒ӣ_▒▒▒▒C▒▒|▒▒▒▒▒şw▒v▒▒>▒|w▒▒▒}▒▒▒ί▒▒i9▒?7+▒gY7i▒$▒▒ʲ▒▒s?▒J'MV%▒rY4ur[▒4▒▒e▒▒.▒▒▒▒▒&/u▒-2▒W▒▒V▒▒!o▒0b▒▒▒♥▒|Q▒4▒▒▒&▒▒Y1Y▒F▒▒Iy▒▒▒▒$▒▒▒▒,▒]▒h▒▒8▒"▒▒M▒,Һ~(▒i▒4Y▒d▒QgQ▒*ۚf7yA▒.▒&i▒<d▒↓▒7▒H_-l▒7▒▒▒Z▒▒.m▒▒ʒ%F,▒۬▒*▒▒hrW▒cY▒▒
▒+▒O1▒-y>▒▒J▒yM?▒4I▒▒▒kYS▒▒:▒▒n▒C▒▒%▒▒▒v▒▒▒{[[tN▒9▒▒▒kA▒▒▒▒▒/[▒▒▒▒u▒▒▒z▒▒▒▒>▒▒5▒▒▒▒t▒t▒▒Y6Û<▒*/i▒i{K>▒,▒▒▒▒▒;9)▒Z.mJSeiLB▒▒▒▒▒j▒▒eQ緅▒_▒α▒Ŋ▒▒▒W▒▒▒▒▒_▒▒ˢ▒▒-q▒<gyw͍▒9▒?▒,▒▒▒▒h&▒V"▒▒▒▒▒▒▒l▒▒3▒▒▒▒\▒▒i#▒▒综▒◄0▒▒▒.e♠>a▒▒▒▒▒▒$klt:▒▒rA▒M▒'F▒R▒▒▒▒Lo▒♥1z▒\▒↓X▒▒▒P"֕▒▒▒♦▒▒▒▒|▒▒▒▒▒▒1I▒o"'#|6e▒▒t▒Ц▒FVL▒▒S▒ޓ▒▒;▒x▒▒▒▒▒▒▒QVrr▒▒▒9O▒W7▒♠Og▒
▒▒▒8▒▒/▒▒dm▒FG'▒'t2L▒▒&L▒Y:▒▒▒▒▒4▒rI<▒#▒+▒je▒▒▒>T9▒▒M▒XE-ʆ▒▒'n▒▒$↑▒m▒W▒▒w̕▒▒m▒n%▒|A_▒yGp↑D▒↓߻▒▒▒i▒▒}ӡH▒▒▒▒׍$$H▒▒&▒▒4▒▒▒Z-@♣▒*~▒▒▒ y6▒▒▒`▒v↓▒s▒+̱▒?▒1▒▒▒<▒>▒^▒▒Y#k▒
7`N'▒o▒.&▒▒(▒Դ~AD▒"E◄' lq▒`▒▒`▒[▒9◄▒▒wzuK▒N▒▒Y▒▒%or▒▒)▒▒i↓▒▒▒l5.S▒޶r▒_*▒RO▒{▒$▒(▒▒▒▒C▒·▒▒׀f2ˊ[:▒▒▒,|ew▒▒▒Ag▒'▒▒▒H▒▒t▒{͓▒▒▒▒JH˭s▒)g▒ON▒▒eŚQ▒▒▒♠ s▒▒ߪ▒▒▒▒▒▒▒▒▒▒_♠▒-▒

(我只复制了最开头的部分。)

获取正确的文件

这告诉你如何找出这些情况下(特别是在这种情况下)出了什么问题。但你如何真正找到并下载正确的文件?

这因情况而异。不过,一个好的开始是:

  • 访问软件的官方网站,查看是否提供下载链接。即使您最初是通过官方网站获取链接的,但过了一段时间后,您可能会发现链接已经更改。

    例如,在这种特殊情况下,当前版本是 1.8.0 而不是 1.7.0.2(并在j子目录中提供而不是提供f),并且旧版本不再在同一 URL 上可用。

  • 转到下载文件时重定向到的页面。在本例中,该页面为:http://www.openwall.com/john/

    或者你甚至可以检查已下载的文件。(或者打开在网络浏览器中。

您已重定向至该软件的主下载页面。您可以在网络浏览器中下载,也可以复制正确的当前下载链接并使用 进行下载wget。有几个选择,但假设您实际上没有需要你尝试下载的特定旧版本,以及你根据特定文件做过尝试下载,我怀疑http://openwall.com/john/j/john-1.8.0.tar.gz就是你要找的。

当然,后来看到这篇文章的读者可能会发现链接不再有效。但此处演示的解决此类问题的方法仍然有效。

ek@Io:~$ wget http://openwall.com/john/j/john-1.8.0.tar.gz
--2017-01-29 00:16:19--  http://openwall.com/john/j/john-1.8.0.tar.gz
Resolving openwall.com (openwall.com)... 195.42.179.197
Connecting to openwall.com (openwall.com)|195.42.179.197|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5450412 (5.2M) [application/x-tar]
Saving to: ‘john-1.8.0.tar.gz’

john-1.8.0.tar.gz                        100%[================================================================================>]   5.20M  78.8KB/s    in 26s

2017-01-29 00:16:47 (202 KB/s) - ‘john-1.8.0.tar.gz’ saved [5450412/5450412]

我已下载该文件。请注意,这次没有发生意外的重定向,并且类型被指定为application/x-tar而不是text/html

(HTTP 重定向并不总是坏事。当您被重定向到某个看起来不像您正在寻找的文件时,您应该怀疑您的下载实际上并没有成功。)

file同意:

ek@Io:~$ file john-1.8.0.tar.gz
john-1.8.0.tar.gz: gzip compressed data, was "john-1.8.0.tar", last modified: Thu May 30 04:19:35 2013, max compression, from Unix

并且成功解压:

ek@Io:~$ tar xf john-1.8.0.tar.gz
ek@Io:~$ cd john-1.8.0/
ek@Io:~/john-1.8.0$ ls -l
total 12
drwxrwxr-x 2 ek ek 4096 Jan 29 00:22 doc
lrwxrwxrwx 1 ek ek   10 May 29  2013 README -> doc/README
drwxrwxr-x 2 ek ek 4096 Jan 29 00:22 run
drwxrwxr-x 2 ek ek 4096 Jan 29 00:22 src

(您说得对,使用 没关系z;它仍然可以与 一起工作tar xzf,因为这是正确的文件。)

您可以继续构建源代码并安装。

请记住,你并不总是需要从源代码构建

有时您确实想要某个程序的最新版本,但它不在 Ubuntu 的存储库中。您可能会尝试查找 PPA,但如果您找不到真正值得信赖的 PPA 或无法提供您想要的 PPA,或者您想使用自定义选项构建它,或者您只是真的喜欢从源代码构建,那么从源代码构建是一种有价值且有用的技术。

不过,我建议至少检查 Ubuntu 官方存储库中适用于您系统的软件。在我的 16.04 系统上:

ek@Io:~$ apt show john
Package: john
Version: 1.8.0-2
Priority: optional
Section: admin
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Ruben Molina <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 452 kB
Depends: libc6 (>= 2.14), john-data (= 1.8.0-2)
Suggests: wordlist
Homepage: http://www.openwall.com/john/
Supported: 5y
Download-Size: 184 kB
APT-Sources: http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
Description: active password cracking tool
 John the Ripper is a tool designed to help systems administrators to
 find weak (easy to guess or crack through brute force) passwords, and
 even automatically mail users warning them about it, if it is desired.
 .
 Besides several crypt(3) password hash types most commonly found on
 various Unix flavors, supported out of the box are Kerberos AFS and
 Windows NT/2000/XP/2003 LM hashes, plus several more with contributed
 patches.

还有其他几种方法可以搜索软件包。通常使用Ubuntu 软件包搜索网页。

由于您要尝试安装版本 1.7.0.2,因此官方存储库中的版本 1.8.0 大概已经足够新了。(实际上,1.8.0 似乎与官方网站提供的下载版本相同。)因此,您可能只想安装它:

sudo apt update
sudo apt install john

答案2

有点可惜的是,这个问题实际上包含了我的情况的答案,直到现在我才注意到。但我会在这里留下这条注释,以便那些试图跳过部分文本的人。

您可能不需要 -z 选项

 -z, --gzip
              filter the archive through gzip

所以对我来说实际的提取命令是

tar -xvf bind-9.16.0.tar.xz

类似的问题,也包含删除选项

如果您不想要此信息,请告知我。

相关内容