python3使用mbruteforce报错

报错截图

在这里插入图片描述
在这里插入图片描述

解决方案

python3 与 python2不同的之处在python3创建一个new process需要以main module的方式
def _check_not_importing_main():
if getattr(process.current_process(), ‘_inheriting’, False):
raise RuntimeError(‘’’
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.''')

参考代码

from multiprocessing.spawn import freeze_support
from pwnlib.util.iters import mbruteforce
import hashlib

flag      = 'd0g3{71b2b5616ee2a4639a07d979ebde964c}'
msgbroken = 'd0g3{71b2b5616**2a4639**7d979**de964c}'
table = '0123456789abcdef'
assert len(table) == 16

m1 = 'd0g3{71b2b5616'
m2 = '2a4639'
m3 = '7d979'
m4 = 'de964c}'

def f(res):
    ciphier = '0596d989a2938e16bcc5d6f89ce709ad9f64d36316ab80408cb6b89b3d7f064a'
    msgbroken = m1 + res[0:2] + m2 + res[2:4] + m3 + res[4:6] + m4
    tmp = hashlib.sha256(msgbroken.encode()).hexdigest()
    if tmp == ciphier:
        return True
if __name__ == '__main__':
    freeze_support()
    res = mbruteforce(f,table,6,method='fixed')
    print(m1 + res[0:2] + m2 + res[2:4] + m3 + res[4:6] + m4 )
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值