我一直在尝试用 C++ 编写一个简单的暴力破解密码破解程序来打开我很久以前锁定的旧 zip 文件。
我正在尝试从程序中调用 pkunzip 。我知道执行此操作的唯一方法是使用 system() 命令。如 system("astring"); 中所示。问题是我需要一次又一次地将新密码转储到字符串中,直到成功为止。这需要在我发送到 DOS 的命令中插入一个变量。这就是我迷路的地方。所以代码可能看起来像这样...
system("pkunzip lockedFile -s[the password variable here]")
另外,整个想法可能很糟糕,所以如果有更好的方法,请直接说出来。
另外,我可以使用 cd\ 命令进入正确的目录,还是只需将相关文件转储到与 C++ 项目本身相同的目录中。任何帮助或一般指示将不胜感激。
哈特
I have been trying to write a simple brute force password cracker in C++ to open an old zip file that I locked a very long time ago.
I am trying to call pkunzip from the program. The only way I know to do this is using the system() command. As in system("astring");. The problem is that I need to dump a new password into the string each time over and over until I get a hit. That would require inserting a variable into to command that I am sending to DOS. That is where I get lost. So the code could look something like this...
system("pkunzip lockedFile -s[the password variable here]")
Also, this entire idea may be horrible, so if there is a better way then please just say.
Also, can I use a cd\ command to get to the proper directory, or do you just have to dump the relevant files in the same directory as the C++ project itself. Any help or general pointers would be much appreciated.
m.hatter
发布评论
评论(2)
这样可以吗?
我使用双反斜杠转义为单个反斜杠,以便 cd 命令正常工作。
希望这有帮助,
此致,
汤姆.
Would this do?
I used the double backslash to escape into a single backslash for the
cd
command to work.Hope this helps,
Best regards,
Tom.
您始终可以使用 sprintf 来创建字符串。如:
如果您厌倦了调用此外部程序,您可能需要使用像 zip utils 库。
You could always use a
sprintf
to create the string. As in:If you're sick of calling this external program, you might want to handle the Zip file internally with a library like the zip utils library.