Guest User

Untitled

a guest
Nov 17th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. *****************
  5. * @author capos *
  6. *****************
  7. */
  8.  
  9. $width = 100;
  10. $height = 114;
  11.  
  12. function buildimg($bytes, $width, $height)
  13. {
  14. $img=imagecreatetruecolor($width, $height);imagealphablending($img, false);imagesavealpha($img, true);$x=0;$y=0;
  15. $colors=unpack("N*", $bytes);
  16. foreach($colors as $color)
  17. {
  18. imagesetpixel($img, $x, $y, (0x7f-($color>>25)<<24)|($color&0xffffff));
  19. if(++$x==$width)
  20. {$x=0;$y++;}
  21. }
  22. header('Content-Type: image/png');
  23. imagepng($img);
  24. }
  25.  
  26. $pixels = file_get_contents('banner.txt'); // the banner pixels
  27.  
  28. if($_GET)
  29. {
  30. $token = trim($_GET["token"]);
  31. if(strlen($token) >= 10)
  32. {
  33. // Stuff to connect to mus and get banner data.. (prime and generator)
  34. $fp = fsockopen("127.0.0.1", 30001, $errno, $errstr, 1);
  35. if (!is_resource($fp))
  36. {
  37. exit("LE FAIL...");
  38. }
  39.  
  40. $packet = 'setToken'.chr(1).$token;
  41.  
  42. fwrite($fp, $packet);
  43. fflush($fp);
  44.  
  45. stream_set_timeout($fp, 1);
  46. $data = fgets($fp, 512);
  47. list($prime, $generator) = explode(':', $data);
  48. fclose($fp);
  49.  
  50. $insert = chr(strlen($prime)).$prime.chr(strlen($generator)).$generator;
  51. $Length = strlen($token);$Length2 = strlen($insert);
  52. $p = 0;$bitsnum = "";
  53. for($i=0;$i<$Length2;$i++)
  54. {
  55. $bits = base_convert(ord($insert[$i]) ^ ord($token[$p]),10,2);
  56. $need = 8 - strlen($bits);
  57. for($o=0;$o<$need;$o++)$bits = "0".$bits;
  58. $bitsnum .= $bits;
  59. if (++$p == $Length) $p = 0;
  60. }
  61. $insertpos = 0;$Length = strlen($bitsnum);
  62. for ($y = 39; $y < 69; $y++)
  63. {
  64. $a = 0;
  65. for ($r = 4; $r < 84; $r++)
  66. {
  67. $pos = (($y + $a) * $width + $r) * 4;
  68. $b = 1;
  69. while ($b < 4)
  70. {
  71. if($insertpos < $Length)
  72. {
  73. $binaryData = base_convert(ord($pixels[$pos + $b]),10,2);
  74. $need = 8 - strlen($binaryData);
  75. for($o=0;$o<$need;$o++) $binaryData = "0".$binaryData;
  76. $binaryData[7] = $bitsnum[$insertpos];
  77. $pixels[$pos + $b] = chr(base_convert($binaryData,2,10));
  78. $insertpos++;$b++;
  79. continue;
  80. }
  81. break 3;
  82. }
  83. if ($r % 2 == 0) $a++;
  84. }
  85. }
  86.  
  87. }
  88. }
  89. buildimg($pixels, $width, $height);
  90. ?>
Add Comment
Please, Sign In to add comment