module.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. registerController('PineAPPoolController', ['$api', '$scope', '$timeout', function($api, $scope, $timeout) {
  2. $scope.ssid = "";
  3. $scope.ssidPool = "";
  4. $scope.addedSSID = "";
  5. $scope.removedSSID = "";
  6. $scope.clearedSSIDPool = "";
  7. $scope.clearedSessionCounter = false;
  8. $scope.lengthError = "";
  9. $scope.poolLocation = "";
  10. $scope.downloadPool = (function() {
  11. $api.request({
  12. module: 'PineAP',
  13. action: 'downloadPineAPPool'
  14. }, function(response) {
  15. if (response.error === undefined) {
  16. window.location = '/api/?download=' + response.download;
  17. }
  18. });
  19. });
  20. $scope.addSSID = (function() {
  21. $api.request({
  22. module: 'PineAP',
  23. action: 'addSSID',
  24. ssid: $scope.ssid
  25. }, function(response) {
  26. if (response.error === undefined) {
  27. $scope.ssid = "";
  28. $scope.addedSSID = true;
  29. } else {
  30. $scope.lengthError = true;
  31. }
  32. $timeout(function(){
  33. $scope.addedSSID = false;
  34. $scope.lengthError = false;
  35. }, 2000);
  36. $scope.getPool();
  37. });
  38. });
  39. $scope.removeSSID = (function() {
  40. $api.request({
  41. module: 'PineAP',
  42. action: 'removeSSID',
  43. ssid: $scope.ssid
  44. }, function(response) {
  45. if (response.error === undefined) {
  46. $scope.ssid = "";
  47. $scope.removedSSID = true;
  48. } else {
  49. $scope.lengthError = true;
  50. }
  51. $timeout(function(){
  52. $scope.removedSSID = false;
  53. $scope.lengthError = false;
  54. }, 2000);
  55. $scope.getPool();
  56. });
  57. });
  58. $scope.getPoolLocation = (function() {
  59. $api.request({
  60. module: 'PineAP',
  61. action: 'getPoolLocation'
  62. }, function(response) {
  63. if (response.error === undefined) {
  64. $scope.poolLocation = response.poolLocation;
  65. }
  66. });
  67. });
  68. $scope.setPoolLocation = (function() {
  69. $api.request({
  70. module: 'PineAP',
  71. action: 'setPoolLocation',
  72. location: $scope.poolLocation
  73. }, function(response) {
  74. if (response.success === true) {
  75. $scope.getPoolLocation();
  76. $scope.getPool();
  77. $scope.updatedPoolLocation = true;
  78. $timeout(function(){
  79. $scope.updatedPoolLocation = false;
  80. }, 2000);
  81. }
  82. });
  83. });
  84. $scope.getPool = (function() {
  85. $api.request({
  86. module: 'PineAP',
  87. action: 'getPool'
  88. }, function(response) {
  89. $scope.ssidPool = response.ssidPool;
  90. });
  91. });
  92. $scope.clearPool = (function() {
  93. $api.request({
  94. module: 'PineAP',
  95. action: 'clearPool'
  96. }, function(response) {
  97. if (response.success === true) {
  98. $scope.ssidPool = "";
  99. $scope.clearedSSIDPool = true;
  100. $timeout(function(){
  101. $scope.clearedSSIDPool = false;
  102. }, 2000);
  103. }
  104. });
  105. $scope.getPool();
  106. });
  107. $scope.clearSessionCounter = (function() {
  108. $api.request({
  109. module: 'PineAP',
  110. action: 'clearSessionCounter'
  111. }, function(response) {
  112. if (response.success === true) {
  113. $scope.clearedSessionCounter = true;
  114. $timeout(function() {
  115. $scope.clearedSessionCounter = false;
  116. }, 2000);
  117. }
  118. })
  119. });
  120. $scope.getSSIDLineNumber = function() {
  121. var textarea = $('#ssidPool');
  122. var lineNumber = textarea.val().substr(0, textarea[0].selectionStart).split("\n").length;
  123. var ssid = textarea.val().split("\n")[lineNumber-1].trim();
  124. $("input[name='ssid']").val(ssid).trigger('input');
  125. };
  126. $scope.getPool();
  127. $scope.getPoolLocation();
  128. }]);
  129. registerController('PineAPSettingsController', ['$api', '$scope', function($api, $scope) {
  130. $scope.disableButton = false;
  131. $scope.saveAlert = false;
  132. $scope.pineAPenabling = false;
  133. $scope.settings = {
  134. allowAssociations: false,
  135. logEvents: false,
  136. pineAPDaemon: false,
  137. autostartPineAP: false,
  138. beaconResponses: false,
  139. captureSSIDs: false,
  140. broadcastSSIDs: false,
  141. connectNotifications: false,
  142. disconnectNotifications: false,
  143. broadcastInterval: 'NORMAL',
  144. responseInterval: 'NORMAL',
  145. sourceMAC: '00:00:00:00:00:00',
  146. targetMAC: 'FF:FF:FF:FF:FF:FF',
  147. interface: 'wlan1mon'
  148. };
  149. $scope.interfaces = [];
  150. $scope.togglePineAP = (function() {
  151. $scope.pineAPenabling = true;
  152. var actionString = $scope.settings.pineAPDaemon ? "disable" : "enable";
  153. $api.request({
  154. module: 'PineAP',
  155. action: actionString
  156. }, function(response) {
  157. if (response.error === undefined) {
  158. $scope.pineAPenabling = false;
  159. $scope.getSettings();
  160. }
  161. });
  162. });
  163. $scope.toggleAutoStart = (function() {
  164. var actionString = $scope.settings.autostartPineAP ? "disableAutoStart" : "enableAutoStart";
  165. $api.request({
  166. module: 'PineAP',
  167. action: actionString
  168. }, function(response) {
  169. if (response.error === undefined) {
  170. $scope.getSettings();
  171. }
  172. });
  173. });
  174. $scope.getSettings = function() {
  175. $api.request({
  176. module: 'PineAP',
  177. action: 'getPineAPSettings'
  178. }, function(response) {
  179. if (response.success === true) {
  180. $scope.settings = response.settings;
  181. }
  182. });
  183. };
  184. $scope.updateSettings = function() {
  185. $scope.disableButton = true;
  186. $api.request({
  187. module: 'PineAP',
  188. action: 'setPineAPSettings',
  189. settings: $scope.settings
  190. }, function() {
  191. $scope.getSettings();
  192. $scope.disableButton = false;
  193. });
  194. };
  195. $scope.getSettings();
  196. }]);
  197. registerController("PineAPEnterpriseController", ['$api', '$scope', '$timeout', '$interval', function($api, $scope, $timeout, $interval) {
  198. $scope.settings = {
  199. enabled: false,
  200. enableAssociations: false,
  201. ssid: "",
  202. mac: "",
  203. encryptionType: "wpa2+ccmp"
  204. };
  205. $scope.certificateSettings = {
  206. state: "California",
  207. country: "US",
  208. locality: "San Francisco",
  209. organization: "YOUR ORG",
  210. email: "bounce@example.com",
  211. commonname: "YOUR CERTIFICATE AUTHORITY"
  212. };
  213. $scope.loadingView = true;
  214. $scope.generatingCertificate = false;
  215. $scope.generateSuccess = false;
  216. $scope.savingSettings = false;
  217. $scope.savedSettings = false;
  218. $scope.certInstalled = false;
  219. $scope.data = [];
  220. $scope.error = '';
  221. $scope.view = '';
  222. $scope.detectCertificate = function() {
  223. $api.request({
  224. module: 'PineAP',
  225. action: 'detectEnterpriseCertificate'
  226. }, function(response) {
  227. if (response.installed === true) {
  228. $scope.generatingCertificate = false;
  229. $interval.cancel($scope.certInterval);
  230. $scope.view = 'normal';
  231. } else {
  232. $scope.view = 'certs';
  233. }
  234. $scope.loadingView = false;
  235. });
  236. };
  237. $scope.clearCertificate = function() {
  238. $scope.view = '';
  239. $scope.loadingView = true;
  240. $api.request({
  241. module: 'PineAP',
  242. action: 'clearEnterpriseCertificate'
  243. }, function() {
  244. $scope.view = 'certs';
  245. $scope.loadingView = false;
  246. });
  247. };
  248. $scope.clearDB = function() {
  249. $api.request({
  250. module: 'PineAP',
  251. action: 'clearEnterpriseDB'
  252. }, function() {
  253. $scope.getData();
  254. });
  255. };
  256. $scope.downloadJTR = function() {
  257. $api.request({
  258. module: 'PineAP',
  259. action: 'downloadJTRHashes'
  260. }, function(response) {
  261. if (response.error === undefined) {
  262. window.location = '/api/?download=' + response.download;
  263. }
  264. });
  265. };
  266. $scope.downloadHashcat = function() {
  267. $api.request({
  268. module: 'PineAP',
  269. action: 'downloadHashcatHashes'
  270. }, function(response) {
  271. if (response.error === undefined) {
  272. window.location = '/api/?download=' + response.download;
  273. }
  274. });
  275. };
  276. $scope.generateCertificate = function() {
  277. $scope.error = '';
  278. $scope.generatingCertificate = true;
  279. $scope.certInterval = $interval(function() {
  280. $scope.detectCertificate();
  281. }, 10000);
  282. $api.request({
  283. module: 'PineAP',
  284. action: 'generateEnterpriseCertificate',
  285. certSettings: $scope.certificateSettings
  286. }, function(response) {
  287. if (response.success) {
  288. } else {
  289. $scope.generatingCertificate = false;
  290. $scope.error = response.error;
  291. $timeout(function() {
  292. $scope.error = '';
  293. }, 5000);
  294. $interval.cancel($scope.certInterval);
  295. }
  296. });
  297. };
  298. $scope.getSettings = function() {
  299. $api.request({
  300. module: 'PineAP',
  301. action: 'getEnterpriseSettings'
  302. }, function(response) {
  303. if (response.error === undefined) {
  304. $scope.settings = response.settings;
  305. } else {
  306. $scope.error = response.error;
  307. }
  308. });
  309. };
  310. $scope.saveSettings = function() {
  311. $scope.error = '';
  312. $scope.savingSettings = true;
  313. $api.request({
  314. module: 'PineAP',
  315. action: 'setEnterpriseSettings',
  316. settings: $scope.settings
  317. }, function(response) {
  318. if (response.success) {
  319. $scope.savingSettings = false;
  320. $scope.savedSettings = true;
  321. $timeout(function(){
  322. $scope.savedSettings = false;
  323. }, 2000);
  324. } else {
  325. $scope.savingSettings = false;
  326. $scope.error = response.error;
  327. $timeout(function() {
  328. $scope.error = '';
  329. }, 5000);
  330. }
  331. });
  332. };
  333. $scope.dataInterval = $interval(function() {
  334. if ($scope.view === 'normal') {
  335. $scope.getData();
  336. }
  337. }, 5000);
  338. $scope.getData = function() {
  339. $api.request({
  340. module: 'PineAP',
  341. action: 'getEnterpriseData'
  342. }, function(response) {
  343. $scope.chalrespdata = response.chalrespdata;
  344. $scope.basicdata = response.basicdata;
  345. });
  346. };
  347. $scope.detectCertificate();
  348. $scope.getSettings();
  349. $scope.getData();
  350. $scope.$on('$destroy', function() {
  351. $interval.cancel($scope.certInterval);
  352. $interval.cancel($scope.dataInterval);
  353. });
  354. }]);
  355. registerController("CapturedHandshakesController", ['$api', '$scope', '$timeout', function($api, $scope, $timeout) {
  356. $scope.handshakes = [];
  357. $scope.clearedAllHandshakes = false;
  358. $scope.deletedHandshake = false;
  359. $scope.getAllHandshakes = function() {
  360. $api.request({
  361. module: 'PineAP',
  362. action: 'getAllHandshakes'
  363. }, function(response) {
  364. $scope.handshakes = response.handshakes;
  365. });
  366. };
  367. $scope.downloadAllHandshakes = function() {
  368. $api.request({
  369. module: 'PineAP',
  370. action: 'downloadAllHandshakes'
  371. }, function(response) {
  372. if (response.error === undefined) {
  373. window.location = '/api/?download=' + response.download;
  374. }
  375. });
  376. };
  377. $scope.clearAllHandshakes = function() {
  378. $api.request({
  379. module: 'PineAP',
  380. action: 'clearAllHandshakes'
  381. }, function(response) {
  382. if (response.success) {
  383. $scope.getAllHandshakes();
  384. $scope.clearedAllHandshakes = true;
  385. $timeout(function() {
  386. $scope.clearedAllHandshakes = false;
  387. }, 2000);
  388. }
  389. });
  390. };
  391. $scope.downloadHandshake = function(bssid) {
  392. $api.request({
  393. module: 'PineAP',
  394. action: 'downloadHandshake',
  395. bssid: bssid,
  396. type: 'pcap'
  397. }, function(response) {
  398. if(response.error === undefined) {
  399. window.location = '/api/?download=' + response.download;
  400. }
  401. });
  402. };
  403. $scope.deleteHandshake = function(bssid) {
  404. $api.request({
  405. module: 'PineAP',
  406. action: 'deleteHandshake',
  407. bssid: bssid
  408. }, function(response) {
  409. if (response.success) {
  410. $scope.getAllHandshakes();
  411. $scope.deletedHandshake = true;
  412. $timeout(function() {
  413. $scope.deletedHandshake = false;
  414. }, 2000);
  415. }
  416. })
  417. };
  418. $scope.getAllHandshakes();
  419. }]);
  420. registerController("PinejectorController", ['$api', '$scope', function($api, $scope){
  421. $scope.injecting = false;
  422. $scope.payload = "";
  423. $scope.channel = 1;
  424. $scope.frameCount = 0;
  425. $scope.delay = 100;
  426. $scope.channels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
  427. $scope.interval = null;
  428. $scope.error = null;
  429. $scope.command = null;
  430. $scope.exitCode = null;
  431. $scope.stdout = null;
  432. $scope.stderr = null;
  433. $scope.showDetails = false;
  434. $scope.toggleDetails = function() {
  435. $scope.showDetails = !$scope.showDetails;
  436. };
  437. $scope.injectFrames = function() {
  438. $scope.injecting = true;
  439. $api.request({
  440. module: 'PineAP',
  441. action: 'inject',
  442. payload: $scope.payload,
  443. channel: $scope.channel,
  444. frameCount: $scope.frameCount,
  445. delay: $scope.delay
  446. }, function(resp) {
  447. $scope.injecting = false;
  448. $scope.error = resp.error;
  449. $scope.command = resp.command;
  450. $scope.exitCode = resp.exitCode;
  451. $scope.stdout = resp.stdout;
  452. $scope.stderr = resp.stderr;
  453. });
  454. };
  455. $scope.fixPayload = function() {
  456. return $scope.payload.replace(/[\\x\-:\t ]/g, '');
  457. };
  458. $scope.checkPayload = function() {
  459. var hexStream = $scope.fixPayload();
  460. return hexStream.search(/[^a-fA-F0-9]/) === -1 && (hexStream.length % 2) === 0 && hexStream.length > 0;
  461. };
  462. $scope.checkRadiotap = function() {
  463. return $scope.payload.startsWith('0000');
  464. };
  465. }]);