Lucene search
+L

MySQL Server Installed (Linux)

🗓️ 30 Sep 2019 00:00:00Reported by TenableType 
nessus
 nessus
🔗 www.tenable.com👁 22 Views

MySQL Server Installed on Linux. Checks for MySQL Server presence

Code
#TRUSTED 970e3925dbf5a6fc04481f15b5c5272982907454ee9bc4a49d0a77e58ec2cbb217045addff196c87598623b40c19b31b5a3746e990d071a0e373ab242e3fe08d9465c8913f62330bcbcb86846349e6b41211ae300408ba39e98ac73a9a25d9162b2cd2e8ee7312eac3fb7b62aeb406258f4ca35fb139216a5be65a1d0eede4836488ad9f01ed612234eb3959782ae92db375c694b660231c3c5c5d3dd0578b2707de836c7e915e519d75e0642a38a9fbc823698a66200ff68f14b8060a17073334ee31854187c55494996cf1c782b2f5a0ecdd849f5cf01708c71644dc12e3f79f0b7af6c23a3928ba67e907fddf02c5c24cfbff50cc9127c78f7f8d394faad0bdd37fd3613a230ef77cc2cb040ba79bf134a519e73ac6131d4b20d613a8dccd7d0047c1a02e636b13c196d1e32eb8a75d128f0ecf7961c39c6e51d8c7fdfe952822db9920d361885e7b7a5a185c86c8eaba87bd928d853563538338e9b8fd3e36bc7ffac574d8d0c78816a62bbc932c8abd8d3ba465dad1e73ee2f9657dc898e3d045b20d012fd4ae93b22d77c8cdd4ebcdd1298914f3f9cb6b3d33715a7bd59820f22b65a1caa528d4908702859335dc1861b1f3ce4348b8f5e9dff370887853cb072b5ea525e042f3f3d5366a3617342a7a5d1cb5d3783ed800cc897874b32afba119b072aa6bd5e4b5919e037c78a33b8228d3b1b84a5ae8ac0192d1eca2
#TRUST-RSA-SHA256 1f10c3b1cbe2b03ea9400b0201b0f1e26a5f44efa8c79ce0d3686e54571a8b455adc9c61aceea1a6919248b360782765236e2927a28c8ef30f108f7459e396420974da4c889b0cfefbe7e750c68f57ffe2dd88f33b561565fc57a321fd2f94bcae14a9c51d6df57f2192a29c40a4b61c8dffa2a7a43529d64010b219602d3ba9149c7598e18c5aab8106a6af4eb67812b409fbb204810bbfca5519c89b2e6050f2696b7ce854bffd146f2c11d7b38d472f5716a102d6bf98e4164a3f78f704b8fa06c924e1f80e57d53e7eb2e81e750149d92eba95bc0a76557ddb67e5b4c0e3f89a3cda66153ff0c7bbabb2d6853d156723f23174dbfb300897d188e92e7c8425edc69eff5926c6418012a7f0cb742368c29b24fac4909f9a45b0b226c7031eb2fb32be676d29fe88d942ca9f12b00da95fde512adcf6f6748e4224f3a6fd57fe7bc3b24aa956bac51980263a4dd0b7d30a647a79b8a268213e24fef86ec80e5f759b036e6b062b455733bd15ef59b2e8a1ded6a7f20e7a10532cfb310a7b12a1d7c6d9063dc281bf2b2d5695abac0f5c0db299787c055190958b99c6c2d7f57f7dbf80c6597d07e7be803b83d7e3b1d1e689aa851da9c2e5cc384c1eb8710b5b4f415e59b01ad8ee51958c62def933c6ffdc98c99f500d0ec91621abbe9e4780d38d7138f00d50e25bf8d23c4de36cbc637dc947b59d547bb62d9330b59c31
#
# (C) Tenable Network Security, Inc.
#

include("compat.inc");

if (description)
{
  script_id(129468);
  script_version("1.11");
  script_set_attribute(attribute:"plugin_modification_date", value:"2026/05/21");

  script_name(english:"MySQL Server Installed (Linux)");
  script_summary(english:"Checks for MySQL Server on Linux");

  script_set_attribute(attribute:"synopsis", value:
"MySQL Server is installed on the remote Linux host.");
  script_set_attribute(attribute:"description", value:
"MySQL Server is installed on the remote Linux host.");
  script_set_attribute(attribute:"solution", value:"n/a");
  script_set_attribute(attribute:"risk_factor", value:"None");

  script_set_attribute(attribute:"plugin_publication_date", value:"2019/09/30");

  script_set_attribute(attribute:"plugin_type", value:"local");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:mysql:mysql");

  script_set_attribute(attribute:"agent", value:"unix");
  script_set_attribute(attribute:"asset_inventory", value:"True");
  script_set_attribute(attribute:"asset_inventory_category", value:"software_enumeration");
  script_end_attributes();

  script_category(ACT_GATHER_INFO);
  script_family(english:"Databases");

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

  script_dependencies("ssh_get_info.nasl", "command_builder_init.nasl");
  script_require_keys("Host/local_checks_enabled", "Host/uname");
  script_require_ports("Host/RedHat/release", "Host/CentOS/release", "Host/Debian/release", "Host/Ubuntu/release", "Host/RockyLinux/release");

  exit(0);
}

include('install_func.inc');
include('local_detection_nix.inc');

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

var release, packages, keys, os, regex;
var rpm = FALSE;
var cpe='cpe:/a:mysql:mysql';
var timeout, depth=10, res, path, buf;
var exclude_dirs = ['/bin', '/boot', '/dev', '/etc', '/lib', '/media', '/mnt', '/proc', '/run',
    '/sbin', '/srv', '/sys', '/tmp'];

# Determine OS and installed packages
packages= get_kb_list("Host/*/rpm-list");
keys = keys(packages);
if(!isnull(keys))
   packages = packages[keys[0]];

if(!isnull(packages))
{
  #see link for package names, looking for Database server and related tools
  #https://dev.mysql.com/doc/refman/8.0/en/linux-installation-rpm.html
  regex = "^(mysql(-community|-commercial|)-server-([0-9\\.]+-?[0-9])[^\|]+).*$";
  rpm = TRUE;
}
else
{
  # Get package list
  packages = get_kb_list("Host/*/dpkg-l");
  keys = keys(packages);
  if(!isnull(keys))
    packages = packages[keys[0]];


  if (empty_or_null(packages))
    audit(AUDIT_PACKAGE_LIST_MISSING);

  regex = "^ii +(mysql-server-core-[0-9\\.]+ +([0-9\\.]+-[0-9][\+]?[a-z]+[0-9\\.].*? ).*)$";
  rpm = FALSE;
}

# Determine if MySql Server is installed and attempt to get version
var app = 'MySQL Server';

var matches = pgrep(pattern:regex, string:packages);
if (empty_or_null(matches)) dbg::detailed_log(lvl:1, msg:'MySQL Server does not seem to be installed via System Package Manager.');

foreach var package (split(matches, sep:'\n'))
{
  matches = pregmatch(pattern:regex, string:package);
  if (empty_or_null(matches)) continue;

  var extra = {};
  extra["Package"] = matches[1];

  var version = UNKNOWN_VER;
  if(!rpm)
  {
    if (!empty_or_null(matches[2]))
      version = matches[2];
  }
  else #for rpm, there is distinction between commercial and community so the version is in the 3rd block
  {
    if (!empty_or_null(matches[3]))
      version = matches[3];
  }
  # All detections for this block will be via pkg mgr
  var extra_no_report = make_array( 'Detection', 'Local', 'Managed by OS', 'True', 'Managed', '1');

  register_install(
    app_name : app,
    vendor : 'MySQL',
    product : 'MySQL',
    path     : '/usr/sbin/mysqld',
    version  : version,
    extra_no_report:extra_no_report,
    cpe      : cpe
  );
}

###
# Search MySQL Server instances distributed via self-contained tarball
###

if (thorough_tests)
{
  timeout = 1800;
  depth = 99;
}

ldnix::init_plugin();
info_connect(exit_on_fail:TRUE);

# the config file for package installed mysql-server is /etc/my.cnf
var mysql_config_files = ldnix::find_executable(paths:'/', bin:'mysql_config', timeout:timeout, depth:depth, excluded:exclude_dirs);
if (isnull(res)) dbg::detailed_log(lvl:1, msg:'No MySQL Server found on this server.');

# check the existence of some other files to ensure it's a complete install instead of just a file
var pattern = "version='([0-9.]+)'";
var match;
foreach var mysql_config_file (mysql_config_files)
{
  path = mysql_config_file - 'mysql_config';
  if ( ldnix::file_exists(file:path+'mysqld') &&
      ldnix::file_exists(file:path+'mysql') &&
      ldnix::file_exists(file:path+'mysqlcheck')
  )
  {
    buf = ldnix::run_cmd_template_wrapper(template:strcat('grep -E "', pattern, '" \'$1$\''), args:[mysql_config_file]);
    if (empty_or_null(buf))
    {
      version = UNKNOWN_VER;
    }
    else
    {
      match = pregmatch(string:buf, pattern:pattern);
      if(match)
        version = match[1];
    }

    register_install(
      app_name : app,
      vendor  : 'MySQL',
      product : 'MySQL',
      path    : path,
      version : version,
      extra_no_report:make_array( 'Detection', 'Local'),
      cpe      : cpe
    );
  }
}
if(info_t == INFO_SSH)
  ssh_close_connection();

get_install_count(app_name:app, exit_if_zero:true);

report_installs(app_name:app);

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

21 May 2026 00:00Current
5.8Medium risk
Vulners AI Score5.8
22