Last active
November 29, 2015 07:42
-
-
Save ihaveamac/3dae2929f8b87ed93dcf to your computer and use it in GitHub Desktop.
qr code read example - https://ianburgwin.net/psmdqrcode/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// extract password from PSMD rescue QR code | |
// uses https://github.com/khanamiryan/php-qrcode-detector-decoder | |
?> | |
<h2>Pokémon Super Mystery Dungeon QR code parser</h2> | |
Check out the QR codes you can use <a href="https://ianburgwin.net/psmdqrcode/codes"><b>here</b></a> and then do ?file=filename!<br> | |
Example: <a href="https://ianburgwin.net/psmdqrcode/?file=1FTq4zo.jpg">https://ianburgwin.net/psmdqrcode/?file=1FTq4zo.jpg</a><br> | |
If you would like your image to be tested, contact ihaveamac/ihaveahax (which is probably where you found the link!)<hr> | |
Source and credits for this PHP script is a <a href="https://gist.github.com/ihaveamac/3dae2929f8b87ed93dcf">GitHub Gist</a><hr> | |
<?php | |
$result = ""; | |
if (!isset($_REQUEST['file'])) { | |
die; | |
} | |
if (!file_exists("codes/".$_REQUEST['file'])) { | |
echo "that file does not exist, look above"; | |
die; | |
} | |
include_once('./lib/QrReader.php'); | |
$qrcode = new QrReader('./codes/'.$_REQUEST['file']); | |
$text = $qrcode->text(); //return decoded text from QR Code | |
file_put_contents($_REQUEST['file'].".txt", $text); | |
$text_hex = bin2hex($text); | |
$text_hex_switch = str_replace("ce25", "2400", $text_hex); | |
$text_switch = hex2bin($text_hex_switch); | |
$password = substr($text_switch, -160); | |
// due to being separated by 00, use double the normal amoubt | |
// i.e. each line is visually 20 characters, but technically 40 | |
$password_lines = substr($password, 0, 14)." ".substr($password, 14, 12)." ".substr($password, 26, 14)."<br>"; | |
$password_lines .= substr($password, 40, 14)." ".substr($password, 54, 12)." ".substr($password, 66, 14)."<br>"; | |
$password_lines .= substr($password, 80, 14)." ".substr($password, 94, 12)." ".substr($password, 106, 14)."<br>"; | |
$password_lines .= substr($password, 120, 14)." ".substr($password, 134, 12)." ".substr($password, 146, 14); | |
$result .= "<b>The password for the below image should be: (all bullseyes changed to $)</b><br>"; | |
$result .= "<pre>".$password_lines."</pre>"; | |
if (file_exists("fullcodes/".$_REQUEST['file'])) { | |
$result .= "Compare it with <a href=\"https://ianburgwin.net/psmdqrcode/fullcodes/".$_REQUEST['file']."\">the full image containing the password</a>."; | |
} else { | |
$result .= "There's no full image with the password for this one. But if the other ones are to go by, it's probably correct."; | |
} | |
$result .= "<br><img src='codes/".$_REQUEST['file']."'>"; | |
$result .= "<hr><h3>The process</h3>"; | |
$result .= "Source:<pre>".$text."</pre>"; | |
$result .= "<hr>Source bin to hex:<pre>".$text_hex."</pre>"; | |
$result .= "<hr>Switch bullseye to $ (ce25 -> 2400):<pre>".$text_hex_switch."</pre>"; | |
$result .= "<hr>Switched hex to bin:<pre>".$text_switch."</pre>"; | |
$result .= "<hr>Get last 160 characters (due to 00 between each)</b>:<pre>".$password."</pre>"; | |
echo $result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment