ChangeSkinX

ChangeSkinX

446k Downloads

ChangeSkin cannot encode old slim models

Feerko opened this issue · 10 comments

commented

What behaviour is observed:

Alex skin doesn't work

Environment description

Bungeecord / mysql

Plugin version or build number:

3.1-SNAPSHOT-de520f3

Ok, so i'm trying to connect your plugin with mineskin. It's works always for steve models and only sometimes for alex idk why.

{"timestamp":1504629230114,"profileId":"d1cec9ad1da84179b1e5604f72bfb226","profileName":"rutger465","signatureRequired":true,"textures":{"SKIN":{"metadata":{"model":"slim"},"url":"http://textures.minecraft.net/texture/519b73379fc41cb16b985f371d1917bf6e4dc99809640dd6ad5386b99a664c"}}}

https://api.mineskin.org/get/id/43035

  $stmt = $conn->prepare("INSERT INTO skinData (SkinID, DisplayName, Timestamp, UUID, Name, SlimModel, SkinURL, CapeURL, Signature) VALUES (NULL, NULL, ?, ?, ?, ?, ?, ?, ?);");
  $stmt->bind_param("sssssss", $Timestamp, $UUID, $Name, $SlimModel, $skinURL, $CapeURL, $Signature);

  $mineskin_json = file_get_contents('http://api.mineskin.org/get/id/' . htmlspecialchars($_GET['mineskin']));
  $mineskin = json_decode($mineskin_json, true);

  $Value = $mineskin["data"]["texture"]["value"];
  $json = base64_decode($Value);
  $array = json_decode($json, true);

  $Timestamp = $array["timestamp"];
  $UUID = $array["profileId"];
  $Name = $array["profileName"];

  if (isset($array["textures"]["SKIN"]["metadata"]["model"])) { $SlimModel = true; }
  else { $SlimModel = false; }

  $skinURL = str_replace('http://textures.minecraft.net/texture/', '', $array["textures"]["SKIN"]["url"]);
  $CapeURL = '';
  $Signature = base64_decode($mineskin["data"]["texture"]["signature"]);

  $stmt->execute();

that's my code.

commented

for skin 43029 in database i get:
Timestamp: 1504629230114
UUID: d1cec9ad1da84179b1e5604f72bfb226
Name: rutger465
SlimModel: 1
SkinURL: 519b73379fc41cb16b985f371d1917bf6e4dc99809640dd6ad5386b99a664c
CapeURL:
Signature:
skinData-Signature.bin.zip

commented

Okay, I think it's because the string escaping in MySQL. I get a different result if I try to encode the binary file. EDIT: If you want to test yourself run base64 filename.

Could you try it with this:

INSERT INTO skinData (`Timestamp`, `UUID`, `Name`, `SlimModel`, `SkinURL`, `CapeURL`, `Signature`) VALUES (?, ?, ?, ?, ?, ?, FROM_BASE64(?))

You do everything like before, but now you don't decode the signature, you let MySQL do that.

EDIT:
(and bindParam with 'ississs')

commented
  $stmt = $conn->prepare("INSERT INTO skinData (Timestamp, UUID, Name, SlimModel, SkinURL, CapeURL, Signature) VALUES (?, ?, ?, ?, ?, ?, FROM_BASE64(?));");
  $stmt->bind_param("ississs", $Timestamp, $UUID, $Name, $SlimModel, $skinURL, $CapeURL, $Signature);

  $mineskin_json = file_get_contents('http://api.mineskin.org/get/id/' . htmlspecialchars($_GET['mineskin']));
  $mineskin = json_decode($mineskin_json, true);

  $Value = $mineskin["data"]["texture"]["value"];
  $json = base64_decode($Value);
  $array = json_decode($json, true);

  $Timestamp = $array["timestamp"];
  $UUID = $array["profileId"];
  $Name = $array["profileName"];

  if (isset($array["textures"]["SKIN"]["metadata"]["model"])) { $SlimModel = true; }
  else { $SlimModel = false; }

  $skinURL = str_replace('http://textures.minecraft.net/texture/', '', $array["textures"]["SKIN"]["url"]);
  $CapeURL = '';
  $Signature = $mineskin["data"]["texture"]["signature"];

This is my code for now. There is no php error but still doesn't work. I'm still alex.

commented

Okay I found the source. If you closely, you can see that the order of metadata and url is different. For some reason Mojang changed this format and now we have a mixed format.

commented

there is way to fix this in plugin side?

commented

Could you give some names, maybe we could find a pattern. It looks like it was a certain time when they changed it. Every newer skin requests from Mojang has the order url and then metadata like ChangeSkin detects. Older ones have metadata and then URL.

commented

Yes I'm working on it. Currently it's possible with newer skins than X or check if the signature is valid and if not try the other way.

commented

It should be fixed now. Besides that as you can see, I cleaned up this ticket a bit in case someone else searches for the same bug.

Sorry for not finding this bug earlier, I properly wasted an entire day for you.

commented

Works great for now, thanks a lot! :)