Kioskloud Auto Password Decrpter

try to resolve password in kioskloud.

  1. // ==UserScript==
  2. // @name Kioskloud Auto Password Decrpter
  3. // @namespace KKDEC_V1
  4. // @version 1.2
  5. // @description try to resolve password in kioskloud.
  6. // @author Laria
  7. // @match https://kioskloud.io/e/*
  8. // @match https://kioskloud.xyz/e/*
  9. // @icon https://i.ibb.co/BZW3cT6/image.webp
  10. // @license MIT
  11. // @grant none
  12. // ==/UserScript==
  13. /*
  14. * == Change log ==
  15. * 1.0 - Release
  16. * 1.1 - await password validation, show result when decrypt failed
  17. * 1.2 - improve internal logic
  18. */
  19.  
  20. //utility
  21. const currentDate = new Date();
  22. function zeroPad(num, numZeros) {
  23. var n = Math.abs(num);
  24. var zeros = Math.max(0, numZeros - Math.floor(n).toString().length );
  25. var zeroString = Math.pow(10,zeros).toString().substr(1);
  26. if( num < 0 ) {
  27. zeroString = '-' + zeroString;
  28. }
  29. return zeroString+n;
  30. }
  31.  
  32. //script const db
  33. const kapdConstDB = {
  34. //password dictionary, input common password or your own password
  35. //you must change here.
  36. passwordDict: [
  37. 'password01',
  38. 'password02',
  39. 'password03',
  40. 'password04',
  41. 'password05',
  42. 'password06',
  43. ],
  44. //try to resolve decrypt time interval, def:1
  45. timeInterval: 1,
  46. logPrompt: {
  47. default: '['+GM.info.script.namespace+']',
  48. },
  49. };
  50.  
  51. //script internal db
  52. let kapdInternalDB = {
  53. elements: { //define after load
  54. container: null,
  55. confirmButton: null,
  56. inputModal: null,
  57. valiateMessage: null,
  58. },
  59. };
  60.  
  61. //utility 2
  62.  
  63. const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
  64.  
  65. //https://stackoverflow.com/questions/5525071
  66. function waitForElm(selector) {
  67. return new Promise(resolve => {
  68. if (document.querySelector(selector)) {
  69. return resolve(document.querySelector(selector));
  70. }
  71.  
  72. const observer = new MutationObserver(mutations => {
  73. if (document.querySelector(selector)) {
  74. observer.disconnect();
  75. resolve(document.querySelector(selector));
  76. }
  77. });
  78.  
  79. // If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
  80. observer.observe(document.body, {
  81. childList: true,
  82. subtree: true
  83. });
  84. });
  85. }
  86.  
  87. //input given password and resolve it
  88. async function tryToDecrypt(inputPassword) {
  89. //fill password field
  90. kapdInternalDB.elements.inputModal.value=inputPassword;
  91. //remove modal valid msg
  92. await kapdInternalDB.elements.inputModal.dispatchEvent(new Event('input', {
  93. view: window,
  94. bubbles: true,
  95. cancelable: true
  96. }));
  97. //click confirm
  98. await kapdInternalDB.elements.confirmButton.click();
  99. }
  100.  
  101. //await validation
  102. function waitForValidation() {
  103. if(kapdInternalDB.elements.valiateMessage.style.display == 'flex') return;
  104. return delay(1).then(waitForValidation);
  105. }
  106.  
  107. //decrypt procedure
  108. async function decrypt() {
  109. //main process
  110. let tryCount = 0;
  111. const startTime = performance.now();
  112. //loop in password dict
  113. for (let i = 0; i < kapdConstDB.passwordDict.length; i++) {
  114. //if not first, await validation
  115. if (i > 0) await waitForValidation();
  116. window.console.log(kapdConstDB.logPrompt.default, 'no.', i, ', try:', kapdConstDB.passwordDict[i]);
  117. await delay(kapdConstDB.timeInterval);
  118. await tryToDecrypt(kapdConstDB.passwordDict[i]);
  119. //correct password
  120. if (document.querySelector('.swal2-container') == null) {
  121. const endTime = performance.now();
  122. const durationSec = parseFloat((Math.ceil((endTime-startTime) * 100) / 100000).toFixed(2));
  123. window.console.log(kapdConstDB.logPrompt.default, 'decrypt finished.');
  124. window.console.log(kapdConstDB.logPrompt.default, 'expected password :', kapdConstDB.passwordDict[i]);
  125. window.console.log(kapdConstDB.logPrompt.default, 'tries:', tryCount, ', duration:', durationSec, 'sec');
  126. return;
  127. }
  128. tryCount ++;
  129. }
  130. const endTime = performance.now();
  131. const durationSec = parseFloat((Math.ceil((endTime-startTime) * 100) / 100000).toFixed(2));
  132. //if resolve failed,
  133. window.console.log(kapdConstDB.logPrompt.default, 'cannot find password in dict..');
  134. window.console.log(kapdConstDB.logPrompt.default, 'tries:', tryCount, ', duration:', durationSec, 'sec');
  135. //replace first dict password, show summary, focus input area
  136. await delay(100);
  137. kapdInternalDB.elements.inputModal.value = kapdConstDB.passwordDict[0];
  138. await delay(20);
  139. kapdInternalDB.elements.valiateMessage.innerHTML = `<div><b>Auto Decryption Failed</b><br><i style="font-size: 82.5%;">Please input manually..</i><br><span style="font-size: 78.5%;">( tries: ${tryCount}, dur: ${durationSec} sec )</span></div>`;
  140. await kapdInternalDB.elements.inputModal.focus();
  141. }
  142.  
  143. //register elements
  144. function registerElements() {
  145. kapdInternalDB.elements.container = document.querySelector('.swal2-container');
  146. kapdInternalDB.elements.confirmButton = kapdInternalDB.elements.container.querySelector('.swal2-confirm');
  147. kapdInternalDB.elements.inputModal = kapdInternalDB.elements.container.querySelector('.swal2-input');
  148. kapdInternalDB.elements.valiateMessage = kapdInternalDB.elements.container.querySelector('#swal2-validation-message');
  149. }
  150.  
  151. async function rootProcedure() {
  152. window.console.log(kapdConstDB.logPrompt.default,'V',GM.info.script.version, '-', GM.info.script.name);
  153. window.console.log(kapdConstDB.logPrompt.default, 'wait modal..');
  154. //await confirm button
  155. await waitForElm('.swal2-confirm');
  156. window.console.log(kapdConstDB.logPrompt.default,'modal loaded, decrypt ready');
  157. //register modal elements
  158. registerElements();
  159. //decrypt start
  160. await decrypt();
  161. window.console.log(kapdConstDB.logPrompt.default,'task finished.');
  162. }
  163.  
  164. window.addEventListener('load', () => setTimeout(rootProcedure, 100));