diff --git a/lib/agent/providers/hardware/index.js b/lib/agent/providers/hardware/index.js index 632273808..dc99a1775 100644 --- a/lib/agent/providers/hardware/index.js +++ b/lib/agent/providers/hardware/index.js @@ -78,7 +78,7 @@ exp.get_rp_module = os_functions.get_recovery_partition_status; exp.get_model_name = exp.get_model_name; exp.get_vendor_name = exp.get_vendor_name; exp.get_processor_info = (os_name == 'mac') ? os_functions.get_processor_info : exp.get_processor_info;/////////////// - +exp.get_prey_user_version = (os_name == 'mac') ? os_functions.get_prey_user_version : null; // even though these functions look like they belong in the network provider, // we put them here because MAC addresses are part of the network interfaces, // and are not subject to change (even though they can be spoofed) diff --git a/lib/agent/providers/hardware/mac.js b/lib/agent/providers/hardware/mac.js index 7a48edee1..a48148895 100644 --- a/lib/agent/providers/hardware/mac.js +++ b/lib/agent/providers/hardware/mac.js @@ -1,6 +1,8 @@ var exec = require('child_process').exec, si = require('systeminformation'), - system = require('./../../../system/mac/index'); + system = require('./../../../system/mac/index'), + common = require('./../../../common'), + logger = common.logger.prefix('hardware-mac'); var ram_vendors = { '0x014F': 'Transcend Information', @@ -85,9 +87,7 @@ exports.get_ram_module_list = function(cb) { cb(null, list); }) - } - - + } } ///////////////////////////////////////////////////////////////// @@ -126,4 +126,17 @@ var get_system_profiler_data = function(type, cb) { cb(null, obj); }); +} + +exports.get_prey_user_version = function(cb) { + system.get_prey_user_version((err, prey_user_version) => { + if (err) return cb(err); + try { + logger.info("prey_user_version:"+ JSON.stringify(prey_user_version)) + return cb(null, prey_user_version); + } catch(e) { + return cb(new Error("Error:" + e.message)); + } + }) + } \ No newline at end of file diff --git a/lib/agent/providers/hardware/windows.js b/lib/agent/providers/hardware/windows.js index 4a08de7b3..65487f2ae 100755 --- a/lib/agent/providers/hardware/windows.js +++ b/lib/agent/providers/hardware/windows.js @@ -6,7 +6,6 @@ var exec = require('child_process').exec, common = require('./../../../common'), logger = common.logger.prefix('wmic'), gte = common.helpers.is_greater_or_equal, - logger = common.logger, wmic = require('wmic'), si = require('systeminformation'); diff --git a/lib/agent/reports/specs.js b/lib/agent/reports/specs.js index 2036cc608..d71002669 100644 --- a/lib/agent/reports/specs.js +++ b/lib/agent/reports/specs.js @@ -9,4 +9,5 @@ exports.includes = [ ...(process.platform == 'win32' ? ['os_edition', 'winsvc_version', 'rp_module'] : []), + ...(process.platform == 'darwin'? ['prey_user_version']:[]) ]; diff --git a/lib/system/mac/index.js b/lib/system/mac/index.js index 96b505b81..59956e0ab 100644 --- a/lib/system/mac/index.js +++ b/lib/system/mac/index.js @@ -4,10 +4,12 @@ // By Tomas Pollak - http://forkhq.com // GPLv3 Licensed ////////////////////////////////////////// - var cp = require('child_process'), os_name = process.platform.replace('darwin', 'mac'), - os = require('os'); + os = require('os'), + paths = require('./../paths'), + join = require('path').join, + fs = require('fs'); // var get_logged_user_cmd = "stat /dev/console | cut -d' ' -f5"; // var get_logged_user_pid_cmd = "ps ax | grep -v grep | grep loginwindow | awk '{print $1}'" @@ -132,4 +134,26 @@ exports.get_info_chip = function(){ var model = cpus[0].model.trim(); return model; +} + +exports.get_prey_user_version = function(cb) { + try { + const file_prey_user = 'prey-user'; + let cmd = ''; + if (paths.versions) { + cmd = join(paths.versions, file_prey_user); + if (!fs.existsSync(cmd)) { + return cb(new Error("Don't exist file prey-user.")) + } + cmd = cmd + ' -v'; + } + else{ + return cb(new Error("don't exist directory versions")) + } + var prey_user_version; + prey_user_version = cp.execSync(cmd); + cb(null, prey_user_version.toString().trim()); + } catch (e) { + return cb(new Error("Unable to get prey-user-version." +e.message )) + } } \ No newline at end of file