mirror of
https://github.com/barronwaffles/dwc_network_server_emulator.git
synced 2026-04-21 16:17:19 -05:00
naswii.nintendowifi.net
Added a preliminary naswii.nintendowifi.net/ac page. This should give enough information to handle Wii connections. The data must still be stored in the database later.
This commit is contained in:
parent
2e41215d09
commit
a74bc36f26
23
tools/generate_server.c
Normal file
23
tools/generate_server.c
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Algorithm the same as used in enctypex_decoder by Luigi Auriemma, just in an easy to use single program.
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i = 0;
|
||||
unsigned int server = 0;
|
||||
|
||||
if(argc != 2)
|
||||
{
|
||||
printf("usage: %s servername\n", argv[0]);
|
||||
}
|
||||
|
||||
for(i = 0; i < strlen(argv[1]); i++)
|
||||
{
|
||||
unsigned char c = tolower(argv[1][i]);
|
||||
server = c - (server * 0x63306ce7);
|
||||
}
|
||||
server %= 20;
|
||||
|
||||
printf("%s.ms%d.nintendowifi.net", argv[1], server);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
test 2
|
||||
159
www/naswii.nintendowifi.net/public_html/ac
Normal file
159
www/naswii.nintendowifi.net/public_html/ac
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
<?php
|
||||
// Make sure to set "ForceType application/x-httpd-php" somewhere in Apache for this file (vhost configuration works well enough)
|
||||
|
||||
// Return the same headers as the real server does for the sake of completeness.
|
||||
// They never get checked so they are entirely optional.
|
||||
header("NODE: wifiappw3");
|
||||
header("Server: Nintendo Wii (http)");
|
||||
|
||||
function parse($key, $value)
|
||||
{
|
||||
$value2 = frombase64($value);
|
||||
$str = "{$key} = {$value} ({$value2})";
|
||||
|
||||
if($key == "token" && substr($value2, 0, 3) == "NDS")
|
||||
{
|
||||
$b64 = base64_decode(substr($value2, 3));
|
||||
}
|
||||
|
||||
$str .= "\r\n";
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
function tobase64($str)
|
||||
{
|
||||
$str = str_replace("=", "*", base64_encode($str));
|
||||
return $str;
|
||||
}
|
||||
|
||||
function frombase64($str)
|
||||
{
|
||||
$str = base64_decode(str_replace("*", "=", $str));
|
||||
return $str;
|
||||
}
|
||||
|
||||
function gen_random_str($len)
|
||||
{
|
||||
$valid = "abcdefghjiklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
$validlen = strlen($valid);
|
||||
|
||||
$output = "";
|
||||
$i = 0;
|
||||
while($i++ < $len)
|
||||
{
|
||||
$output .= $valid[mt_rand(0, $validlen - 1)];
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Debug log file
|
||||
$file = fopen("output.txt","a+");
|
||||
|
||||
$action = "";
|
||||
|
||||
$authkey = "";
|
||||
$str = "POST:\r\n";
|
||||
foreach ($_POST as $key => $value)
|
||||
{
|
||||
$str .= parse($key, $value);
|
||||
|
||||
if(//$key == "action" ||
|
||||
$key == "gsbrcd" ||
|
||||
//$key == "sdkver" ||
|
||||
$key == "userid" ||
|
||||
$key == "passwd" ||
|
||||
//$key == "bssid" ||
|
||||
//$key == "apinfo" ||
|
||||
$key == "gamecd" ||
|
||||
//$key == "makercd" ||
|
||||
//$key == "unitcd" ||
|
||||
$key == "macadr" ||
|
||||
//$key == "lang" ||
|
||||
$key == "birth" ||
|
||||
//$key == "devtime" ||
|
||||
$key == "devname" ||
|
||||
$key == "ingamesn" ||
|
||||
$key == "csnum" ||
|
||||
$key == "cfc")
|
||||
{
|
||||
$authkey .= $key . "\\" . frombase64($value) . "|";
|
||||
}
|
||||
|
||||
if($key == "action")
|
||||
{
|
||||
$action = frombase64($value);
|
||||
}
|
||||
}
|
||||
$str .= "\r\n";
|
||||
|
||||
// Gets are not a part of the spec, but they allow for easy testing without having to POST every time
|
||||
$str .= "GET:\r\n";
|
||||
foreach ($_GET as $key => $value)
|
||||
{
|
||||
$str .= parse($key, $value);
|
||||
|
||||
if(//$key == "action" ||
|
||||
$key == "gsbrcd" ||
|
||||
//$key == "sdkver" ||
|
||||
$key == "userid" ||
|
||||
$key == "passwd" ||
|
||||
//$key == "bssid" ||
|
||||
//$key == "apinfo" ||
|
||||
$key == "gamecd" ||
|
||||
//$key == "makercd" ||
|
||||
//$key == "unitcd" ||
|
||||
$key == "macadr" ||
|
||||
//$key == "lang" ||
|
||||
$key == "birth" ||
|
||||
//$key == "devtime" ||
|
||||
$key == "devname" ||
|
||||
$key == "ingamesn" ||
|
||||
$key == "csnum" ||
|
||||
$key == "cfc")
|
||||
{
|
||||
$authkey .= $key . "\\" . frombase64($value) . "|";
|
||||
}
|
||||
|
||||
if($key == "action")
|
||||
{
|
||||
$action = frombase64($value);
|
||||
}
|
||||
}
|
||||
$str .= "\r\n";
|
||||
$str .= "\r\n";
|
||||
$str .= "\r\n";
|
||||
|
||||
// Write data gotten from POST/GET so we can view it later more easily
|
||||
fwrite($file, $str);
|
||||
fclose($file);
|
||||
|
||||
$now = getdate();
|
||||
$time = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
|
||||
$time = base64_encode($time);
|
||||
$time = str_replace("=", "*", $time);
|
||||
$retry = tobase64("0");
|
||||
|
||||
if($action == "login")
|
||||
{
|
||||
$returncd = tobase64("001");
|
||||
$challenge_key = gen_random_str(8);
|
||||
$challenge = tobase64($challenge_key);
|
||||
$locator = tobase64("gamespy.com");
|
||||
|
||||
$authkey .= "challenge\\" . $challenge_key;
|
||||
|
||||
// Encode the information we need to handle logins on the gamespy server.
|
||||
// This informaiton is not the same as the real server would return, but we don't need to maintain
|
||||
// interoperability with the real server, so we can ignore that detail.
|
||||
$token = tobase64("NDS" . base64_encode($authkey));
|
||||
|
||||
echo "challenge=" . $challenge . "&locator=" . $locator . "&retry=" . $retry . "&returncd=" . $returncd . "&token=" . $token . "&datetime=" . $time;
|
||||
}
|
||||
else if($action = "acctcreate")
|
||||
{
|
||||
$returncd = tobase64("002");
|
||||
echo "retry=" . $retry . "&returncd=" . $returncd . "&datetime=" . $time;
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user