在 Windows 命令行中使用双引号提取密码存档 [英] Extract password archive with double quote in windows command line

查看:31
本文介绍了在 Windows 命令行中使用双引号提取密码存档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 PHP 中提取存档文件(zip、rar、z7、gz 等).因为密码可以包含像¡¿这样的特殊字符,而且PHP exec 不支持unicode 字符(出于某种原因).我最终使用了一个批处理文件,如此处所述 php exec() 在 unicode 模式下?.

I want to extract archive files (zip,rar,z7,gz,etc) from PHP. Because the passwords can contain special characters like ¡¿, and PHP exec does not support unicode characters (for some reason). I eneded up using a batch file as explained here php exec() in unicode mode?.

但是,与 Windows 10 一样可爱,我似乎无法弄清楚如何提取具有单双引号作为密码的存档...

But, as lovely as windows 10 is, I can't seem to figure out how to extract an archive that has a single double quote as password...

"C:Program Files7-Zip7z.exe" x "C:UsersmeDesktop25mb.rar" -o"C:UsersmeDesktop" -p"password here" -y

这是使用 7zip 提取的默认行.(注意下面)我有一个文件 25mb.bin 存储在 test.rar 中存储在 25mb.rar 中,密码为(单双引号).

That is the default line to extract using 7zip. (note below) I have a file 25mb.bin stored in test.rar stored in 25mb.rar with password " (single double quote).

错误是:

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21

Scanning the drive for archives:
1 file, 13312 bytes (13 KiB)

Extracting archive: C:UsersmeDesktop25mb.rar
--
Path = C:UsersmeDesktop25mb.rar
Type = Rar
Physical Size = 13312
Solid = -
Blocks = 1
Multivolume = -
Volumes = 1

ERROR: Data Error in encrypted file. Wrong password? : test.rar

Sub items Errors: 1

Archives with Errors: 1

Sub items Errors: 1

我试过了:

-p" *
-p"" **
-p"""  *
-p"""" **
-p"^"" * (default escape for CMD)
-p""" *

*:该行询问我是否要覆盖,这意味着 -y 不会被执行,而是被视为密码的一部分.

**:执行,但有错误.解压出来的文件test.rar无法打开(已损坏)

注意:这个方法对 ~`!@#$%^&()_+-={}[]|:;'<>?,./€¡¿*

Note: This method has no problem whatsoever with ~`!@#$%^&()_+-={}[]|:;'<>?,./€¡¿*

注意:winRAR 有一个巧妙的功能,您可以提供一个带有密码的文件,用于提取,而不是提供一个字符串.然而,这仅适用于 RAR 文件(!),因此在我的情况下是无用的.

rar 示例:

file_put_contents( 'C:UsersunnyDesktoppass.txt', $password );
exec( '"C:\Program Files\WinRAR\winrar" e -ad -p "C:\Users\me\Desktop\25mb.rar" *.* "C:\Users\me\Desktop" < "C:\Usersme\Desktop\pass.txt"', $extractStatus );

推荐答案

好吧,经过随机测试,我设法找到了答案!

Well, after testing random things, I managed to find the answear!

"C:Program Files7-Zip7z.exe" x "C:UsersmeDesktopdq.rar" -o"C:UsersmeDesktop" -sccutf-8 -y < C:UsersmeDesktoppass.txt

注意 -p 参数不存在(!)(如果添加,它不起作用)

Note that the -p parameter is NOT present(!) (if added, it doesn't work)

文件 pass.txt 包含 (双引号后跟换行符)

The file pass.txt contains " (double quote followed by a line break)

-sccutf-8"选项确保特殊字符也能正常工作!

The "-sccutf-8" option ensures that special characters work as well!

有效!

编辑 2:当密码文件包含°、¡、¿或§等特殊字符时,此方法仍然有效!您必须设置-sccutf-8"才能使其工作

Edit 2: When the password file contains special characters like °, ¡, ¿ or §, this method still works! You do have to set "-sccutf-8" in order to make it work

这篇关于在 Windows 命令行中使用双引号提取密码存档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆