Skip to content
This repository
  • 3 commits
  • 8 files changed
  • 0 comments
  • 1 contributor
6 lib/prey/plugins/actions/motion-detector/bin/README
... ... @@ -0,0 +1,6 @@
  1 +This plugin requires the 'amstracker' binary to read information
  2 +from your Macbook's accelerometer.
  3 +
  4 +Please download the AMSTracker package from
  5 +http://osxbook.com/software/sms/amstracker/ and copy the binary
  6 +into this folder.
2  lib/prey/plugins/actions/process-watcher/index.js
@@ -35,7 +35,7 @@ var ProcessWatcher = function(options){
35 35
36 36 this.loop = setInterval(function(){
37 37
38   - Processes.get('full_process_list', getter_callback);
  38 + Processes.get('process_list', getter_callback);
39 39
40 40 }, this.interval);
41 41
18 lib/prey/plugins/actions/remote-desktop/index.js
@@ -8,9 +8,9 @@
8 8 var common = require('./../../../common'),
9 9 logger = common.logger,
10 10 util = require('util'),
11   - Command = require('command'),
  11 + spawn = require('child_process').spawn,
12 12 Tunnel = require('./../../../tunnel'),
13   - emitter = require('events').EventEmitter,
  13 + Emitter = require('events').EventEmitter,
14 14 os_functions = require('./platform/' + common.os_name);
15 15
16 16 var RemoteDesktop = function(options){
@@ -39,8 +39,7 @@ var RemoteDesktop = function(options){
39 39 logger.info("Tunnel for remote desktop is open!");
40 40
41 41 var vnc_cmd = os_functions.vnc_command(self.options);
42   - // console.log("running: " + vnc_cmd);
43   - self.child = new Command(vnc_cmd);
  42 + self.child = spawn(vnc_cmd);
44 43
45 44 self.child.on('exit', function(code){
46 45 logger.info("VNC server terminated.");
@@ -48,15 +47,6 @@ var RemoteDesktop = function(options){
48 47 // self.done();
49 48 });
50 49
51   - self.child.on('error', function(e){
52   - logger.info('VNC server closed abruptly with status code ' + e.code);
53   - // console.log(e);
54   - });
55   -
56   -// self.child.on('return', function(output){
57   -// console.log(output);
58   -// });
59   -
60 50 });
61 51
62 52 this.tunnel.on('closed', function(err){
@@ -82,7 +72,7 @@ var RemoteDesktop = function(options){
82 72
83 73 };
84 74
85   -util.inherits(RemoteDesktop, emitter);
  75 +util.inherits(RemoteDesktop, Emitter);
86 76
87 77 exports.start = function(options, callback){
88 78
14 lib/prey/plugins/actions/remote-desktop/platform/mac/index.js
... ... @@ -0,0 +1,14 @@
  1 +var kickstart = "/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart";
  2 +var exec = require('child_process').exec;
  3 +
  4 +exports.stop_vnc = function(callback){
  5 + exec(kickstart + ' -stop -deactivate', callback);
  6 +}
  7 +
  8 +exports.vnc_command = function(options){
  9 + var str = kickstart + ' -activate -restart -agent -configure -access';
  10 + str += ' -on -clientopts -setvnclegacy -vnclegacy yes -setreqperm -reqperm yes';
  11 + if(options.pass) str += '-setvncpw -vncpw $desktop__vnc_pass';
  12 + // str += "-privs -all -allowAccessFor -allUsers";
  13 + return str;
  14 +}
19 lib/prey/plugins/actions/remote-terminal/index.js
@@ -8,9 +8,9 @@
8 8 var common = require('./../../../common'),
9 9 logger = common.logger,
10 10 util = require('util'),
11   - Command = require('command'),
  11 + spawn = require('child_process').spawn,
12 12 Tunnel = require('./../../../tunnel'),
13   - emitter = require('events').EventEmitter,
  13 + Emitter = require('events').EventEmitter,
14 14 os_functions = require('./platform/' + common.os_name);
15 15
16 16 var RemoteTerminal = function(options){
@@ -57,23 +57,14 @@ var RemoteTerminal = function(options){
57 57
58 58 var ssh_cmd = os_functions.ssh_server_command;
59 59
60   - this.child = new Command(ssh_cmd);
  60 + this.child = spawn(ssh_cmd);
61 61
62 62 this.child.on('exit', function(code){
63   - logger.info("SSH server not running.");
  63 + logger.info("SSH server exited.");
64 64 if(self.tunnel.is_open()) self.tunnel.close();
65 65 // self.done();
66 66 });
67 67
68   - this.child.on('error', function(e){
69   - logger.info('SSH server closed abruptly with status : ' + e.code);
70   - // console.log(e);
71   - });
72   -
73   -// self.remote_terminal_command.on('return', function(output){
74   -// console.log(output);
75   -// });
76   -
77 68 };
78 69
79 70 this.stop_ssh_server = function(){
@@ -93,7 +84,7 @@ var RemoteTerminal = function(options){
93 84
94 85 };
95 86
96   -util.inherits(RemoteTerminal, emitter);
  87 +util.inherits(RemoteTerminal, Emitter);
97 88
98 89 exports.start = function(options, callback){
99 90
9 lib/prey/plugins/actions/remote-terminal/platform/linux/index.js
@@ -5,16 +5,13 @@
5 5 // GPLv3 Licensed
6 6 //////////////////////////////////////////
7 7
8   -var base = require(process.env.ROOT_PATH + "/lib/prey/common");
  8 +var exec = require('child_process').exec;
9 9
10 10 exports.ssh_server_running = function(){
11 11
12   - base.helpers.run_cmd('ps aux | grep sshd > /dev/null && echo 1', function(output){
  12 + exec('ps aux | grep sshd > /dev/null && echo 1', function(err, stdout, stderr){
13 13
14   - if(output == null || output == "")
15   - return false;
16   - else
17   - return true;
  14 + callback(output && output.toString() == '1')
18 15
19 16 });
20 17
18 lib/prey/plugins/actions/remote-terminal/platform/mac/index.js
... ... @@ -0,0 +1,18 @@
  1 +//////////////////////////////////////////
  2 +// Prey JS Terminal Module Mac Functions
  3 +// (c) 2011 - Fork Ltd.
  4 +// by Tomas Pollak - http://forkhq.com
  5 +// GPLv3 Licensed
  6 +//////////////////////////////////////////
  7 +
  8 +var exec = require('child_process').exec;
  9 +
  10 +exports.ssh_server_running = function(){
  11 +
  12 + exec('echo "test" | nc localhost 22 &> /dev/null && echo 1', function(err, stdout, stderr){
  13 +
  14 + callback(output && output.toString() == '1')
  15 +
  16 + });
  17 +
  18 +}
20 test/action.js
@@ -11,16 +11,22 @@ console.log("loading " + module_name);
11 11
12 12 var mod = require(__dirname + '/../lib/prey/plugins/actions/' + module_name);
13 13
14   -mod.start({}, function(err){
  14 +var instance = mod.start({}, function(err){
15 15 console.log(err);
16 16 });
17 17
18   -(mod.events || []).forEach(function(ev){
19   - mod.on(ev), function(data){
20   - console.log("Event triggered " + ev);
21   - if(data) console.log(data);
22   - }
23   -})
  18 +if(instance && mod.events){
  19 +
  20 + mod.events.forEach(function(ev){
  21 +
  22 + instance.on(ev, function(data){
  23 + console.log("Event triggered " + ev);
  24 + if(data) console.log(data);
  25 + });
  26 +
  27 + });
  28 +
  29 +}
24 30
25 31 process.on('SIGINT', function () {
26 32 console.log(' >> Got Ctrl-C!');

No commit comments for this range

Something went wrong with that request. Please try again.