<html>
<script type="text/javascript">// <![CDATA[
/*
* getWpaPskKeyFromPassphrase( pass: string, ssid: string)
* -> string of 64 hex digits
*
* Compute the binary PMK from passphrase and SSID as used in the WPA-PSK
* wireless encryption standard. The passphrase is usually entered by
* the user as a string of at most 63 characters; the binary key is usually
* displayed as a sequence of 64 hex digits.
*/
function getWpaPskKeyFromPassphrase(pass, salt) {
/* pad string to 64 bytes and convert to 16 32-bit words */
function stringtowords(s, padi) {
/* return a 80-word array for later use in the SHA1 code */
var z = new Array(80);
var j = -1, k = 0;
var n = s.length;
for (var i = 0; i < 64; i++) {
var c = 0;
if (i < n) {
c = s.charCodeAt(i);
} else if (padi) {
/* add 4-byte PBKDF2 block index and
standard padding for the final SHA1 input block */
if (i == n) c = (padi >>> 24) & 0xff;
else if (i == n + 1) c = (padi >>> 16) & 0xff;
else if (i == n + 2) c = (padi >>> 8) & 0xff;
else if (i == n + 3) c = padi & 0xff;
else if (i == n + 4) c = 0x80;
}
if (k == 0) { j++; z[j] = 0; k = 32; }
k -= 8;
z[j] = z[j] | (c << k);
}
if (padi) z[15] = 8 * (64 + n + 4);
return z;
}
/* compute the intermediate SHA1 state after processing just
the 64-byte padded HMAC key */
function initsha(w, padbyte) {
var pw = (padbyte << 24) | (padbyte << 16) | (padbyte << 8) | padbyte;
for (var t = 0; t < 16; t++) w[t] ^= pw;
var s = [ 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0 ];
var a = s[0], b = s[1], c = s[2], d = s[3], e = s[4];
var t;
for (var k = 16; k < 80; k++) {
t = w[k-3] ^ w[k-8] ^ w[k-14] ^ w[k-16];
w[k] = (t<<1) | (t>>>31);
}
for (var k = 0; k < 20; k++) {
t = ((a<<5) | (a>>>27)) + e + w[k] + 0x5A827999 + ((b&c)|((~b)&d));
e = d; d = c; c = (b<<30) | (b>>>2); b = a; a = t & 0xffffffff;
}
for (var k = 20; k < 40; k++) {
t = ((a<<5) | (a>>>27)) + e + w[k] + 0x6ED9EBA1 + (b^c^d);
e = d; d = c; c = (b<<30) | (b>>>2); b = a; a = t & 0xffffffff;
}
for (var k = 40; k < 60; k++) {
t = ((a<<5) | (a>>>27)) + e + w[k] + 0x8F1BBCDC + ((b&c)|(b&d)|(c&d));
e = d; d = c; c = (b<<30) | (b>>>2); b = a; a = t & 0xffffffff;
}
for (var k = 60; k < 80; k++) {
t = ((a<<5) | (a>>>27)) + e + w[k] + 0xCA62C1D6 + (b^c^d);
e = d; d = c; c = (b<<30) | (b>>>2); b = a; a = t & 0xffffffff;
}
s[0] = (s[0] + a) & 0xffffffff;
s[1] = (s[1] + b) & 0xffffffff;
s[2] = (s[2] + c) & 0xffffffff;
s[3] = (s[3] + d) & 0xffffffff;
s[4] = (s[4] + e) & 0xffffffff;
return s;
}
/* compute the intermediate SHA1 state of the inner and outer parts
of the HMAC algorithm after processing the padded HMAC key */
var hmac_istate = initsha(stringtowords(pass, 0), 0x36);
var hmac_ostate = initsha(stringtowords(pass, 0), 0x5c);
/* output is created in blocks of 20 bytes at a time and collected
in a string as hexadecimal digits */
var hash = '';
var i = 0;
while (hash.length < 64) {
/* prepare 20-byte (5-word) output vector */
var u = [ 0, 0, 0, 0, 0 ];
/* prepare input vector for the first SHA1 update (salt + block number) */
i++;
var w = stringtowords(salt, i);
/* iterate 4096 times an inner and an outer SHA1 operation */
for (var j = 0; j < 2 * 4096; j++) {
/* alternate inner and outer SHA1 operations */
var s = (j & 1) ? hmac_ostate : hmac_istate;
/* inline the SHA1 update operation */
var a = s[0], b = s[1], c = s[2], d = s[3], e = s[4];
var t;
for (var k = 16; k < 80; k++) {
t = w[k-3] ^ w[k-8] ^ w[k-14] ^ w[k-16];
w[k] = (t<<1) | (t>>>31);
}
for (var k = 0; k < 20; k++) {
t = ((a<<5) | (a>>>27)) + e + w[k] + 0x5A827999 + ((b&c)|((~b)&d));
e = d; d = c; c = (b<<30) | (b>>>2); b = a; a = t & 0xffffffff;
}
for (var k = 20; k < 40; k++) {
t = ((a<<5) | (a>>>27)) + e + w[k] + 0x6ED9EBA1 + (b^c^d);
e = d; d = c; c = (b<<30) | (b>>>2); b = a; a = t & 0xffffffff;
}
for (var k = 40; k < 60; k++) {
t = ((a<<5) | (a>>>27)) + e + w[k] + 0x8F1BBCDC + ((b&c)|(b&d)|(c&d));
e = d; d = c; c = (b<<30) | (b>>>2); b = a; a = t & 0xffffffff;
}
for (var k = 60; k < 80; k++) {
t = ((a<<5) | (a>>>27)) + e + w[k] + 0xCA62C1D6 + (b^c^d);
e = d; d = c; c = (b<<30) | (b>>>2); b = a; a = t & 0xffffffff;
}
/* stuff the SHA1 output back into the input vector */
w[0] = (s[0] + a) & 0xffffffff;
w[1] = (s[1] + b) & 0xffffffff;
w[2] = (s[2] + c) & 0xffffffff;
w[3] = (s[3] + d) & 0xffffffff;
w[4] = (s[4] + e) & 0xffffffff;
if (j & 1) {
/* XOR the result of each complete HMAC-SHA1 operation into u */
u[0] ^= w[0]; u[1] ^= w[1]; u[2] ^= w[2]; u[3] ^= w[3]; u[4] ^= w[4];
} else if (j == 0) {
/* pad the new 20-byte input vector for subsequent SHA1 operations */
w[5] = 0x80000000;
for (var k = 6; k < 15; k++) w[k] = 0;
w[15] = 8 * (64 + 20);
}
}
/* convert output vector u to hex and append to output string */
for (var j = 0; j < 5; j++)
for (var k = 0; k < 8; k++) {
var t = (u[j] >>> (28 - 4 * k)) & 0x0f;
hash += (t < 10) ? t : String.fromCharCode(87 + t);
}
}
/* return the first 32 key bytes as a hexadecimal string */
return hash.substring(0, 64);
}
function fshowkey(s) {
if (s == "") { for (var i = 0; i < 64; i++) s += "\u00a0"; }
var elem = document.getElementById("fhexkey");
while (elem.hasChildNodes()) elem.removeChild(elem.firstChild);
elem.appendChild(document.createTextNode(s));
}
function fcalc() {
var ssid = document.getElementById("fssid").value;
var pass = document.getElementById("fpass").value;
fshowkey("");
if (ssid.length < 1) {
alert("ERROR: You must enter the network SSID string.");
document.getElementById("fssid").focus();
return;
}
if (ssid.length > 32) {
alert("ERROR: The SSID string must not be longer than 32 characters.");
document.getElementById("fssid").focus();
return;
}
if (pass.length < 1) {
alert("ERROR: Passphrase must be at least 8 characters.");
document.getElementById("fpass").focus();
return;
}
if (pass.length > 63) {
alert("ERROR: Passphrase must not be longer than 63 characters.");
document.getElementById("fpass").focus();
return;
}
for (var i = 0; i < pass.length; i++)
if (pass.charCodeAt(i) < 1 || pass.charCodeAt(i) > 126) {
alert("ERROR: Passphrase contains strange characters.");
document.getElementById("fpass").focus();
return;
}
for (var i = 0; i < ssid.length; i++)
if (ssid.charCodeAt(i) < 1 || ssid.charCodeAt(i) > 126) {
alert("ERROR: SSID string contains strange characters.");
document.getElementById("fssid").focus();
return;
}
var hash = getWpaPskKeyFromPassphrase(pass, ssid);
fshowkey(hash);
}
function fclear() {
document.getElementById("fssid").value = "";
document.getElementById("fpass").value = "";
fshowkey("");
}
function ftest() {
document.getElementById("fssid").value = "TP-LINK";
document.getElementById("fpass").value = "12345678";
fcalc();
var n = document.getElementById("fhexkey");
if (n && n.firstChild && n.firstChild.data ==
"1eecc652f354863e9f985a96d48545c4994e0d21b04955432b60c2600c0743da") {
alert("test passed succesfully");
} else {
alert("ERROR: test failed, please get a better webbrowser");
}
}
// ]]></script>
<div lang="en" class="mainpanel">
<div class="topbar">
<h1>WPA PMK calculation</h1>
<span class="subtitle">From passphrase to hexadecimal key</span>
</div>
<table class="formtbl">
<tbody><tr>
<td>Network SSID:</td>
<td><input type="text" name="fssid" id="fssid" size="48" maxlength="32"></td>
a1014671152
- 粉丝: 0
- 资源: 1
最新资源
- C#ASP.NET幼儿园管理系统源码数据库 SQL2008源码类型 WebForm
- 【重磅,更新!】空间杜宾模型和检验代码+结果解释(2024版)
- unity类似于QQ截图功能
- 虚拟机中安装MAC黑苹果系统需要的解锁软件
- 2草药信息增加(头歌)(1).cpp
- 基于matlab实现LQR+PID车辆横纵向控制算法实现(自动驾驶控制算法)+项目源码+模型+文档说明+代码注释
- 【老生谈算法】matlab实现机器视觉硬币检测与计数系统研究
- winform - GDI 绘制三万个方块并实时刷新.zip,某个点位是否焊接完毕,焊接完了就由红变蓝色实时刷新
- C#星辰物料采购仓储系统源码数据库 SQL2008源码类型 WebForm
- 基于MATLAB车牌识别系统实现系统【GUI带界面】.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈