mirror of
https://github.com/LiEnby/eCDP-Serial-Code.git
synced 2025-04-18 22:18:51 +01:00
Switch to JavaScript version.
This commit is contained in:
parent
ee0e4f8c8d
commit
490ebad2f4
@ -8,7 +8,7 @@
|
||||
<body>
|
||||
<div class="keygen">
|
||||
<img src="donald.jpg" class="askRonald" width="228" height="406">
|
||||
<div class="leaveOffering"> Leave an offering for Ronald McDonald </div>
|
||||
<div class="leaveOffering"> Leave an offering for Donald McDonald </div>
|
||||
DSi Mac Address:<br>
|
||||
<input type="text" id="dsiMac0" class="macAddr" value="00" maxlength="2"> :
|
||||
<input type="text" id="dsiMac1" class="macAddr" value="00" maxlength="2"> :
|
||||
@ -21,27 +21,220 @@
|
||||
Store Management Number of DS Card:<br>
|
||||
<input type="text" id="managementId" class="entry" value="000000" maxlength="6" size="3"><br>
|
||||
<input type="submit" id="generate_password" class="button" value="Place Offering" onclick="placeOffering()"><br>
|
||||
<div id="offering"></div>
|
||||
<div id="offering">Keys Originally Cracked by SilicaAndPina, algorithm ported to JavaScript by @User670.</div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
// Keygen for McDonald's eCDP (eCrew Development Program),
|
||||
// a Nintendo DS software to train employees.
|
||||
// This keygen is for the only dumped Japanese version of eCDP.
|
||||
// ROM: https://archive.org/details/mcdonalds-japan-ecdp-rom-training-nintendo-ds-cartridge-dump
|
||||
|
||||
// Usage: Select the third option in main menu, enter two 6-digit numbers as you like,
|
||||
// and use this script to calculate the third code.
|
||||
|
||||
// Web/JavaScript port info:
|
||||
// This is based on LazyDog's keygen in Python, located at the URL below:
|
||||
// https://gist.github.com/lazydogP/57c431cc7fddb5b969559c4c8cd8c881
|
||||
//
|
||||
// I know there is one that beats him by 2 days
|
||||
// (https://github.com/KuromeSan/eCDP-Serial-Code ),
|
||||
// but that one is written in C which I hardly understand in the first place,
|
||||
// and also uses some library that I have no idea what that is.
|
||||
// At least this Python one I can understand.
|
||||
|
||||
|
||||
function toUnsigned(n){
|
||||
if(n>=0)return n;
|
||||
return 4294967296+n;
|
||||
}
|
||||
|
||||
function rol(n, rotation){
|
||||
// Original rol function has an optional parameter "width" that defaults
|
||||
// to 32. I'm gonna hard code it because the only instance of this
|
||||
// function call doesn't include this parameter, ... and the fact that
|
||||
// new JS standards kinda make me feel confused about what you can and
|
||||
// can't do in JS.
|
||||
var width=32;
|
||||
rotation%=width;
|
||||
if(rotation==0){
|
||||
return n;
|
||||
}
|
||||
n&=(2**width-1);
|
||||
// Apparently bitwise operators treat numbers as a **signed** 32-bits
|
||||
// Did conversion to match the Python
|
||||
return toUnsigned((n<<rotation) | (n>> (width-rotation)));
|
||||
}
|
||||
|
||||
function gen_index(sum_offset, length){
|
||||
if(length==0){
|
||||
return 0;
|
||||
}
|
||||
if(length <= sum_offset){
|
||||
var count=0x1c;
|
||||
var seed=sum_offset>>4;
|
||||
if(length <= seed>>0xc){
|
||||
count-=0x10;
|
||||
seed=seed>>0x10;
|
||||
}
|
||||
if(length <= seed>>4){
|
||||
count-=8;
|
||||
seed=seed>>8;
|
||||
}
|
||||
if(length<=seed){
|
||||
count-=4;
|
||||
seed=seed>>4;
|
||||
}
|
||||
|
||||
// Did someone say bitwise sucks in Python?
|
||||
// It sucks here too
|
||||
// Some bitwise replaced with equivalent regular maths because
|
||||
// maths can handle numbers larger than 32 bits while
|
||||
// bitwise can't
|
||||
sum_offset=rol(sum_offset, count);
|
||||
sum_offset*=2;
|
||||
//carry=(sum_offset&(2**32))!=0;
|
||||
carry=Math.floor(sum_offset/(2**32))%2
|
||||
for(var i=count; i<32; i++){
|
||||
seed= seed*2 + (2**32-length);
|
||||
if(carry){
|
||||
seed+=1;
|
||||
}
|
||||
carry=Math.floor(seed/(2**32))%2
|
||||
seed%=(2**32)
|
||||
if(!carry){
|
||||
seed+=length;
|
||||
seed%=(2**32)
|
||||
}
|
||||
sum_offset*=2;
|
||||
carry=Math.floor(sum_offset/(2**32))%2;
|
||||
sum_offset%=(2**32)
|
||||
}
|
||||
// why is there a `pass` in the original? There is no block to pass
|
||||
return seed;
|
||||
}else{
|
||||
return sum_offset;
|
||||
}
|
||||
}
|
||||
|
||||
function gen_index_2(sum_offset, length){
|
||||
return sum_offset%length;
|
||||
}
|
||||
|
||||
function calc_shorten_index(input_merge){
|
||||
var hex_char="0123456789ABCDEF";
|
||||
var sum_offset=0;
|
||||
for(var c of input_merge){
|
||||
sum_offset+=hex_char.indexOf(c);
|
||||
}
|
||||
return gen_index(sum_offset, 7);
|
||||
// and here's another `pass`
|
||||
}
|
||||
|
||||
function shuffle(input_merge, shuffle_index){
|
||||
var shuffle_map = [
|
||||
[0x01,0x0A,0x16,0x04,0x07,0x18,0x0C,0x10,0x05,0x17,0x09,0x03,0x12,0x08,0x15,0x13,0x0B,0x02,0x0F,0x0D,0x11,0x0E,0x06,0x14],
|
||||
[0x07,0x0C,0x0E,0x11,0x09,0x16,0x10,0x06,0x14,0x0D,0x01,0x02,0x12,0x08,0x13,0x0B,0x0F,0x0A,0x18,0x15,0x04,0x05,0x03,0x17],
|
||||
[0x0F,0x04,0x09,0x03,0x06,0x07,0x11,0x12,0x15,0x16,0x02,0x08,0x05,0x17,0x0C,0x0D,0x01,0x18,0x0B,0x14,0x0E,0x10,0x13,0x0A],
|
||||
[0x02,0x0A,0x0E,0x12,0x0B,0x03,0x0C,0x06,0x13,0x07,0x11,0x09,0x15,0x18,0x10,0x17,0x14,0x0F,0x04,0x01,0x05,0x08,0x16,0x0D],
|
||||
[0x0B,0x02,0x09,0x16,0x14,0x01,0x12,0x11,0x15,0x06,0x0F,0x17,0x07,0x10,0x0C,0x0E,0x08,0x18,0x13,0x03,0x0A,0x0D,0x04,0x05],
|
||||
[0x09,0x0F,0x05,0x0D,0x16,0x15,0x12,0x11,0x03,0x0A,0x04,0x10,0x0E,0x14,0x02,0x01,0x13,0x0C,0x06,0x0B,0x17,0x18,0x07,0x08],
|
||||
[0x12,0x02,0x0C,0x09,0x0D,0x0E,0x04,0x07,0x16,0x14,0x17,0x01,0x11,0x03,0x10,0x15,0x08,0x0A,0x05,0x13,0x0B,0x18,0x0F,0x06]
|
||||
];
|
||||
var shuffle_method=shuffle_map[shuffle_index];
|
||||
var shuffled_str="";
|
||||
for(var i=0; i<0x18; i++){
|
||||
shuffled_str+=input_merge[shuffle_method[i]-1];
|
||||
}
|
||||
return shuffled_str;
|
||||
}
|
||||
|
||||
function hex2ints(hex_str){
|
||||
var result=[];
|
||||
for(var i=0; i<6; i++){
|
||||
result.push(parseInt("0x"+hex_str.slice(4*i, 4*i+4)));
|
||||
// JS parseInt recognizes 0x hex numbers, but can't otherwise handle
|
||||
// other bases
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function ints_encrypt(numbers){
|
||||
// never mind the bitwise nonsenses
|
||||
var key=0x3e0f83e1; //good news it's 32 bits
|
||||
result=[];
|
||||
for(var i=0; i<6; i++){
|
||||
var r0=Math.floor(numbers[i]/(2**0x1f));
|
||||
var mul=key*numbers[i]; //wait how many bits are we getting here?
|
||||
var r2= mul%(2**32);
|
||||
var r6= Math.floor(mul/(2**32));
|
||||
r6=r0+r6>>3;
|
||||
mul=0x21*r6;
|
||||
r0=mul%(2**32);
|
||||
r2=Math.floor(mul/(2**32));
|
||||
r6=numbers[i]-r0;
|
||||
result.push(r6+1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function ints2str(numbers){
|
||||
var chars="123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
|
||||
var s="";
|
||||
for(var i of numbers){
|
||||
s+=chars[i-1];
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
function calc_serial_code(mac_code, code1, code2){
|
||||
var full_code=mac_code.toUpperCase()+code1+code2;
|
||||
var shorten_index=calc_shorten_index(full_code);
|
||||
var shuffle_str=shuffle(full_code, shorten_index);
|
||||
var shuffle_numbers=hex2ints(shuffle_str);
|
||||
var encrypted_numbers=ints_encrypt(shuffle_numbers);
|
||||
var serial_code=ints2str(encrypted_numbers);
|
||||
return serial_code;
|
||||
}
|
||||
|
||||
// starting here is not present in the original code
|
||||
// made these for web and such
|
||||
function input_sanitizer(mac_code, code1, code2){
|
||||
var mac=""
|
||||
for(var c of mac_code){
|
||||
if(("0123456789AaBbCcDdEeFf").indexOf(c)!=-1){
|
||||
mac+=c
|
||||
}
|
||||
}
|
||||
var c1=""
|
||||
for(var c of code1){
|
||||
if(("0123456789").indexOf(c)!=-1){
|
||||
c1+=c
|
||||
}
|
||||
}
|
||||
var c2=""
|
||||
for(var c of code2){
|
||||
if(("0123456789").indexOf(c)!=-1){
|
||||
c2+=c
|
||||
}
|
||||
}
|
||||
if(mac.length!=12 || c1.length!=6 || c2.length!=6){
|
||||
return ""
|
||||
}
|
||||
return calc_serial_code(mac, c1, c2)
|
||||
}
|
||||
|
||||
|
||||
function placeOffering()
|
||||
{
|
||||
query = "/password.php?mac0="+dsiMac0.value+"&mac1="+dsiMac1.value+"&mac2="+dsiMac2.value+"&mac3="+dsiMac3.value+"&mac4="+dsiMac4.value+"&mac5="+dsiMac5.value+"&store="+storeId.value+"&management="+managementId.value;
|
||||
offering.innerText = "Contacting Ronald McDonald...";
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.open("GET",query,true);
|
||||
xhr.onreadystatechange = function () {
|
||||
if(xhr.readyState === XMLHttpRequest.DONE) {
|
||||
var status = xhr.status;
|
||||
if (status === 0 || (status >= 200 && status < 400)) {
|
||||
offering.innerText = "Ronald McDonald speaks with a cryptic message: "+xhr.responseText;
|
||||
} else {
|
||||
offering.innerText = "Ronald McDonald looks at you, disgusted, throwing your BigMac right back at you.";
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
var macAddress = dsiMac0.value+dsiMac1.value+dsiMac2.value+dsiMac3.value+dsiMac4.value+dsiMac5.value;
|
||||
var sId = storeId.value;
|
||||
var mId = managementId.value;
|
||||
var key = input_sanitizer(macAddress, sId, mId)
|
||||
if(key != "")
|
||||
offering.innerText = "Donald McDonald speaks with a cryptic message: "+key;
|
||||
else
|
||||
offering.innerText = "Donald McDonald looks at you, disgusted, throwing your Big Mac right back at you.";
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
Loading…
x
Reference in New Issue
Block a user