Firefox Installed (Mac OS X)

2011-06-24T00:00:00
ID MACOSX_FIREFOX_INSTALLED.NASL
Type nessus
Reporter Tenable
Modified 2018-05-16T00:00:00

Description

Mozilla Firefox is installed on the remote Mac OS X host.

                                        
                                            #TRUSTED 7c59fdaecebcb2590411a4a5034804019de848d42bd03feef5c539862146189c2c683c343d02ce496858e974d984ec433999d2b12660e22e90ca21b3e16eec0fc8ad8ec0115a80f3c0bff60217e1c8901bf22be77c05fc85ac29156987019fc3822118c0781d19e8be2fb202ac1d8b9ec29b6da45ed15415682d92724d7d89a56b8f9d4c6df1bc2a08083c7d1385a6dc71c4025206b8886c60b2998a38758dc2fb2fa262a529bfaa6b62d573841d2998f004117ee1ab2096bf9b5803574fbe2b1a19ba5892a0d763bd294b4525aa29a9e7cfa4d5d531333e888cd2f1bd57361630e97552e7487e90c853053e31c05f0e5724623b634da702adccc71d0a0f42901af1212d1104faeb84108c9d706c0ee65c72fb16e59cdc90e7bb7cbec6084310cb66ccf7be7eda1fadd3bad920c1cf73d3bd4bcb7cb601c0124ee593a28b0783b9ddbceeddcd03c16be9eabde9f8de1910cb0063d39bd11552664d2db2f611aed6bb6f6b10cdef5d439f9094ad6f484e99ab2db39f4a959504767a519beaa22c4c09c039dc6184d6941a63d5240047942194b2543546c06edc68ec82ccb30d77d84cb51c60136c94d5e69bbc04d0fef6a33275683b28f12ae7fd90c7657bddd7398a78202dd76c081f8ef486652f06616fd891b4a89c5bd07ac2bdc1f12972a14b07f7e22e8d4f5e342c5a74b2e07cc592c21a4c69913152df95791c73bd21a8
#
# (C) Tenable Network Security, Inc.
#

include("compat.inc");

if (description)
{
  script_id(55417);
  script_version("1.14");
  script_set_attribute(attribute:"plugin_modification_date", value:"2018/05/16");

  script_name(english:"Firefox Installed (Mac OS X)");
  script_summary(english:"Gets the Firefox version from Info.plist.");

  script_set_attribute(attribute:"synopsis", value:
"The remote Mac OS X host contains a web browser.");
  script_set_attribute(attribute:"description", value:
"Mozilla Firefox is installed on the remote Mac OS X host.");
  script_set_attribute(attribute:"see_also", value:"https://www.mozilla.org/en-US/firefox/new/");
  script_set_attribute(attribute:"solution", value:"n/a");
  script_set_attribute(attribute:"risk_factor", value:"None");

  script_set_attribute(attribute:"plugin_publication_date", value:"2011/06/24");

  script_set_attribute(attribute:"plugin_type", value:"local");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:mozilla:firefox");
  script_end_attributes();

  script_category(ACT_GATHER_INFO);
  script_family(english:"MacOS X Local Security Checks");

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

  script_dependencies("ssh_get_info.nasl");
  script_require_keys("Host/local_checks_enabled", "Host/MacOSX/Version");

  exit(0);
}

include("audit.inc");
include("global_settings.inc");
include("misc_func.inc");
include("ssh_func.inc");
include("macosx_func.inc");
include("install_func.inc");

app = "Firefox";

if(sshlib::get_support_level() >= sshlib::SSH_LIB_SUPPORTS_COMMANDS)
  enable_ssh_wrappers();
else disable_ssh_wrappers();

if (!get_kb_item("Host/local_checks_enabled")) audit(AUDIT_LOCAL_CHECKS_NOT_ENABLED);

os = get_kb_item("Host/MacOSX/Version");
if (!os) audit(AUDIT_OS_NOT, "Mac OS X");

kb_base = "MacOSX/Firefox";

esr_ui = '';

path = '/Applications/Firefox.app';
plist = path + '/Contents/Info.plist';
cmd =  'plutil -convert xml1 -o - \'' + plist + '\' | ' +
  'grep -A 1 CFBundleShortVersionString | ' +
  'tail -n 1 | ' +
  'sed \'s/.*string>\\(.*\\)<\\/string>.*/\\1/g\'';
version = exec_cmd(cmd:cmd);
if (!strlen(version)) audit(AUDIT_NOT_INST, app);

if (version !~ "^[0-9]") audit(AUDIT_VER_FAIL, app);

# Check for ESR *before* saving anything
esr_major_versions_pattern = "^(10\.|17\.|24\.|31\.|38\.|45\.|52\.)";
if (version =~ esr_major_versions_pattern)
{
  xul_file = path + '/Contents/MacOS/XUL';
  cmd = 'grep -caie "esr.releasechannel\\|/builds/slave/\\(rel-\\)\\?m-esr[0-9]\\+-" '+xul_file;

  is_esr = exec_cmd(cmd:cmd);

  # is_esr will be any of :
  # 0 - not ESR, no matching lines
  # > 0 - ESR, more than zero matching lines
  # not an integer - ERROR of some sort
  if (strlen(is_esr))
  {
    if (is_esr =~ "[^0-9]") audit(AUDIT_FN_FAIL, "'"+cmd+"'", "a non-numeric value");

    is_esr = int(is_esr);

    if (is_esr > 0)
    {
      set_kb_item(name:kb_base+"/is_esr", value:TRUE);
      esr_ui = ' ESR';
    }
  }
  else audit(AUDIT_FN_FAIL, "'"+cmd+"'", "zero-length output");
}

set_kb_item(name:kb_base+"/Installed", value:TRUE);
set_kb_item(name:kb_base+"/Version", value:version);
set_kb_item(name:kb_base+"/Path", value:path);

register_install(
  app_name:app + esr_ui,
  path:path,
  version:version,
  cpe:"cpe:/a:mozilla:firefox");

report =
  '\n  Path    : ' + path +
  '\n  Version : ' + version + esr_ui + '\n';

report_installs(app_name:app + esr_ui, extra:report);