Created
January 10, 2011 00:34
-
-
Save przemoc/772184 to your computer and use it in GitHub Desktop.
Awful p7zip hack for reading passwords from stdin. Compatible w/ 9.04 and 9.13.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- p7zip_9.04.orig/CPP/7zip/UI/Console/Main.cpp 2009-06-27 16:18:14.000000000 +0200 | |
+++ p7zip_9.04/CPP/7zip/UI/Console/Main.cpp 2011-01-10 01:25:36.000000000 +0100 | |
@@ -48,6 +48,10 @@ | |
#include "myPrivate.h" | |
#include "Windows/System.h" | |
+#include <iostream> | |
+ | |
+#define MAX_PWD_SIZE_FROM_STDIN 1024 | |
+ | |
using namespace NWindows; | |
using namespace NFile; | |
using namespace NCommandLineParser; | |
@@ -443,13 +447,23 @@ | |
#endif | |
UString errorMessage; | |
CDecompressStat stat; | |
- HRESULT result = DecompressArchives( | |
- codecs, | |
- formatIndices, | |
- options.ArchivePathsSorted, | |
- options.ArchivePathsFullSorted, | |
- options.WildcardCensor.Pairs.Front().Head, | |
- eo, &openCallback, ecs, errorMessage, stat); | |
+ | |
+ wchar_t pwd[MAX_PWD_SIZE_FROM_STDIN] = { 0 }; /* start with empty pwd */ | |
+ do { | |
+ stdStream << "Test: " << pwd << endl; | |
+ options.Password = pwd; | |
+ ecs->Password = options.Password; | |
+ openCallback.Password = options.Password; | |
+ | |
+ HRESULT result = DecompressArchives( | |
+ codecs, | |
+ formatIndices, | |
+ options.ArchivePathsSorted, | |
+ options.ArchivePathsFullSorted, | |
+ options.WildcardCensor.Pairs.Front().Head, | |
+ eo, &openCallback, ecs, errorMessage, stat); | |
+ } while (ecs->NumArchiveErrors == ecs->NumArchives && | |
+ std::wcin.getline(pwd, MAX_PWD_SIZE_FROM_STDIN)); | |
if (!errorMessage.IsEmpty()) | |
{ | |
stdStream << endl << "Error: " << errorMessage; | |
@@ -458,6 +472,7 @@ | |
} | |
stdStream << endl; | |
+ stdStream << "Password: " << options.Password << endl; | |
if (ecs->NumArchives > 1) | |
stdStream << "Archives: " << ecs->NumArchives << endl; | |
if (ecs->NumArchiveErrors != 0 || ecs->NumFileErrors != 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment