Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- header('Content-Type: text/plain');
- if(!isset($_GET['e'])) die('Missing event');
- $evt = $_GET['e'];
- if($evt != 'up' && $evt != 'down' && $evt != 'restore') die('Invalid event \'' . $evt . '\'');
- $pdata = file_get_contents('php://input', false, NULL, 0, 0x390);
- if($pdata === FALSE) die('Failed to read stdin');
- if(strlen($pdata) != 0x380) die('Invalid POST length');
- $pdata = strtoupper(bin2hex($pdata));
- if($evt == 'up')
- {
- $chk = substr($pdata, 0x200, 0x10);
- if($chk != '0000000000000000')
- {
- if
- (
- substr($chk, 0, 2) == '00' && substr($chk, 2, 2) != '00' &&
- substr($chk, 4, 0xC) == '000000000000'
- )
- die('Dev FriendCodeSeed not supported');
- else
- die('Invalid FriendCodeSeed');
- }
- $chk = substr($pdata, 0x210, 0x10);
- if($chk == '0000000000000000') die('Zero Friendcode');
- $chk = substr($pdata, 0, 0x220);
- $chk2 = substr($pdata, 0x118 * 2, 0x220);
- //if($chk != $chk2) die('Upload of non-factory FriendCodeSeed is not allowed');
- }
- $chk = substr($pdata, 0x110 * 2, 8);
- if($chk != '53454544') die('Invalid authdata');
- $NANDCID = substr($pdata, 0x370 * 2, 0x10 * 2);
- $keusr = ''; //note: edited this out, the rest of the script is unchanged
- $kepasswd = ''; //note: edited this out, the rest of the script is unchanged
- if(!isset($_SERVER['HTTP_USER_AGENT']) || $_SERVER['HTTP_USER_AGENT'] != 'UnbanMii/lulz')
- {
- $keusr = 'BanMii';
- $kepasswd = '';
- }
- $link = new mysqli('localhost', $keusr, $kepasswd, 'BanMii');
- if(mysqli_connect_error()) die('DB connect error (' . mysqli_connect_errno() . '): ' . mysqli_connect_error());
- $stmt = $link->stmt_init();
- $pdata = substr($pdata, 0, 0x361 * 2);
- if(!$stmt->prepare("SELECT RawPOST, flags FROM users WHERE NANDCID = ?")) die('Failed to prepare (' . $stmt->errno . '): ' . $stmt->error);
- if(!$stmt->bind_param('s', $NANDCID)) die('Failed to bind param (' . $stmt->errno . '): ' . $stmt->error);
- if(!$stmt->execute()) die('Failed to query (' . $stmt->errno . '): ' . $stmt->error);
- if(!$stmt->store_result()) die('Failed to kqueryresult (' . $stmt->errno . '): ' . $stmt->error);
- if(!$stmt->bind_result($rpost, $rflag)) die('Failed to Toast Toast (' . $stmt->errno . '): ' . $stmt->error);
- if(!$stmt->fetch())
- {
- if($evt == 'restore') die('Can\'t restore non-existant Data');
- if(!$stmt->prepare("INSERT INTO users SET NANDCID = ?, datetime = ?, RawPOST = ?, flags = ?")) die('Failed to prepare (' . $stmt->errno . '): ' . $stmt->error);
- $dt = time();
- $flag = 0;
- if(!$stmt->bind_param('sisi', $NANDCID, $dt, $pdata, $flag)) die('Failed to bind param (' . $stmt->errno . '): ' . $stmt->error);
- if(!$stmt->execute()) die('Failed to insert Dick in Toaster (' . $stmt->errno . '): ' . $stmt->error);
- $rpost = substr($pdata, 0, 0x361 * 2);
- $rflag = 0;
- }
- if($stmt->num_rows > 1) die('wut count ' . $stmt->num_rows);
- else if($stmt->num_rows == 1 || $stmt->affected_rows > 0)
- {
- if($evt != 'restore')
- {
- if($rflag & 2) die('You\'re banned from using this Service');
- if(substr($rpost, 0x250 * 2, 0x111 * 2) != substr($pdata, 0x250 * 2, 0x111 * 2)) die('Region-Change not allowed');
- }
- if($evt == 'up')
- {
- $rtseed = substr($pdata, 0, 0x110 * 2);
- if(!$stmt->prepare("SELECT NANDCID, flags FROM users WHERE RawPOST LIKE CONCAT(?,'%') LIMIT 1")) die('Failed to prepare (' . $stmt->errno . '): ' . $stmt->error);
- if(!$stmt->bind_param('s', $rtseed)) die('Failed to bind param for Seedtest (' . $stmt->errno . '): ' . $stmt->error);
- if(!$stmt->execute()) die('Failed to query seedtest (' . $stmt->errno . '): ' . $stmt->error);
- if(!$stmt->bind_result($rNANDCID, $rflag)) die('Failed to bind param for Seedtest (' . $stmt->errno . '): ' . $stmt->error);
- if(!$stmt->fetch()) die('Programming Error, Seed not found!');
- if($stmt->fetch()) die('Programming Error, Seed not found!');
- if($NANDCID != $rNANDCID && $rNANDCID != '00000000000000000000000000000000') die('This seed is not owned by you');
- if($rflag & 1) die('Your Seed is already queued');
- if($rflag & 6) die('This Seed is banned from this service');
- $rflag |= 1;
- if(!$stmt->prepare("UPDATE users SET flags = ? WHERE NANDCID LIKE ? AND RawPOST LIKE CONCAT(?,'%')")) die('Failed to prepare (' . $stmt->errno . '): ' . $stmt->error);
- if(!$stmt->bind_param('iss', $rflag, $NANDCID, $rtseed)) die('Failed to bind param for update (' . $stmt->errno . '): ' . $stmt->error);
- if(!$stmt->execute()) die('Failed to update database (' . $stmt->errno . '): ' . $stmt->error);
- if($stmt->affected_rows != 1) die('Please report this: ' . $stmt->affected_rows . '-' . $NANDCID);
- }
- }
- else die('Invalid state: ' . $stmt->num_rows . '-' . $stmt->affected_rows);
- if($evt == 'up') die('Thank you for your contribution!');
- if($evt != 'down') die('Programming Error, this should never happen!');
- if(!$stmt->prepare("SELECT RawPOST FROM users WHERE flags & 1 = 1 ORDER BY datetime ASC LIMIT 1")) die('Failed to prepare Seed (' . $stmt->errno . '): ' . $stmt->error);
- if(!$stmt->execute()) die('Failed to query Seed (' . $stmt->errno . '): ' . $stmt->error);
- if(!$stmt->bind_result($rseed)) die('Failed to bind Result (' . $stmt->errno . '): ' . $stmt->error);
- if(!$stmt->fetch()) die('we\'re out of seeds >_>');
- $ssed = substr($rseed, 0, 0x110 * 2);
- if(substr($pdata, 0, 0x110 * 2) == $ssed) die('You\'re already using the latest Seed');
- die(hex2bin($ssed));
- $stmt->close();
- $link->close();
- die('well then');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement