module.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. registerController('OnlineHashCrack_Controller', ['$api', '$scope', '$rootScope', '$interval', '$timeout', function($api, $scope, $rootScope, $interval, $timeout) {
  2. $scope.title = "Loading...";
  3. $scope.version = "Loading...";
  4. $scope.refreshInfo = (function() {
  5. $api.request({
  6. module: 'OnlineHashCrack',
  7. action: "refreshInfo"
  8. }, function(response) {
  9. $scope.title = response.title;
  10. $scope.version = "v" + response.version;
  11. })
  12. });
  13. $scope.refreshInfo();
  14. }]);
  15. registerController('OnlineHashCrack_ControlsController', ['$api', '$scope', '$rootScope', '$interval', '$timeout', function($api, $scope, $rootScope, $interval, $timeout) {
  16. $scope.install = "Loading...";
  17. $scope.installLabel = "default";
  18. $scope.processing = false;
  19. $scope.key = "Loading...";
  20. $scope.keyLabel = "default";
  21. $scope.generating = false;
  22. $scope.device = '';
  23. $scope.sdAvailable = false;
  24. $rootScope.status = {
  25. installed: false,
  26. generated: false,
  27. refreshOutput: false,
  28. refreshKnownHosts: false
  29. };
  30. $scope.refreshStatus = (function() {
  31. $api.request({
  32. module: "OnlineHashCrack",
  33. action: "refreshStatus"
  34. }, function(response) {
  35. $rootScope.status.installed = response.installed;
  36. $scope.device = response.device;
  37. $scope.sdAvailable = response.sdAvailable;
  38. if (response.processing) $scope.processing = true;
  39. $scope.install = response.install;
  40. $scope.installLabel = response.installLabel;
  41. })
  42. });
  43. $scope.handleDependencies = (function(param) {
  44. if (!$rootScope.status.installed)
  45. $scope.install = "Installing...";
  46. else
  47. $scope.install = "Removing...";
  48. $api.request({
  49. module: 'OnlineHashCrack',
  50. action: 'handleDependencies',
  51. destination: param
  52. }, function(response) {
  53. if (response.success === true) {
  54. $scope.installLabel = "warning";
  55. $scope.processing = true;
  56. $scope.handleDependenciesInterval = $interval(function() {
  57. $api.request({
  58. module: 'OnlineHashCrack',
  59. action: 'handleDependenciesStatus'
  60. }, function(response) {
  61. if (response.success === true) {
  62. $scope.processing = false;
  63. $scope.refreshStatus();
  64. $interval.cancel($scope.handleDependenciesInterval);
  65. }
  66. });
  67. }, 5000);
  68. }
  69. });
  70. });
  71. $scope.refreshStatus();
  72. }]);
  73. registerController('OnlineHashCrack_OutputController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
  74. $scope.output = 'Loading...';
  75. $scope.refreshOutput = (function() {
  76. $api.request({
  77. module: "OnlineHashCrack",
  78. action: "refreshOutput",
  79. filter: $scope.filter
  80. }, function(response) {
  81. $scope.output = response;
  82. })
  83. });
  84. $scope.clearOutput = (function() {
  85. $api.request({
  86. module: "OnlineHashCrack",
  87. action: "clearOutput"
  88. }, function(response) {
  89. $scope.refreshOutput();
  90. })
  91. });
  92. $scope.refreshOutput();
  93. $rootScope.$watch('status.refreshOutput', function(param) {
  94. if (param) {
  95. $scope.refreshOutput();
  96. }
  97. });
  98. }]);
  99. registerController('OnlineHashCrack_WPAController', ['$api', '$scope', '$rootScope', '$interval', function($api, $scope, $rootScope, $interval) {
  100. $scope.file = '';
  101. $scope.submitWPALabel = "primary";
  102. $scope.submitWPA = "Submit";
  103. $scope.working = false;
  104. $scope.selectedFile = '--';
  105. $scope.files = [];
  106. $scope.getCapFiles = function() {
  107. $api.request({
  108. module: 'OnlineHashCrack',
  109. action: 'getCapFiles'
  110. }, function(response) {
  111. $scope.files = response.files;
  112. });
  113. };
  114. $scope.submitWPAOnline = (function() {
  115. $rootScope.status.refreshOutput = false;
  116. $rootScope.status.refreshKnownHosts = false;
  117. if ($scope.selectedFile != '')
  118. $file = $scope.selectedFile;
  119. else
  120. $file = $scope.file;
  121. $api.request({
  122. module: 'OnlineHashCrack',
  123. action: 'submitWPAOnline',
  124. file: $file
  125. }, function(response) {
  126. $scope.submitWPALabel = "warning";
  127. $scope.submitWPA = "Working...";
  128. $scope.working = true;
  129. $scope.submitWPAOnlineInterval = $interval(function() {
  130. $api.request({
  131. module: 'OnlineHashCrack',
  132. action: 'submitWPAOnlineStatus'
  133. }, function(response) {
  134. if (response.success === true) {
  135. $scope.working = false;
  136. $interval.cancel($scope.submitWPAOnlineInterval);
  137. $scope.submitWPALabel = "primary";
  138. $scope.submitWPA = "Submit";
  139. $rootScope.status.refreshOutput = true;
  140. $rootScope.status.refreshKnownHosts = true;
  141. }
  142. });
  143. }, 5000);
  144. });
  145. });
  146. $scope.getCapFiles();
  147. }]);
  148. registerController('OnlineHashCrack_SettingsController', ['$api', '$scope', '$rootScope', '$timeout', function($api, $scope, $rootScope, $timeout) {
  149. $scope.settings = {
  150. email: ""
  151. };
  152. $scope.saveSettingsLabel = "primary";
  153. $scope.saveSettings = "Save";
  154. $scope.saving = false;
  155. $scope.getSettings = function() {
  156. $api.request({
  157. module: 'OnlineHashCrack',
  158. action: 'getSettings'
  159. }, function(response) {
  160. $scope.settings = response.settings;
  161. });
  162. };
  163. $scope.setSettings = function() {
  164. $scope.saveSettingsLabel = "warning";
  165. $scope.saveSettings = "Saving...";
  166. $scope.saving = true;
  167. $api.request({
  168. module: 'OnlineHashCrack',
  169. action: 'setSettings',
  170. settings: $scope.settings
  171. }, function(response) {
  172. $scope.getSettings();
  173. $scope.saveSettingsLabel = "success";
  174. $scope.saveSettings = "Saved";
  175. $timeout(function() {
  176. $scope.saveSettingsLabel = "primary";
  177. $scope.saveSettings = "Save";
  178. $scope.saving = false;
  179. }, 2000);
  180. });
  181. };
  182. $scope.getSettings();
  183. }]);