Firefox Installed (Mac OS X)

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

Description

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

                                        
                                            #TRUSTED 6455ab7bb6aebee67b52540606ac8613919286ab13690e389a66746eff047cf411453096d238bfea71cca732e2ea9cb740740febc7972d98848f79b3b33ebbf256035171f6ffcbda2dc0579eb641d371680ce27066537085e311529d161db327ac9b4b5baa84306ffef80f50aa574ad0f9ffacaba3dc866431c6e3e058ac96931009e38ff746df16451515eb23cc2aa3fdde6543ced4a910bb7834521eac263292669102e662d8d30f1288a5e8e9bed4618e69854fb56dc61d327d9f67ba3a1aee3ecc1035c8524abe411a75de44a4b181132c7550bffea2b27b508eb7e619bcf6011ced96437c8c6ab2450dd3330da3b4324a2c3edf8a3240b8276c146065efcd6d0f2eaceafb28e170feb047884e331f1e56517496243c360b208189d17aee03c6768fee8089ea98e0e5c01763fd861d3c27197331a06b1377b8dd9104bcadc63acfe06d673e3b688fffc7ce085016d3d917f62afc2a3db9d2721a658f1b5e2389e748192e455781617304420b6dae520969a821c2765132d6691b49684ecfc9e696827c132b6fcdd21aa2145ad61460acab39dc5346080e876b813368f8d382825609c83a3d04e9cd75326838bdd174a475186033f981842b287b2bbc397bbb92396df11b11c2502ca169a5d29f0168ae9e94fd60c8706692c6aa55411050a515092495dbf8a0ec2ea0c5a5adc183f88a943502edebd714327241ebe52de0
#
# (C) Tenable Network Security, Inc.
#

include("compat.inc");

if (description)
{
  script_id(55417);
  script_version("1.16");
  script_set_attribute(attribute:"plugin_modification_date", value:"2018/06/29");

  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 in versions < 60.x *before* saving anything
esr_major_versions_pattern = "^(10\.|17\.|24\.|31\.|38\.|45\.|52\.|60\.)";
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");
}

# Check for ESR in versions >= 60.x *before* saving anything
if (version =~ esr_major_versions_pattern && empty_or_null(esr_ui))
{
  xul_file = path + '/Contents/Resources/update-settings.ini';
  cmd = 'grep -caie "ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-esr" '+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_installs(app_name:app + esr_ui);