报错截图
解决方案
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 )