IMEI sum Check PHP

Started on the old forum in April 2010 · view the original in the archive · old links redirect here

7 replies · 2,757 views · started 16 years ago · 1 min read

7 participants
bOrN2pwn Developer · 230 posts #1

Just needs to be fixed and it will work with some networks....

<?
//Grabs the IMEI
$imei = $_REQUEST["imei"];

//Loops all the Odd IMEI numbers, then times it by 2
for( $i = 0 ; $i<14 ; $i++ ) {
	$imei1 = $imei{$i}*2;
//THIS is where the main error is. It always shows up as Zero.
	$imei1a = $imei1a + $imei1{0} + $imei1{1}); 
}
//Another Loop, For even numbers
for( $i = 1; $i<14; $i++) {
	$imei2 = $imei{$i}*1;
	$imei2a = $imei2 + $imei2a;
}

//Adds the Results together.
$imei3 = $imei2a + $imei1a;

//If the Remainder is 0 the sum check equals zero
if($imei3 % 10 == 0) {
 $sum == 0;
 }
//Otherwise:
 	else {
	$sum == 10 - $imei3 % 10; 
	}
	//Validation stage - Finds if valid or not
if($imei3 % 10 != $sum) {
	echo 'Invalid';
	} else {
		echo 'Valid!';
		}
	
?>

find this

for( $i = 0 ; $i<14 ; $i++ ) 
{	$imei1a[$i] = $imei[$i]*2;    }

BakGat

class Counter {
public:
  void Count();
  int  ReadDisplay();
private:
  int  CurrentCount;
};

External image (may be gone) External image (may be gone) External image (may be gone)

Back up my hard drive? How do I put it in reverse? http://www.hackthissite.org Profile…

neostar Developer · 109 posts #2

How u r going to obtain there imei nos?

bogart Junior · 14 posts #5

bOrN2pwn wrote: Just needs to be fixed and it will work with some networks....

<?
//Grabs the IMEI
$imei = $_REQUEST["imei"];

//Loops all the Odd IMEI numbers, then times it by 2
for( $i = 0 ; $i<14 ; $i++ ) {
	$imei1 = $imei{$i}*2;
//THIS is where the main error is. It always shows up as Zero.
	$imei1a = $imei1a + $imei1{0} + $imei1{1}); 
}
//Another Loop, For even numbers
for( $i = 1; $i<14; $i++) {
	$imei2 = $imei{$i}*1;
	$imei2a = $imei2 + $imei2a;
}

//Adds the Results together.
$imei3 = $imei2a + $imei1a;

//If the Remainder is 0 the sum check equals zero
if($imei3 % 10 == 0) {
 $sum == 0;
 }
//Otherwise:
 	else {
	$sum == 10 - $imei3 % 10; 
	}
	//Validation stage - Finds if valid or not
if($imei3 % 10 != $sum) {
	echo 'Invalid';
	} else {
		echo 'Valid!';
		}
	
?>

find this

for( $i = 0 ; $i<14 ; $i++ ) 
{	$imei1a[$i] = $imei[$i]*2;    }

i first saw it here IMEI sum Check PHP - Nokia Flash Reverse Electronic Engineering. looks nice.

godsmurf Newbie · 1 posts #7

Is this any good?

It seems to work for me but is probably doing everything the hardest way ever..

function checkImei($imei) {
	$i = 0;
	$total = 0;
	
	$imei = strval($imei);
	
	while ($i < 14) {
		$digit = intval($imei[$i]);
		
		if ($i == 1 || $i == 3 || $i == 5 || $i == 7 || $i == 9 || $i == 11 || $i == 13) {
			$num = $digit * 2;
			$num = strval($num);
			
			if ($num > 9) {
				$digit1 = intval($num[0]);
				$digit2 = intval($num[1]);
				
				$new_num = $digit1 + $digit2;
				
			} else {
				$new_num = $num;
			}
		} else {
			$new_num = $digit;
		}
		$total = $total + $new_num;
	
		$i++;
	}
	$tens = $total / 10;
	$int = intval($tens);

	$checksum = 10 - ($total - ($int * 10));
	
	$result = strval(substr($imei,0,14)).strval($checksum);

	if ($imei == $result) {
		return true;
	} else {
		return false;
	}
}

Also only works for 15 digit IMEI not IMEISV which, from what I have looked at, you just have to accept as a random bunch of number 16 characters long.

metulj Super moderator Principal · 1,726 posts #8

godsmurf wrote: Is this any good?

It seems to work for me but is probably doing everything the hardest way ever..

function checkImei($imei) {
$i = 0;
$total = 0;

$imei = strval($imei);

while ($i < 14) {
$digit = intval($imei[$i]);

if ($i == 1 || $i == 3 || $i == 5 || $i == 7 || $i == 9 || $i == 11 || $i == 13) {
$num = $digit * 2;
$num = strval($num);

if ($num > 9) {
$digit1 = intval($num[0]);
$digit2 = intval($num[1]);

$new_num = $digit1 + $digit2;

} else {
$new_num = $num;
}
} else {
$new_num = $digit;
}
$total = $total + $new_num;

$i++;
}
$tens = $total / 10;
$int = intval($tens);

$checksum = 10 - ($total - ($int * 10));

$result = strval(substr($imei,0,14)).strval($checksum);

if ($imei == $result) {
return true;
} else {
return false;
}
}

Also only works for 15 digit IMEI not IMEISV which, from what I have looked at, you just have to accept as a random bunch of number 16 characters long.

IMEI contain ONLY 15 digits... so as far as that concerne.. it's fine... other than that code is useless... you can obtain IMEI, only from unsecured networks... that suck..

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close