Advertisement
Tarferi

Guessing EUD address

Oct 7th, 2018
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.32 KB | None | 0 0
  1.  
  2. $fname = "_internal_database.txt";
  3.  
  4. function getPossibilities($arr, $addr)
  5. {
  6.     $res = array();
  7.     foreach ($arr as $t) {
  8.         if ($t["version"]["name"] == "1.16.1") {
  9.             $curAddr = hexdec($t["address"]);
  10.             $mod = $curAddr % 4;
  11.             if ($addr >= $curAddr - $mod) {
  12.                 $res[$curAddr] = $t;
  13.             }
  14.         }
  15.     }
  16.     return $res;
  17. }
  18.  
  19. function getActual($arr, $addr)
  20. {
  21.     foreach ($arr as $t) {
  22.         $adr = hexdec($t["address"]);
  23.         $size = $t["size"] * 1;
  24.         $length = $t["length"] * 1;
  25.         $ldr = $adr + ($size * $length);
  26.         if ($addr >= $adr && $addr <= $ldr) {
  27.             return $t;
  28.         }
  29.     }
  30.     foreach ($arr as $t) {
  31.         $adr = hexdec($t["address"]);
  32.         $size = $t["size"] * 1;
  33.         $length = $t["length"] * 1;
  34.         $ldr = $adr + ($size * $length);
  35.         $mod = $addr % 4;
  36.         if ($addr >= $adr - $mod && $addr <= $ldr) {
  37.             return $t;
  38.         }
  39.     }
  40.     // Not direct hit
  41.     return false;
  42. }
  43.  
  44. if (isset($_GET["findPlayerID"])) {
  45.     if(isset($_GET["isHexAddress"])) {
  46.         $pid = ((hexdec($_GET["findPlayerID"]) * 1) / 4) - 1452249;;
  47.     } else {
  48.         $pid = $_GET["findPlayerID"] * 1;
  49.     }
  50.     $num = 1452249;
  51.     $addr = 4 * ($pid + $num);
  52.     $fc = json_decode(file_get_contents($fname), true);
  53.    
  54.     $candidate = false;
  55.     foreach ($fc as $t) {
  56.         if ($t["version"]["name"] == "1.16.1") {
  57.             $adr = hexdec($t["address"]);
  58.             $size = $t["size"] * 1;
  59.             $length = $t["length"] * 1;
  60.             if ($addr >= $adr) {
  61.                 $offset = ($addr - $addr) / $size;
  62.                 if ($offset < $length) {
  63.                     $candidate = $t;
  64.                     break;
  65.                 }
  66.             }
  67.         }
  68.     }
  69.    
  70.     if ($candidate === false) {
  71.         echo "<a href=\"/epd\">Back to main page</a><br />";
  72.         die("Unable to determine the source!");
  73.     }
  74.     $offset = $addr - (hexdec($candidate["address"]));
  75.     $oid = floor($offset / ($candidate["size"] * 1));
  76.     $haddr = "00000000" . strtoupper(dechex($addr));
  77.     $haddr = strrev(substr(strrev($haddr), 0, 8));
  78.    
  79.     $_GET["showadditional"] = array(
  80.         $pid,
  81.         $haddr,
  82.         $oid
  83.     );
  84.     $_GET["details"] = $candidate["address"];
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement