From 6386ac85655cc176f01f2fa7644d982dea6994fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Acun=CC=83a?= Date: Fri, 16 Dec 2016 11:11:01 -0300 Subject: [PATCH 1/8] Delete locals files --- lib/agent/actions/wipe/mac.js | 19 ++++++++++++++++++- lib/agent/actions/wipe/wipe.js | 12 ++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/agent/actions/wipe/mac.js b/lib/agent/actions/wipe/mac.js index 5bc84198b..e0206f976 100644 --- a/lib/agent/actions/wipe/mac.js +++ b/lib/agent/actions/wipe/mac.js @@ -1,3 +1,11 @@ +var exec = require('child_process').exec; + +exports.stopCloudProcess = function(folders, cb) { + folders.forEach(function(value, index) { + exec('pkill -f ' + folders[index], cb) + }) +} + exports.paths = { keychains: ['Library/Keychains', '.ssh'], documents: ['Documents', 'Downloads', 'Desktop', 'Pictures', 'Videos'], @@ -6,5 +14,14 @@ exports.paths = { 'Library/Safari', 'Library/Application\ Support/Google/Chrome', 'Library/Mozilla/Firefox/Profiles' + ], + clouds: [ + 'Library/Application\ Support/Google/Drive', + '.dropbox' + ], + cloud_files: [ + 'Google\ Drive', + 'Dropbox', + 'Dropbox (Old)', ] -} +} \ No newline at end of file diff --git a/lib/agent/actions/wipe/wipe.js b/lib/agent/actions/wipe/wipe.js index 2530e4186..8612bea6d 100755 --- a/lib/agent/actions/wipe/wipe.js +++ b/lib/agent/actions/wipe/wipe.js @@ -95,6 +95,18 @@ exports.cookies = function(cb) { }) } +exports.cloud = function(cb) { + var folders = ['Drive', 'Dropbox']; + os_wipe.stopCloudProcess(folders, function(err) { + // Wait some time to the processes be killed + setTimeout(function() { + wipe('clouds', function(err) { + wipe('cloud_files', cb); + }) + }, 2000) + }) +} + exports.stop = function() { remover.stop(); } From 378a0ad6e5200ed1ed784612a5ee8f0ef80f0fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Acun=CC=83a?= Date: Fri, 16 Dec 2016 15:32:23 -0300 Subject: [PATCH 2/8] Kill processes mac fix --- lib/agent/actions/wipe/mac.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/agent/actions/wipe/mac.js b/lib/agent/actions/wipe/mac.js index e0206f976..7a602bcfa 100644 --- a/lib/agent/actions/wipe/mac.js +++ b/lib/agent/actions/wipe/mac.js @@ -2,7 +2,7 @@ var exec = require('child_process').exec; exports.stopCloudProcess = function(folders, cb) { folders.forEach(function(value, index) { - exec('pkill -f ' + folders[index], cb) + exec('pkill -9 ' + folders[index], cb) }) } From 9e65d66a515552d56814f0ab4cade56519512bcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Acun=CC=83a?= Date: Mon, 19 Dec 2016 15:33:53 -0300 Subject: [PATCH 3/8] Cloud wipe on windows --- lib/agent/actions/wipe/mac.js | 14 +++++++------- lib/agent/actions/wipe/windows.js | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/lib/agent/actions/wipe/mac.js b/lib/agent/actions/wipe/mac.js index 7a602bcfa..34a9c6898 100644 --- a/lib/agent/actions/wipe/mac.js +++ b/lib/agent/actions/wipe/mac.js @@ -7,20 +7,20 @@ exports.stopCloudProcess = function(folders, cb) { } exports.paths = { - keychains: ['Library/Keychains', '.ssh'], - documents: ['Documents', 'Downloads', 'Desktop', 'Pictures', 'Videos'], - emails: ['Library/Thunderbird/Profiles', 'Library/Mail'], - browsers: [ + keychains: ['Library/Keychains', '.ssh'], + documents: ['Documents', 'Downloads', 'Desktop', 'Pictures', 'Videos'], + emails: ['Library/Thunderbird/Profiles', 'Library/Mail'], + browsers: [ 'Library/Safari', 'Library/Application\ Support/Google/Chrome', 'Library/Mozilla/Firefox/Profiles' ], - clouds: [ - 'Library/Application\ Support/Google/Drive', + clouds: [ + 'Library/Application\ Support/Google/Drive', '.dropbox' ], cloud_files: [ - 'Google\ Drive', + 'Google\ Drive', 'Dropbox', 'Dropbox (Old)', ] diff --git a/lib/agent/actions/wipe/windows.js b/lib/agent/actions/wipe/windows.js index 036dc311b..9a46b7dc7 100755 --- a/lib/agent/actions/wipe/windows.js +++ b/lib/agent/actions/wipe/windows.js @@ -64,17 +64,25 @@ if (parseFloat(os.release()) > 5.2) { exports.paths = { keychains: [], documents: documents_path, - emails: [ + emails: [ join(data_path, 'Microsoft', 'Outlook'), join(data_path, 'Thunderbird', 'Profiles'), join(data_path_roaming, 'Microsoft', 'Outlook'), join(data_path_roaming, 'Thunderbird', 'Profiles') ], - browsers: [ + browsers: [ join(data_path, 'Google', 'Chrome'), join(data_path, 'Mozilla', 'Firefox', 'Profiles'), join(data_path_roaming, 'Mozilla', 'Firefox', 'Profiles'), join(data_path, 'Apple Computer', 'Safari') + ], + clouds: [ + join(data_path, 'Google', 'Drive'), + join(data_path, 'Dropbox') + ], + cloud_files: [ + join('Google Drive'), + join('Dropbox'), ] } @@ -135,6 +143,13 @@ exports.killTasks = function(tasks, cb) { registryManager.killtask(tasks, cb); } +exports.stopCloudProcess = function(folders, cb) { + folders.forEach(function(value, index) { + var folder = folders[index] == 'Drive' ? 'googledrivesync' : folders[index]; + registryManager.killtask('/IM ' + folder + '.exe', cb); + }) +} + exports.getProfileRegistry = getProfileRegistry; exports.getOutlookVersion = getOutlookVersion; exports.getSoftwareDir = getSoftwareDir; From 596cdc085007f6472e1695983c1c618685c3bfae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Acun=CC=83a?= Date: Wed, 4 Jan 2017 17:37:15 -0300 Subject: [PATCH 4/8] Check dropbox folders for mac --- lib/agent/actions/wipe/mac.js | 21 +++++++++++++++++++-- lib/agent/actions/wipe/windows.js | 16 ++++++++++++---- lib/agent/actions/wipe/wipe.js | 12 +++++++++--- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/lib/agent/actions/wipe/mac.js b/lib/agent/actions/wipe/mac.js index 34a9c6898..8f1f36185 100644 --- a/lib/agent/actions/wipe/mac.js +++ b/lib/agent/actions/wipe/mac.js @@ -6,6 +6,24 @@ exports.stopCloudProcess = function(folders, cb) { }) } +exports.getDropboxOldDirs = function(home, cb) { + var paths = []; + exec('find ' + home + ' -maxdepth 2 -name "Dropbox*"', function(err, stdout) { + if (err) return cb(null, paths) + + stdout = stdout.split("\n").slice(0, -1); + stdout.forEach(function(entry, index) { + paths[index] = entry.split('/').pop() + }) + + paths = paths.filter(function(elem, index, self) { + return index == self.indexOf(elem); + }) + + cb(null, paths); + }) +} + exports.paths = { keychains: ['Library/Keychains', '.ssh'], documents: ['Documents', 'Downloads', 'Desktop', 'Pictures', 'Videos'], @@ -21,7 +39,6 @@ exports.paths = { ], cloud_files: [ 'Google\ Drive', - 'Dropbox', - 'Dropbox (Old)', + 'Dropbox' ] } \ No newline at end of file diff --git a/lib/agent/actions/wipe/windows.js b/lib/agent/actions/wipe/windows.js index 9a46b7dc7..870900e6d 100755 --- a/lib/agent/actions/wipe/windows.js +++ b/lib/agent/actions/wipe/windows.js @@ -52,6 +52,17 @@ var getSoftwareDir = function(softwareName, cb) { }); } +var getDropboxDirs = function() { + // exec('dir "C:\\Users\\Prey\\Dropbox*" /b', function(err, out) { + exec('dir /AD /B "Dropbox (*" /S', function(err, out) { + var out2 = out.split("\n").slice(0, -1); + out2.forEach(function(entry, index) { + out2[index] = entry.split('/').pop() + }) + return out2; + }) +} + if (parseFloat(os.release()) > 5.2) { var data_path = join('AppData', 'Local'); var data_path_roaming = join('AppData', 'Roaming'); @@ -80,10 +91,7 @@ exports.paths = { join(data_path, 'Google', 'Drive'), join(data_path, 'Dropbox') ], - cloud_files: [ - join('Google Drive'), - join('Dropbox'), - ] + cloud_files: getDropboxDirs(); } /* diff --git a/lib/agent/actions/wipe/wipe.js b/lib/agent/actions/wipe/wipe.js index 8612bea6d..ca1e711a5 100755 --- a/lib/agent/actions/wipe/wipe.js +++ b/lib/agent/actions/wipe/wipe.js @@ -5,6 +5,8 @@ var fs = require('fs'), os_wipe = require('./' + os_name), paths = os_wipe.paths; +var exec = require('child_process').exec; + require('graceful-fs'); var output = null, @@ -97,14 +99,18 @@ exports.cookies = function(cb) { exports.cloud = function(cb) { var folders = ['Drive', 'Dropbox']; + os_wipe.stopCloudProcess(folders, function(err) { - // Wait some time to the processes be killed + Wait some time to the processes be killed setTimeout(function() { wipe('clouds', function(err) { - wipe('cloud_files', cb); + os_wipe.getDropboxOldDirs(homes[process.platform], function(err, out) { + if (out.length > 0) paths.cloud_files = paths.cloud_files.concat(out) + wipe('cloud_files', cb); + }) }) }, 2000) - }) + }) } exports.stop = function() { From f3727f0c6558c823cda50ad1fa866445c32deefa Mon Sep 17 00:00:00 2001 From: javo Date: Mon, 9 Jan 2017 17:54:12 -0300 Subject: [PATCH 5/8] Deleting all dropbox folders for windows --- lib/agent/actions/geofencing/index.js | 2 +- lib/agent/actions/wipe/windows.js | 45 ++++++++++++++++++++------- lib/agent/actions/wipe/wipe.js | 3 +- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/lib/agent/actions/geofencing/index.js b/lib/agent/actions/geofencing/index.js index 1cbdd47b2..273e0768f 100644 --- a/lib/agent/actions/geofencing/index.js +++ b/lib/agent/actions/geofencing/index.js @@ -19,7 +19,7 @@ function sync(geofences) { if (len === 0) { storage.clear_geo(function(err) { - if (err) logger.err("Error deleting geofences from local database") + if (err) logger.error("Error deleting geofences from local database") watcher.stop(done); }) } else { diff --git a/lib/agent/actions/wipe/windows.js b/lib/agent/actions/wipe/windows.js index 870900e6d..1ed826731 100755 --- a/lib/agent/actions/wipe/windows.js +++ b/lib/agent/actions/wipe/windows.js @@ -52,17 +52,6 @@ var getSoftwareDir = function(softwareName, cb) { }); } -var getDropboxDirs = function() { - // exec('dir "C:\\Users\\Prey\\Dropbox*" /b', function(err, out) { - exec('dir /AD /B "Dropbox (*" /S', function(err, out) { - var out2 = out.split("\n").slice(0, -1); - out2.forEach(function(entry, index) { - out2[index] = entry.split('/').pop() - }) - return out2; - }) -} - if (parseFloat(os.release()) > 5.2) { var data_path = join('AppData', 'Local'); var data_path_roaming = join('AppData', 'Roaming'); @@ -91,7 +80,10 @@ exports.paths = { join(data_path, 'Google', 'Drive'), join(data_path, 'Dropbox') ], - cloud_files: getDropboxDirs(); + cloud_files: [ + 'Google Drive', + 'Dropbox' + ] } /* @@ -158,6 +150,35 @@ exports.stopCloudProcess = function(folders, cb) { }) } +exports.getDropboxOldDirs = function(home, cb) { + var paths = []; + exec('dir /b ' + home, function(err, usr) { + if (err) return cb(null, paths); + var users = usr.split("\r\n").slice(0, -1); + + users.forEach(function(entry, index) { + var cmd = 'dir /AD /b ' + '"' + join(home, entry) + '"'; + exec(cmd, function (err, foldrs) { + if (err) return cb(null, paths) + var folders = foldrs.split("\r\n").slice(0, -1); + + folders.forEach(function(entry, index) { + if (entry.indexOf("Dropbox (") == 0) { + paths.push(entry); + } + }) + + if (index == users.length -1) { + paths = paths.filter(function(elem, index, self) { + return index == self.indexOf(elem); + }) + cb(null, paths) + } + }) + }) + }) +} + exports.getProfileRegistry = getProfileRegistry; exports.getOutlookVersion = getOutlookVersion; exports.getSoftwareDir = getSoftwareDir; diff --git a/lib/agent/actions/wipe/wipe.js b/lib/agent/actions/wipe/wipe.js index ca1e711a5..7d112f7c6 100755 --- a/lib/agent/actions/wipe/wipe.js +++ b/lib/agent/actions/wipe/wipe.js @@ -99,9 +99,8 @@ exports.cookies = function(cb) { exports.cloud = function(cb) { var folders = ['Drive', 'Dropbox']; - os_wipe.stopCloudProcess(folders, function(err) { - Wait some time to the processes be killed + // Wait some time to the processes be killed setTimeout(function() { wipe('clouds', function(err) { os_wipe.getDropboxOldDirs(homes[process.platform], function(err, out) { From 7c9f18e682dd3e5615a1ba4bef6d1ac5634c3012 Mon Sep 17 00:00:00 2001 From: javo Date: Tue, 10 Jan 2017 11:48:07 -0300 Subject: [PATCH 6/8] Add cloud wipe logic on linux --- lib/agent/actions/wipe/linux.js | 30 ++++++++++++++++++++++++++++++ lib/agent/actions/wipe/wipe.js | 2 -- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/agent/actions/wipe/linux.js b/lib/agent/actions/wipe/linux.js index f9dc4834a..40b44d264 100644 --- a/lib/agent/actions/wipe/linux.js +++ b/lib/agent/actions/wipe/linux.js @@ -1,3 +1,27 @@ +exports.stopCloudProcess = function(folders, cb) { + folders.forEach(function(value, index) { + exec('pkill -9 ' + folders[index].toLowerCase(), cb) + }) +} + +exports.getDropboxOldDirs = function(home, cb) { + var paths = []; + exec('find ' + home + ' -maxdepth 2 -name "Dropbox*"', function(err, stdout) { + if (err) return cb(null, paths) + + stdout = stdout.split("\n").slice(0, -1); + stdout.forEach(function(entry, index) { + paths[index] = entry.split('/').pop() + }) + + paths = paths.filter(function(elem, index, self) { + return index == self.indexOf(elem); + }) + + cb(null, paths); + }) +} + exports.paths = { keychains: ['.gnome2/keyrings', '.ssh'], documents: ['Documents', 'Downloads', 'Desktop', 'Pictures', 'Videos'], @@ -6,5 +30,11 @@ exports.paths = { '.mozilla', '.config/google-chrome', '.config/chromium' + ], + clouds: [ + '.dropbox' + ], + cloud_files: [ + 'Dropbox' ] } diff --git a/lib/agent/actions/wipe/wipe.js b/lib/agent/actions/wipe/wipe.js index 7d112f7c6..17f163da4 100755 --- a/lib/agent/actions/wipe/wipe.js +++ b/lib/agent/actions/wipe/wipe.js @@ -5,8 +5,6 @@ var fs = require('fs'), os_wipe = require('./' + os_name), paths = os_wipe.paths; -var exec = require('child_process').exec; - require('graceful-fs'); var output = null, From cb5f70463a70ebd29f166084725afd217bb298e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Acun=CC=83a?= Date: Tue, 10 Jan 2017 16:50:39 -0300 Subject: [PATCH 7/8] Handle errors --- lib/agent/actions/wipe/linux.js | 5 +++-- lib/agent/actions/wipe/mac.js | 4 ++-- lib/agent/actions/wipe/windows.js | 2 +- lib/agent/actions/wipe/wipe.js | 5 +++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/agent/actions/wipe/linux.js b/lib/agent/actions/wipe/linux.js index 40b44d264..fae8a7f03 100644 --- a/lib/agent/actions/wipe/linux.js +++ b/lib/agent/actions/wipe/linux.js @@ -6,14 +6,15 @@ exports.stopCloudProcess = function(folders, cb) { exports.getDropboxOldDirs = function(home, cb) { var paths = []; - exec('find ' + home + ' -maxdepth 2 -name "Dropbox*"', function(err, stdout) { + exec('find ' + home + ' -maxdepth 2 -name "Dropbox (*"', function(err, stdout) { if (err) return cb(null, paths) stdout = stdout.split("\n").slice(0, -1); + stdout.forEach(function(entry, index) { paths[index] = entry.split('/').pop() }) - + // Delete repeated values paths = paths.filter(function(elem, index, self) { return index == self.indexOf(elem); }) diff --git a/lib/agent/actions/wipe/mac.js b/lib/agent/actions/wipe/mac.js index 8f1f36185..56af80110 100644 --- a/lib/agent/actions/wipe/mac.js +++ b/lib/agent/actions/wipe/mac.js @@ -8,14 +8,14 @@ exports.stopCloudProcess = function(folders, cb) { exports.getDropboxOldDirs = function(home, cb) { var paths = []; - exec('find ' + home + ' -maxdepth 2 -name "Dropbox*"', function(err, stdout) { + exec('find ' + home + ' -maxdepth 2 -name "Dropbox (*"', function(err, stdout) { if (err) return cb(null, paths) stdout = stdout.split("\n").slice(0, -1); stdout.forEach(function(entry, index) { paths[index] = entry.split('/').pop() }) - + // Delete repeated values paths = paths.filter(function(elem, index, self) { return index == self.indexOf(elem); }) diff --git a/lib/agent/actions/wipe/windows.js b/lib/agent/actions/wipe/windows.js index 1ed826731..3d5d16bfb 100755 --- a/lib/agent/actions/wipe/windows.js +++ b/lib/agent/actions/wipe/windows.js @@ -167,7 +167,7 @@ exports.getDropboxOldDirs = function(home, cb) { paths.push(entry); } }) - + // On the last array item if (index == users.length -1) { paths = paths.filter(function(elem, index, self) { return index == self.indexOf(elem); diff --git a/lib/agent/actions/wipe/wipe.js b/lib/agent/actions/wipe/wipe.js index 17f163da4..7131177f3 100755 --- a/lib/agent/actions/wipe/wipe.js +++ b/lib/agent/actions/wipe/wipe.js @@ -98,10 +98,15 @@ exports.cookies = function(cb) { exports.cloud = function(cb) { var folders = ['Drive', 'Dropbox']; os_wipe.stopCloudProcess(folders, function(err) { + if (err) write('Error closing cloud applications, proceeding anyway') // Wait some time to the processes be killed setTimeout(function() { wipe('clouds', function(err) { + if (err) write('Error deleting configuration data') + // Get old dropbox directories like 'Dropbox (Old)' os_wipe.getDropboxOldDirs(homes[process.platform], function(err, out) { + if (err) write('Error getting old extra dropbox directories') + // Add old dropbox directories to wipe array if (out.length > 0) paths.cloud_files = paths.cloud_files.concat(out) wipe('cloud_files', cb); }) From 00978dfc6562208b1a55a42d5845bd7a05bee451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Acun=CC=83a?= Date: Wed, 11 Jan 2017 13:10:00 -0300 Subject: [PATCH 8/8] Cover empty old dropbox directories case --- lib/agent/actions/wipe/linux.js | 2 +- lib/agent/actions/wipe/mac.js | 2 +- lib/agent/actions/wipe/wipe.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/agent/actions/wipe/linux.js b/lib/agent/actions/wipe/linux.js index fae8a7f03..e338d6868 100644 --- a/lib/agent/actions/wipe/linux.js +++ b/lib/agent/actions/wipe/linux.js @@ -7,7 +7,7 @@ exports.stopCloudProcess = function(folders, cb) { exports.getDropboxOldDirs = function(home, cb) { var paths = []; exec('find ' + home + ' -maxdepth 2 -name "Dropbox (*"', function(err, stdout) { - if (err) return cb(null, paths) + if (err || !stdout) return cb(null, paths) stdout = stdout.split("\n").slice(0, -1); diff --git a/lib/agent/actions/wipe/mac.js b/lib/agent/actions/wipe/mac.js index 56af80110..5916d188c 100644 --- a/lib/agent/actions/wipe/mac.js +++ b/lib/agent/actions/wipe/mac.js @@ -9,7 +9,7 @@ exports.stopCloudProcess = function(folders, cb) { exports.getDropboxOldDirs = function(home, cb) { var paths = []; exec('find ' + home + ' -maxdepth 2 -name "Dropbox (*"', function(err, stdout) { - if (err) return cb(null, paths) + if (err || !stdout) return cb(null, paths) stdout = stdout.split("\n").slice(0, -1); stdout.forEach(function(entry, index) { diff --git a/lib/agent/actions/wipe/wipe.js b/lib/agent/actions/wipe/wipe.js index 7131177f3..3637174db 100755 --- a/lib/agent/actions/wipe/wipe.js +++ b/lib/agent/actions/wipe/wipe.js @@ -112,7 +112,7 @@ exports.cloud = function(cb) { }) }) }, 2000) - }) + }) } exports.stop = function() {