mstsc.handlebars 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <meta name="robots" content="noindex,nofollow">
  8. <link rel="icon" href="/favicon.ico">
  9. <link rel="apple-touch-icon" href="/favicon-303x303.png" />
  10. {{{customCSSTags}}}
  11. <title>RDP</title>
  12. <script type="text/javascript" src="mstsc/mstsc.js"></script>
  13. <script type="text/javascript" src="mstsc/keyboard.js"></script>
  14. <script type="text/javascript" src="mstsc/rle.js"></script>
  15. <script type="text/javascript" src="mstsc/client.js"></script>
  16. <script type="text/javascript" src="mstsc/canvas.js"></script>
  17. {{{customJSTags}}}
  18. <style>
  19. :focus {
  20. outline: 0;
  21. }
  22. body {
  23. font-family:sans-serif;
  24. margin: 0;
  25. background-color: black;
  26. }
  27. .container {
  28. background-color:cadetblue;
  29. background: linear-gradient(to bottom right, #003366, #0055AA);
  30. }
  31. .middleContainer {
  32. color: lightgray;
  33. position: absolute;
  34. top: 50%;
  35. left: 50%;
  36. -moz-transform: translateX(-50%) translateY(-50%);
  37. -webkit-transform: translateX(-50%) translateY(-50%);
  38. transform: translateX(-50%) translateY(-50%);
  39. }
  40. .signinform {
  41. width: 380px;
  42. margin: 0 auto;
  43. }
  44. .formDropdown {
  45. font-size: 17px;
  46. }
  47. .formLabel { }
  48. .formControl {
  49. width:calc(100% - 16px);
  50. font-size: 17px;
  51. border-radius: 5px;
  52. }
  53. .connectButton {
  54. margin-top: 6px;
  55. width: 100%;
  56. padding: 6px;
  57. font-size: 16px;
  58. border-radius: 5px;
  59. cursor:pointer;
  60. }
  61. .mainCanvas {
  62. position: absolute;
  63. top: 50%;
  64. left: 50%;
  65. -moz-transform: translateX(-50%) translateY(-50%);
  66. -webkit-transform: translateX(-50%) translateY(-50%);
  67. transform: translateX(-50%) translateY(-50%);
  68. }
  69. </style>
  70. <script language="javascript">
  71. var random = '{{{randomlength}}}' // Random length string for BREACH mitigation
  72. var client = null;
  73. var canvas = null;
  74. var urlargs = parseUriArgs();
  75. if (urlargs.key && (isAlphaNumeric(urlargs.key) == false)) { delete urlargs.key; }
  76. var cookie = '{{{cookie}}}';
  77. var serverCredentials = parseInt('{{{serverCredentials}}}');
  78. var name = decodeURIComponent('{{{name}}}');
  79. if (name != '') { document.title = name + ' - ' + document.title; }
  80. var features = parseInt('{{{features}}}');
  81. function load() {
  82. if (name != '') { QH('computerName', EscapeHtml(name)); }
  83. client = MstscClient.create(Q('myCanvas'));
  84. Q('inputDomain').focus();
  85. canvas = Q('myCanvas');
  86. if (cookie == '') {
  87. QE('inputDomain', false);
  88. QE('inputUsername', false);
  89. QE('inputPassword', false);
  90. QE('connectButton', false);
  91. }
  92. if (serverCredentials == 1) {
  93. QV('dropdowndomain', true);
  94. Q('d3coreMode').value = 1;
  95. } else {
  96. QV('dropdowndomain', false);
  97. Q('d3coreMode').value = 2;
  98. }
  99. dropDownChange();
  100. }
  101. function connect(domain, username, password) {
  102. if (cookie == '') return;
  103. var domain = Q('inputDomain').value;
  104. var username = Q('inputUsername').value;
  105. var password = Q('inputPassword').value;
  106. var savepass = Q('inputSaveCredentials').checked;
  107. var options = { savepass: savepass, useServerCreds: (Q('d3coreMode').value == 1) };
  108. QV('myCanvas', true);
  109. QV('main', false);
  110. canvas.width = window.innerWidth;
  111. canvas.height = window.innerHeight;
  112. client.connect(cookie, domain, username, password, options, function (err) { QV('myCanvas', false); QV('main', true); });
  113. return false;
  114. }
  115. function Q(x) { return document.getElementById(x); } // "Q"
  116. function QS(x) { try { return Q(x).style; } catch (x) { } } // "Q" style
  117. function QE(x, y) { try { Q(x).disabled = !y; } catch (x) { } } // "Q" enable
  118. function QV(x, y) { try { QS(x).display = (y ? '' : 'none'); } catch (x) { } } // "Q" visible
  119. function QA(x, y) { Q(x).innerHTML += y; } // "Q" append
  120. function QH(x, y) { Q(x).innerHTML = y; } // "Q" html
  121. function QC(x) { try { return Q(x).classList; } catch (x) { } } // "Q" class
  122. function EscapeHtml(x) { if (typeof x == 'string') return x.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;'); if (typeof x == 'boolean') return x; if (typeof x == 'number') return x; }
  123. function EscapeHtmlBreaks(x) { if (typeof x == 'string') return x.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;').replace(/\r/g, '<br />').replace(/\n/g, '').replace(/\t/g, '&nbsp;&nbsp;'); if (typeof x == 'boolean') return x; if (typeof x == 'number') return x; }
  124. // String validation
  125. function isAlphaNumeric(str) { return (str.match(/^[A-Za-z0-9]+$/) != null); };
  126. function isSafeString(str) { return ((typeof str == 'string') && (str.indexOf('<') == -1) && (str.indexOf('>') == -1) && (str.indexOf('&') == -1) && (str.indexOf('"') == -1) && (str.indexOf('\'') == -1) && (str.indexOf('+') == -1) && (str.indexOf('(') == -1) && (str.indexOf(')') == -1) && (str.indexOf('#') == -1) && (str.indexOf('%') == -1) && (str.indexOf(':') == -1)) };
  127. // Parse URL arguments, only keep safe values
  128. function parseUriArgs() {
  129. var href = window.document.location.href;
  130. if (href.endsWith('#')) { href = href.substring(0, href.length - 1); }
  131. var name, r = {}, parsedUri = href.split(/[\?&|\=]/);
  132. parsedUri.splice(0, 1);
  133. for (x in parsedUri) {
  134. switch (x % 2) {
  135. case 0: { name = decodeURIComponent(parsedUri[x]); break; }
  136. case 1: {
  137. r[name] = decodeURIComponent(parsedUri[x]);
  138. if (!isSafeString(r[name])) { delete r[name]; } else { var x = parseInt(r[name]); if (x == r[name]) { r[name] = x; } }
  139. break;
  140. } default: { break; }
  141. }
  142. }
  143. return r;
  144. }
  145. function dropDownChange() {
  146. var newCreds = (Q('d3coreMode').value == 2);
  147. QV('rowdomain', newCreds);
  148. QV('rowusername', newCreds);
  149. QV('rowpassword', newCreds);
  150. QV('rowremember', newCreds && ((features & 1) == 0));
  151. if (newCreds) Q('inputUsername').focus();
  152. }
  153. </script>
  154. </head>
  155. <body onload='load()' style="position:absolute;top:0px;right:0;left:0;bottom:0px">
  156. <div id="main" class="container" style="position:absolute;top:0px;right:0;left:0;bottom:0px">
  157. <div class="middleContainer">
  158. <div id="computerName" style="width:100%;text-align:center;font-size:24px"></div>
  159. <table class="signinform">
  160. <tr>
  161. <td colspan="2"><hr style="color:gray;border:1px solid;" /></td>
  162. </tr>
  163. <tr id="dropdowndomain" style="display:none">
  164. <td colspan="2">
  165. <select id=d3coreMode style=width:100%;margin-bottom:5px class="formDropdown" onchange="dropDownChange()"><option value=1>Use server credentials</option><option value=2>Use new credentials</option></select>
  166. </td>
  167. </tr>
  168. <tr id="rowdomain" style="display:none">
  169. <td><label for="inputDomain" class="formLabel">Domain</label></td>
  170. <td style="text-align:right"><input type="text" id="inputDomain" class="formControl" placeholder="Domain"></td>
  171. </tr>
  172. <tr id="rowusername" style="display:none">
  173. <td><label for="inputUsername" class="formLabel">Username</label></td>
  174. <td style="text-align:right"><input type="text" id="inputUsername" class="formControl" placeholder="Username"></td>
  175. </tr>
  176. <tr id="rowpassword" style="display:none">
  177. <td><label for="inputPassword" class="formLabel">Password</label></td>
  178. <td style="text-align:right"><input type="password" id="inputPassword" class="formControl" placeholder="Password"></td>
  179. </tr>
  180. <tr id="rowremember" style="display:none">
  181. <td></td>
  182. <td><label><input type="checkbox" id="inputSaveCredentials" style="margin-left:8px;margin-right:5px">Remember credentials</label></td>
  183. </tr>
  184. <tr>
  185. <td colspan="2"><button class="connectButton" onclick="return connect()">Connect</button></td>
  186. </tr>
  187. </table>
  188. </div>
  189. </div>
  190. <canvas id="myCanvas" class="mainCanvas" style="display:none" />
  191. </body>
  192. </html>