Skip to content

Instantly share code, notes, and snippets.

@z3ntu
Forked from benlorenz/fp3verifycode.pl
Last active February 11, 2020 00:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save z3ntu/9c09120bb44c6dd9fe163931a1478ea9 to your computer and use it in GitHub Desktop.
Save z3ntu/9c09120bb44c6dd9fe163931a1478ea9 to your computer and use it in GitHub Desktop.
FP3 oem unlock verify code
<!DOCTYPE html>
<html lang="en">
<head>
<title>FP3 'verify code' generator</title>
</head>
<body>
<h2>FP3 'verify code' generator</h2>
<p>A big thanks to <a href="https://forum.fairphone.com/t/oem-unlock-input-verify-code/56231/11?u=z3ntu" target="_blank">_tmp in the Fairphone Forum</a> for the code behind this site!</p>
<p>Enter the IMEI (slot 1) and serial number values from your phone and press submit.</p>
<p>You can find those numbers under "About phone" - "Model &amp; hardware" in the Settings app.</p>
<form method="post">
IMEI1:<br>
<input type="text" name="imei"><br>
Serial:<br>
<input type="text" name="serial"><br>
<input type="submit" value="Submit">
</form>
<?php
if (isset($_POST["imei"]) && isset($_POST["serial"])) {
$imei = $_POST["imei"];
$serial = $_POST["serial"];
if(strlen($imei) != 15 || strlen($serial) < 10) {
print("<h3>IMEI must be 15 characters and serial must be longer than 10 characters.</h3>");
return;
}
$key = $imei . $serial;
$md5 = md5($key);
$chk = 0;
for ($i = 0; $i < 8; $i++) {
$chk += ord(substr($md5,$i,1)) * 256**($i%4);
}
$chk &= 0xFFFFFFFF;
print("<h3>Code: " . dechex($chk) . "</h3>");
}
?>
</body>
</html>
@rugk
Copy link

rugk commented Feb 10, 2020

Maybe this can be re-implemented in JS instead of PHP, so one does not need to send that data over the wire and everything happens locally?

@z3ntu
Copy link
Author

z3ntu commented Feb 10, 2020

I wrote that in the forum comment as well

And now thinking about this, it would have probably been nicer to implement it as client-side JavaScript. Oh well.

If you translate this "algorithm" into JavaScript, I can definitely put it up on my website but honestly I have better things to do 😉

@rugk
Copy link

rugk commented Feb 11, 2020

I don't, so… 😜

Here we go:
https://gist.github.com/rugk/0ab18cc0f43d823c6464b790d8c77d3d

Actually, as all that code in a gist is bad, here we have some repos:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment