python中的BruteForce攻击程序不工作

2024-06-01 08:59:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我开发了一个zipfile密码破解器,它可以进行暴力攻击。zipfile的密码是1234。当我运行程序时,它会给我一个错误:

Traceback (most recent call last):
  File "C:\Users\Kartikey\Desktop\cracking\bruteforce\bruteforce.py", line 51, in <module>
    zf.extractall(password)
  File "C:\Python27\lib\zipfile.py", line 1040, in extractall
    self.extract(zipinfo, path, pwd)
  File "C:\Python27\lib\zipfile.py", line 1028, in extract
    return self._extract_member(member, path, pwd)
  File "C:\Python27\lib\zipfile.py", line 1069, in _extract_member
    targetpath = os.path.join(targetpath, arcname)
  File "C:\Python27\lib\ntpath.py", line 84, in join
    result_path = result_path + '\\'
TypeError: can only concatenate tuple (not "str") to tuple

代码如下:

^{pr2}$

有什么想法吗?在


Tags: pathinpyself密码libpwdline
1条回答
网友
1楼 · 发布于 2024-06-01 08:59:36

itertools.combinations_with_replacement()生成带有单个字符而不是字符串的元组:

>>> import itertools
>>> gen = itertools.combinations_with_replacement('1234', 3)
>>> next(gen)
('1', '1', '1')

使用''.join()将它们组成一个字符串:

^{pr2}$

但是请注意,zf.extractall()的第一个参数是一个路径,而不是密码。您正在尝试将内容提取到由生成的密码命名的路径。我怀疑那是你想做的。在

使用pwd关键字参数指定密码:

zf.extractall(pwd=password)

相关问题 更多 >