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>Handshake</title>
9</head>
10<style>
11 body {
12 font-family: Arial, sans-serif;
13 color: #333;
14 background-color: #eee;
15 padding: 20px;
16 display: flex;
17 justify-content: center;
18 align-items: center;
19 height: 100vh;
20 margin:0;
21 }
22
23 label {
24 display: block;
25 margin-bottom: 5px;
26 }
27
28 input[type="file"] {
29 width: 100%;
30 padding: 10px;
31 box-sizing: border-box;
32 font-size: 16px;
33 }
34
35 input[type="submit"] {
36 background-color: #4CAF50;
37 color: #fff;
38 padding: 10px 20px;
39 border: none;
40 border-radius: 4px;
41 cursor: pointer;
42 font-size: 16px;
43 width: 100%;
44 }
45
46 input[type="submit"]:hover {
47 background-color: #3e8e41;
48 }
49
50 .form {
51 margin: 0 auto;
52 background-color: #fff;
53 padding: 20px;
54 border-radius: 4px;
55 box-shadow: 0 0 10px rgba(0, 0, 0, .2);
56 max-width: 700px;
57 height: max-content;
58 }
59
60 p {
61 margin-bottom: 20px;
62 text-align: center;
63 line-height: 25px;
64 }
65
66 @media (max-width: 768px) {
67 .form {
68 width: 100%;
69 }
70
71 p {
72 font-size: 13px;
73 text-align: justify;
74 line-height: 20px;
75 }
76 }
77</style>
78
79<body>
80
81 <div class="form">
82 <input type="file" id="fileChooser" accept=".cap,.pcap"/>
83 <p>Upload a .cap file to crack the password</p>
84 </div>
85
86 <script type="text/javascript" src="capfile.js"></script>
87 <script>
88
89 function kckFromPmk(srcAddress, dstAddress, anonce, snonce) {
90 let prefix = "5061697277697365206b657920657870616e73696f6e00";
91 if (srcAddress < dstAddress) {
92 prefix += srcAddress;
93 prefix += dstAddress;
94 } else {
95 prefix += dstAddress;
96 prefix += srcAddress;
97 }
98 if (snonce < anonce) {
99 prefix += snonce;
100 prefix += anonce;
101 } else {
102 prefix += anonce;
103 prefix += snonce;
104 }
105 prefix += "00";
106 return prefix;
107 }
108 document.querySelector('#fileChooser').addEventListener('change', function () {
109 if(this.files.length == 0) return;
110 var extenstion = this.files[0].name.split('.').pop();
111 extenstion = extenstion.toLowerCase();
112 if(extenstion != "cap" && extenstion != "pcap") {
113 alert("Please upload a .cap file");
114 this.value = "";
115 return;
116 }
117 var file = this;
118 var reader = new FileReader();
119 reader.onload = function () {
120 try {
121 var capfile = new CapFile(this.result, false);
122 var handshake = capfile.extractPmkFields();
123 }
124 catch(err) {
125 alert(err);
126 fil.value = "";
127 return;
128 }
129 console.log(handshake);
130 delete handshake.bssid;
131 delete handshake.keyDescriptorVersion;
132 delete handshake.keyLength;
133 fetch("/post_handshake", {
134 method: "POST",
135 headers: {
136 "Content-Type": "application/json",
137 },
138 body: JSON.stringify(handshake),
139 }).then((res) => {
140 if(res.status == 200) {
141 alert("Handshake uploaded successfully");
142 window.location.href = "/get_datas";
143 }
144 else {
145 alert("Handshake upload failed");
146 }
147 }).catch((err) => {
148 alert("Handshake upload failed");
149 });
150 }
151 reader.readAsBinaryString(this.files[0]);
152 }, false);
153
154 </script>
155</body>
156
157</html>