forked from bacher09/pwgen-for-bios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
decrypt_bios.min.js
37 lines (37 loc) · 15.2 KB
/
decrypt_bios.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var keyboardDict={2:"1",3:"2",4:"3",5:"4",6:"5",7:"6",8:"7",9:"8",10:"9",11:"0",16:"q",17:"w",18:"e",19:"r",20:"t",21:"y",22:"u",23:"i",24:"o",25:"p",30:"a",31:"s",32:"d",33:"f",34:"g",35:"h",36:"j",37:"k",38:"l",44:"z",45:"x",46:"c",47:"v",48:"b",49:"n",50:"m"},SONY="sony",SAMSUNG="samsung",PHOENIX="phoenix",HP_COMPAQ="hp_compaq_phoenix",FSI_PHOENIX="fsi_phoenix",FSI_L_PHOENIX="fsi_l_phoenix",FSI_P_PHOENIX="fsi_p_phoenix",FSI_S_PHOENIX="fsi_s_phoenix",FSI_X_PHOENIX="fsi_x_phoenix",INSYDE="insyde",
HP_MINI="hp_mini",FSI_20_DEC_NEW="fsi_20_dec_new",FSI_20_DEC_OLD="fsi_20_dec_old",FSI_HEX="fsi_hex",DELL_TAG="dell_tag",DELL_HDD_NEW="dell_hdd_new",DELL_HDD_OLD="dell_hdd_old",DELL_SERIES_PREFIX=["595B","D35B","2A7B","A95B"],encscans=[5,16,19,9,50,3,37,17,31,23,6,21,48,25,38,34,10,2,44,47,22,20,7,24,36,35,49,32,30,8,45,33,4,11,18,46],chartabl2A7B="012345679abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0",scancods="\x00\u001b1234567890-=\b\tqwertyuiop[]\r\u00ffasdfghjkl;'`\u00ff\\zxcvbnm,./",
encData=[1732584193,-271733879,-1732584194,271733878],MD5magic_o=[3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,
681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745];function CorectBits(a){if("object"==typeof a){for(var b=0;b<a.length;b++)a[b]|=0;return a}return a|0}var MD5magic=CorectBits(MD5magic_o);function SignedToUnsigned(a){return a>>>0}
"undefined"==typeof Object.keys&&(Object.keys=function(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&b.push(c);return b});var keys=Object.keys;"undefined"==typeof values&&(values=function(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&b.push(a[c]);return b});Array.prototype.swap=function(a,b){var c=this[a];this[a]=this[b];this[b]=c;return this};Array.prototype.getUnique=function(){for(var a={},b=[],c=0,d=this.length;c<d;++c)this[c]in a||(b.push(this[c]),a[this[c]]=1);return b};
"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return String(this).replace(/^\s+|\s+$/g,"")});function min(a,b){return a<b?a:b}function CreateHashTable2(a,b){for(var c=min(a.length,b.length),d={},e=0;e<c;e++)d[a[e]]=b[e];return d}function CreateHashTable3(a){for(var b={},c=0;c<a.length;c++)b[a[c][0]]=a[c][1];return b}function CreateHashTable(a,b){return"undefined"==typeof b?CreateHashTable3(a):CreateHashTable2(a,b)}function ord(a){return a.charCodeAt(0)}
function chr(a){return String.fromCharCode(a)}function div(a,b){return a/b-a%b/b}function copy_array(a){for(var b=[],c=0;c<a.length;c++)b[c]=a[c];return b}function StringToArray(a){var b=[];if("object"==typeof a)return a;for(var c=0;c<a.length;c++)b[c]=a.charCodeAt(c);return b}function ArrayToString(a){for(var b="",c=0;c<a.length;c++)b+=chr(a[c]);return b}function toByte(a){for(var b=0;b<a.length;b++)a[b]&=255;return a}function isHexNumber(a){return/[0-9ABCDEF]/gi.test(a)}
function isDecNumber(a){return/[0-9]/gi.test(a)}function filterFalse(a){for(var b=[],c=0;c<a.length;c++)a[c]&&b.push(a[c]);return b}function ByteArrToIntArr(a){for(var b=a.length>>2,c=[],d=0;d<=b;d++)c[d]=a[4*d]|a[4*d+1]<<8|a[4*d+2]<<16|a[4*d+3]<<24;return c}function StringToIntArr(a){return"object"==typeof a?ByteArrToIntArr(a):ByteArrToIntArr(StringToArray(a))}function IntToByteArr(a){var b=[];b[0]=a&255;b[1]=a>>8&255;b[2]=a>>16&255;b[3]=a>>24&255;return b}
function IntArrToByteArr(a){for(var b=[],c=0;c<a.length;c++)b=b.concat(IntToByteArr(a[c]));return b}function fill_zero(a,b,c){for(;b<c;b++)a[b]=0;return a}var keyboardDictDigits=CreateHashTable(keys(keyboardDict).slice(0,9),values(keyboardDict).slice(0,9)),keyboardDictChars=CreateHashTable(keys(keyboardDict).slice(10,36),values(keyboardDict).slice(10,36));function keyToAscii(a){for(var b="",c=0;c<a.length&&0!=a[c];c++){if(32>a[c]||127<a[c])return;b+=String.fromCharCode(a[c])}return b}
function keyboardEncToAscii(a){for(var b="",c=0;c<a.length&&0!=a[c];c++)if(a[c]in keyboardDict)b+=keyboardDict[a[c]];else return"";return b}function badCRC16(a,b){for(var c="undefined"==typeof b?0:b,d=0,d=0;d<a.length;d++)for(var c=c^a[d],e=8;e--;)c=c&1?c>>1^8193:c>>1;return c}
function bruteForce(a,b,c,d,e,f){b="undefined"==typeof b?0:b;e="undefined"==typeof e?3:e;f="undefined"==typeof f?7:f;var g=[0,0,0,0,0,0,0];if(16383<a)return"Bad hash";var h=0;c=keys(!0==("undefined"==typeof d?!0:d)?keyboardDictChars:!0==("undefined"==typeof c?!1:c)?keyboardDictDigits:keyboardDict);for(d=c.length;;){for(var l=Math.random()*d,k=0;7>k;k++)g[k]=c[Math.floor(l%d)],l*=7;h++;if(5E4<h)return"No";for(k=e;k<=f;k++)if(badCRC16(g.slice(0,k),b)==a)return g=g.slice(0,k),keyboardEncToAscii(g)}}
function calc_in(a){return[a[1]>>1,a[1]>>6|a[0]<<2,a[0]>>3]}function begin_calc(a,b){var c=[];"string"==typeof a&&(a=StringToArray(a));c[0]=a[b[3]];c[1]=a[b[3]]>>5|(a[b[2]]>>5|a[b[2]]<<3)&241;c[2]=a[b[2]]>>2;c[3]=a[b[2]]>>7|a[b[1]]<<1;c[4]=a[b[1]]>>4|a[b[0]]<<4;c=c.concat(calc_in(a));return toByte(c)}function end_calc(a,b,c,d){for(var e=0,f=[],g=0;8>g;g++)e=170,b[g]&1&&(e^=a[c[0]]),b[g]&2&&(e^=a[c[1]]),b[g]&4&&(e^=a[c[2]]),b[g]&8&&(e^=a[1]),b[g]&16&&(e^=a[0]),f[g]=d[e%d.length];return f}
function calc_suffix_shortcut(a,b,c){var d=StringToArray(a);b=begin_calc(d,b);return"2A7B"==dell_get_serial_line(a)?end_calc(d,b,c,StringToArray(chartabl2A7B)):end_calc(d,b,c,encscans)}function calc_suffix_tag(a){return calc_suffix_shortcut(a,[1,2,3,4],[4,3,2])}function calc_suffix_hdd_new(a){return calc_suffix_shortcut(a,[1,10,9,8],[8,9,10])}
function calc_suffix_hdd_old(a){var b=[49,49,49,49,49];a=StringToArray(a);for(var b=b.concat(calc_in(a)),c=5;8>c;c++){var d=170;b[c]&8&&(d^=a[1]);b[c]&16&&(d^=a[0]);b[c]=encscans[d%encscans.length]}return b}
function blockEncode(a,b,c,d,e,f){function g(a,c,b){c=c[b>>4][i&3];return SignedToUnsigned(a)/Math.pow(2,32-c)|SignedToUnsigned(a)<<c|0}function h(c,d,e){return l+b(c,k,m,p,MD5magic[e]+a[d])|0}var l=encData[0]|0,k=encData[1]|0,m=encData[2]|0,p=encData[3]|0,q=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]],n;for(i=0;64>i;i++){switch(i>>4){case 0:n=h(c,i&15,i);break;case 1:n=h(d,5*i+1&15,i);break;case 2:n=h(e,3*i+5&15,i);break;case 3:n=h(f,7*i&15,i)}l=p;p=m;m=k;k=g(n,q,i)+k|0}return CorectBits([l+
encData[0],k+encData[1],m+encData[2],p+encData[3]])}function dell_get_serial_line(a){return"object"==typeof a?ArrayToString(a.slice(a.length-4,a.length)).toUpperCase():a.substr(a.length-4,a.length).toUpperCase()}function dell_get_serial_main(a){return a.substr(0,a.length-4)}
function choseEncode(a,b){function c(a,c,b){return(b^c)&a^b}function d(a,c,b){return(a^c)&b^c}function e(a,c,b){return c^a^b}function f(a,c,b){return(a|~b)^c}function g(a,c,b,d,e){return a(c,b,d)+e|0}function h(a,c,b,d,e){return a(c,b,d)+-e|0}function l(a,c,b){return(~b^c)&a^~b}function k(a,c,b){return~c^a^b}function m(a,c,b){return(~a|~b)^c}return"D35B"==dell_get_serial_line(b)?blockEncode(a,g,c,d,e,f):blockEncode(a,h,l,d,k,m)}
function answerToString(a,b){for(var c=a[0]%9,d="",e=0;16>e;e++)"2A7B"==dell_get_serial_line(b)?d+=chartabl2A7B.charAt(a[e]%chartabl2A7B.length):c<=e&&8>d.length&&(d+=scancods.charAt(encscans[a[e]%encscans.length]));return d}function dell_encode(a,b,c){a[b]=128;a=StringToIntArr(a);a=fill_zero(a,6,16);a[14]=b<<3;return IntArrToByteArr(choseEncode(a,c))}
function getBiosPwdForDellTag(a){"A95B"==dell_get_serial_line(a)&&(a=dell_get_serial_main(a)+"595B");var b=StringToArray(a),b=b.concat(calc_suffix_tag(b));return answerToString(dell_encode(b,23,a),a)}function getBiosPwdForDellHddNew(a){if("A95B"==dell_get_serial_line(a)){var b=chr(0)+chr(0)+chr(0);a=a.slice(3,a.length-4)+b+"595B"}b=StringToArray(a);b=b.concat(calc_suffix_hdd_new(b));return answerToString(dell_encode(b,23,a),a)}
function getBiosPwdForDellHddOld(a){a=calc_suffix_hdd_old(a);for(var b="",c=0;c<a.length;c++)b+=scancods.charAt(a[c]);return b}function getBiosPwdForSony(a){if(7!=a.length)return"";for(var b=0,c="",d=0;d<a.length;d++)c+="0987654321876543210976543210982109876543109876543221098765436543210987".charAt(parseInt(a.charAt(d),10)+10*b),b++;return c}
function getBiosPwdForSamsung(a){function b(a,c,b){for(var d=[],e=0;e<a.length;e++)d.push(a[e]<<b[7*c+e]&255|a[e]>>8-b[7*c+e]);return d}for(var c=[7,1,5,3,0,6,2,5,2,3,0,6,1,7,6,1,5,2,7,1,0,3,7,6,1,0,5,2,1,5,7,3,2,0,6],d=[1,6,2,5,7,3,0,7,1,6,2,5,0,3,0,6,5,1,1,7,2,5,2,3,7,6,2,1,3,7,6,5,0,1,7],e=[],f=1;f<div(a.length,2);f++)e.push(parseInt(a.charAt(2*f)+a.charAt(2*f+1),16));f=parseInt(a.substring(0,2),16)%5;a=keyboardEncToAscii(b(e,f,c));""==a&&(a=keyboardEncToAscii(b(e,f,d)));c=keyToAscii(b(e,f,c));
d=keyToAscii(b(e,f,d));return filterFalse([a,c,d])}function getBiosPwdForGenericPhoenix(a){return bruteForce(parseInt(a,10))}function getBiosPwdForHPCompaqPhoenix(a){return bruteForce(parseInt(a,10),17232)}function getBiosPwdForFsiPhoenix(a){return bruteForce(parseInt(a,10),65,!0,!1,3,7)}function getBiosPwdForFsiLPhoenix(a){return bruteForce(parseInt(a,10)+1,ord("L"),!0,!1,3,7)}function getBiosPwdForFsiPPhoenix(a){return bruteForce(parseInt(a,10)+1,ord("P"),!0,!1,3,7)}
function getBiosPwdForFsiSPhoenix(a){return bruteForce(parseInt(a,10)+1,ord("S"),!0,!1,3,7)}function getBiosPwdForFsiXPhoenix(a){return bruteForce(parseInt(a,10)+1,ord("X"),!0,!1,3,7)}function getBiosPwdForInsyde(a){for(var b="",c=0,d=0,e=0;8>e;e++)d=c=ord("Iou|hj&Z".charAt(e))^ord(a.charAt(e)),d*=1717986919,d=Math.floor(d/Math.pow(2,32)),d=d>>2|d&192,d&2147483648&&d++,d*=10,b+=(c-d).toString();return b}
function getBiosPwdForHpmini(a){var b={1:"3",0:"1",3:"F",2:"7",5:"Q",4:"V",7:"X",6:"G",9:"O",8:"U",a:"C",c:"E",b:"P",e:"M",d:"T",g:"H",f:"8",i:"Y",h:"Z",k:"S",j:"W",m:"4",l:"K",o:"J",n:"9",q:"5",p:"2",s:"N",r:"B",u:"L",t:"A",w:"D",v:"6",y:"I",x:"4",z:"0"},c={1:"3",0:"1",3:"F",2:"7",5:"Q",4:"V",7:"X",6:"G",9:"O",8:"U",a:"C",c:"E",b:"P",e:"M",d:"T",g:"H",f:"8",i:"Y",h:"Z",k:"S",j:"W",m:"4",l:"K",o:"J",n:"9",q:"5",p:"2",s:"N",r:"B",u:"L",t:"A",w:"D",v:"6",y:"I",x:"R",z:"0"},d="",e="";a=a.toLowerCase();
for(var f=0;f<a.length;f++)d+=b[a.charAt(f)],e+=c[a.charAt(f)];return d==e?d.toLowerCase():[d.toLowerCase(),e.toLowerCase()]}
function getBiosPwdForFsi20dec_old(a){function b(a,b,e){var f=copy_array(a);f[b[0]]=(a[e[0]]>>4|a[e[3]]<<4)&255;f[b[1]]=a[e[0]]&15|a[e[3]]&240;f[b[2]]=a[e[1]]>>4|a[e[2]]<<4&255;f[b[3]]=a[e[1]]&15|a[e[2]]&240;return f}return function(a){for(var d=0;d<a.length;d++)a[d]^=ord(":3-v@e4i".charAt(d));a.swap(2,6);a.swap(3,7);a=b(a,[0,1,2,3],[0,1,2,3]);a=b(a,[4,5,6,7],[6,7,4,5]);a[0]=a[0]<<3&255|a[0]>>5;a[1]=a[1]<<5&255|a[1]>>3;a[2]=a[2]<<7&255|a[2]>>1;a[3]=a[3]<<4&255|a[3]>>4;a[5]=a[5]<<6&255|a[5]>>2;a[6]=
a[6]<<1&255|a[6]>>7;a[7]=a[7]<<2&255|a[7]>>6;for(var d=[],e=0;e<a.length;e++)d[e]=a[e]%36;a=d;d="";for(e=0;e<a.length;e++)d+=9<a[e]?chr(ord("a")+a[e]-10):chr(ord("0")+a[e]);return d}(function(a){a=[parseInt(a.slice(0,5),10),parseInt(a.slice(5,10),10),parseInt(a.slice(10,15),10),parseInt(a.slice(15,20),10)];for(var b=[],e=0;e<a.length;e++)b.push(a[e]%256),b.push(Math.floor(a[e]/256));return b}(a))}
function getBiosPwdForFSI20dec_new(a){var b="4798156302 7201593846 5412367098 6587249310 9137605284 3974018625 8052974163".split(" ");a=a.charAt(0)+a.charAt(2)+a.charAt(5)+a.charAt(11)+a.charAt(13)+a.charAt(15)+a.charAt(16);for(var c="",d=0,e=0;e<a.length;e++)c+=b[d].charAt(parseInt(a.charAt(e),10)),d++;return c}function getBiosPwdForFSI20dec(a){return CreateHashTable([FSI_20_DEC_NEW,FSI_20_DEC_OLD],[getBiosPwdForFSI20dec_new(a),getBiosPwdForFsi20dec_old(a)])}
function getBiosPwdForFSIhex(a){function b(a){var b=ord("0");return chr(b+(a>>12)%16%10)+chr(b+(a>>8)%16%10)+chr(b+(a>>4)%16%10)+chr(b+(a>>0)%16%10)}function c(a,b){for(var c=0,g=0,h=0;h<a.length;h++)g=b[(ord(a.charAt(h))^c>>8)%256],c=(c<<8^g)&65535;return c}20==a.length&&(a=a.slice(12,20));return function(a){for(var e=[],f=0,g=0;256>g;g++){for(var f=g<<8,h=0;8>h;h++)f<<=1,f&65536&&(f^=4129);e.push(f&65535)}return b(c(a.slice(0,4),e))+b(c(a.slice(4,8),e))}(a)}
function has_element(a,b){for(var c=0;c<b.length;c++)if(b[c]==a)return!0;return!1}function numberChecker(a,b,c,d){c="undefined"==typeof c?!0:c;d="undefined"==typeof c?!1:d;var e=!1,f=a.length;if(c)e=isDecNumber(a);else if(d)e=isHexNumber(a);else return!1;return!0==e&&has_element(f,b)?!0:!1}function dellChecker(a,b,c){c="undefine"==typeof c?!1:c;if(has_element(a.length,b)){if(!c)return!0;for(b=0;b<c.length;b++)if(dell_get_serial_line(a)==c[b])return!0}return!1}
function autoCheckAndRun(a,b,c,d,e){return numberChecker(a,c,d,e)?b(a):!1}function autoCheckAndRunWithKey(a,b,c,d,e,f){a=autoCheckAndRun(a,b,d,e,f);return!1!=a?(b={},b[c]=a,b):!1}function dell_serial_normalize(a){return dell_get_serial_main(a)+dell_get_serial_line(a)}function dellCheckAndRunWithKey(a,b,c,d,e){return dellChecker(a,d,e)?(d={},d[c]=b(dell_serial_normalize(a)),d):!1}function autoGetBiosPwdForSony(a){return autoCheckAndRunWithKey(a,getBiosPwdForSony,SONY,[7],!0,!1)}
function autoGetBiosPwdForSamsung(a){return autoCheckAndRunWithKey(a,getBiosPwdForSamsung,SAMSUNG,[12,16,18],!1,!0)}function autoGetBiosPwdForAllPhoenix(a){return numberChecker(a,[5],!0)?CreateHashTable([PHOENIX,HP_COMPAQ,FSI_PHOENIX,FSI_L_PHOENIX,FSI_P_PHOENIX,FSI_S_PHOENIX,FSI_X_PHOENIX],[getBiosPwdForGenericPhoenix(a),getBiosPwdForHPCompaqPhoenix(a),getBiosPwdForFsiPhoenix(a),getBiosPwdForFsiLPhoenix(a),getBiosPwdForFsiPPhoenix(a),getBiosPwdForFsiSPhoenix(a),getBiosPwdForFsiXPhoenix(a)]):!1}
function autoGetBiosPwdForInsyde(a){return autoCheckAndRunWithKey(a,getBiosPwdForInsyde,INSYDE,[8],!0)}function autoGetBiosPwdForHpmini(a){return 10==a.length?CreateHashTable([HP_MINI],[getBiosPwdForHpmini(a)]):!1}function autoGetBiosPwdForFSI20dec(a){return autoCheckAndRun(a,getBiosPwdForFSI20dec,[20],!0)}function autoGetBiosPwdForFSIhex(a){return autoCheckAndRunWithKey(a,getBiosPwdForFSIhex,FSI_HEX,[8,20],!1,!0)}
function autoGetBiosPwdForDellHddOld(a){return dellCheckAndRunWithKey(a,getBiosPwdForDellHddOld,DELL_HDD_OLD,[11],!1)}function autoGetBiosPwdForDellTag(a){return dellCheckAndRunWithKey(a,getBiosPwdForDellTag,DELL_TAG,[11],DELL_SERIES_PREFIX)}function metaDellManyTag(a,b,c,d){if(a.length==b){b=[];for(var e=0;e<DELL_SERIES_PREFIX.length;e++)b[e]=d(a+DELL_SERIES_PREFIX[e]);if(0==b.length)return!1;a={};a[c]=b.getUnique();return a}return!1}
function autoGetBiosPwdForDellHddNew(a){return dellCheckAndRunWithKey(a,getBiosPwdForDellHddNew,DELL_HDD_NEW,[15],DELL_SERIES_PREFIX)}function autoGetBiosPwdForDellTagAll(a){return metaDellManyTag(a,7,DELL_TAG,getBiosPwdForDellTag)}function autoGetBiosPwdForDellHddNewAll(a){return metaDellManyTag(a,11,DELL_HDD_NEW,getBiosPwdForDellHddNew)}
var arr_of_bios_pwgen_fun=[autoGetBiosPwdForSony,autoGetBiosPwdForSamsung,autoGetBiosPwdForAllPhoenix,autoGetBiosPwdForInsyde,autoGetBiosPwdForHpmini,autoGetBiosPwdForFSI20dec,autoGetBiosPwdForFSIhex,autoGetBiosPwdForDellHddOld,autoGetBiosPwdForDellTag,autoGetBiosPwdForDellHddNew,autoGetBiosPwdForDellTagAll,autoGetBiosPwdForDellHddNewAll];
function autoGetBiosPwd(a){var b="",c={};a=a.trim().replace(/-/gi,"");for(var d=0;d<arr_of_bios_pwgen_fun.length;d++)if(b=arr_of_bios_pwgen_fun[d](a),!1!=b)for(var e in b)c[e]=b[e];return c};