nokia unlock script

Discussion in 'PHP' started by smetten, Sep 28, 2006.

  1. #1
    Hi,

    I have this nokia unlock script, but i only have the php script.
    I don´t know how I can make a html form where I can enter the variables.

    Can somebody help me?

    this is the php script

    <?php
    
    // uso: http://localhost/dct2.php?imei=111111111111119&net=22222&gid1=ADCC&gid2=44FF&msin=1234567890
    
    // *********************************
    function string_to_array($cadena)
    {
    	for ($i = 0; $i < strlen($cadena); $i++)
    		$nueva[$i] = ord(substr($cadena, $i, 1));
    	return $nueva;
    }
    
    function char_of($cadena, $pos)
    {
    	return ord(substr($cadena, $pos, 1));
    }
    //**********************************
    
    function convertir_byte_a_hex ($byte)
    {
            if (($byte > 47) && ($byte < 58))  // '0' a '9'
                    return ($byte-48);
            else if (($byte > 64) && ($byte < 71))  // 'A' a 'F' o otro caracter
            	return ($byte-55);
            else
            	return $byte;
    }
    
    
    $Sl_F0 = array(0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
    $S_Sub = array(0x17,0x2D,0x25,0x29,0x17,0x15,0x23,0x13,0x2B,0x19,0x20,0x16,0x29,0x1F,0x1C);
    $S_Xor = array(0x02,0x0B,0x07,0x04,0x01,0x19,0x11,0x09,0x10,0x1E);
    $S_Add = array(0x01,0x05,0x07,0x06,0x03,0x02,0x03,0x05,0x09,0x01);
    $C_112 = array(0x17,0x2C,0x43,0x0E,0x22,0x13,0x43,0x4D,0x59,0x16,0x22,0x4E,0x37,0x58,
    	       0x5C,0x0C,0x23,0x1D,0x4E,0x5C,0x22,0x2D,0x15,0x44,0x30,0x34,0x3B,0x0D,
    	       0x4B,0x2D,0x5A,0x12,0x24,0x43,0x35,0x4A,0x47,0x36,0x13,0x17,0x53,0x24,
    	       0x13,0x1B,0x1F,0x62,0x38,0x4D,0x54,0x2A,0x38,0x15,0x1D,0x0D,0x0B,0x41,
    	       0x22,0x47,0x1D,0x4E,0x62,0x22,0x41,0x17,0x26,0x30,0x2C,0x57,0x38,0x36,
    	       0x12,0x40,0x20,0x59,0x23,0x21,0x36,0x32,0x48,0x52,0x62,0x3F,0x13,0x0D,
    	       0x42,0x2E,0x18,0x2D,0x4E,0x20,0x0E,0x23,0x4A,0x60,0x47,0x25,0x30,0x39,
    	       0x3F,0x52,0x48,0x3B,0x1A,0x26,0x5D,0x2D,0x2C,0x57,0x45,0x11,0x20,0x30);
    $C_1C = array(0x01,0x05,0x07,0x06,0x03,0x02,0x03,0x05,
    	      0x09,0x01,0x00,0x02,0x05,0x06,0x02,0x08,
    	      0x05,0x06,0x07,0x09,0x02,0x03,0x05,0x08,
    	      0x03,0x05,0x04,0x01);
    
    
    
    function calcular_codigo ($CodeNR, $IMEI_p, $network_code, $GID1, $GID2, $MSIN)
    {
    	global $Sl_F0;
    	global $S_Sub;
    	global $S_Xor;
    	global $S_Add;
    	global $C_112;
    	global $C_1C;
    
    	$Secr=0;
    
    	$network_code=string_to_array($network_code);
    	$GID1=string_to_array($GID1);
    	$GID2=string_to_array($GID2);
    	$MSIN=string_to_array($MSIN);
    	$Imei=string_to_array($IMEI_p);
    	
    	for ($i=0; $i<5; $i++)
    		$SP[$i]=convertir_byte_a_hex($network_code[$i]);
    		
    	$Gid1_1=convertir_byte_a_hex($GID1[0]) << 4;
    	$Gid1_1|=convertir_byte_a_hex($GID1[1]);
    	$Gid1_2=convertir_byte_a_hex($GID1[2]) << 4;
    	$Gid1_2|=convertir_byte_a_hex($GID1[3]);
    
    	$Gid2_1=convertir_byte_a_hex($GID2[0]) << 4;
    	$Gid2_1|=convertir_byte_a_hex($GID2[1]);
    	$Gid2_2=convertir_byte_a_hex($GID2[2]) << 4;
    	$Gid2_2|=convertir_byte_a_hex($GID2[3]);
    
    	for ($i=0; $i<10; $i++)
    		$IMSI[$i]=convertir_byte_a_hex($MSIN[$i]);
    
    	if ($CodeNR == 4)
    	{
    		$Sl_F0[0]=($SP[0] << 4);		 // original: Sl_F0[0]=9 | (SP[0] << 4);
    		$Sl_F0[1]=$SP[1] | ($SP[2] << 4);
    		$Sl_F0[2]=$SP[3] | ($SP[4] << 4);
    		$Sl_F0[3]=$IMSI[0] | ($IMSI[1] << 4);
    		$Sl_F0[4]=$IMSI[2] | ($IMSI[3] << 4);
    		$Sl_F0[5]=$IMSI[4] | ($IMSI[5] << 4);   // original: Sl_F0[5]=IMSI[4] | (IMSI[5] << 4);
    		$Sl_F0[6]=$IMSI[6] | ($IMSI[7] << 4);
    		$Sl_F0[7]=$IMSI[8] | ($IMSI[9] << 4);
    	}
    
    	$Sl_F1[0]=$Gid1_1;
    	$Sl_F1[1]=$Gid1_2;
    
    	$Sl_F2[0]=$Gid2_1;
    	$Sl_F2[1]=$Gid2_2;
    
    
    	$Sl_Temp[0]=$SP[0] << 4;
    	$Sl_Temp[1]=$SP[1] | ($SP[2] << 4);
    	$Sl_Temp[2]=$SP[3] | ($SP[4] << 4);
    
    	//Inicio Calc_28;
    	$Fux=((($Sl_Temp[0] & 0xF0) + $Sl_Temp[1]) % 0x08);
    	$Fix=$Sl_Temp[2] % 0x0E;
    	$O=$Fix + ($Fux * 0x0E);
    	$A_3[0]=($Sl_Temp[0] & 0xF0) - $C_112[$O];
    	$A_3[0]&=0xFF;
    
    	for ($I=1; $I<=2; $I++)
    	{
    		$O=(($Fix + $I) % 0x0E) + ($Fux * 0x0E);
    		$A_3[$I]=$Sl_Temp[$I] - $C_112[$O];
    		$A_3[$I]&=0xFF;
    	}
    
    	$NSL_Result=0;
    	$C=0;
    	do
    	{
    	$NSL_Result= $NSL_Result + ($A_3[2] >> $C) + ($A_3[1] >> $C);
    	$NSL_Result&=0xFF;
    	$C=$C+2;
    	} while ($C<=6);
    	$NSL_Result=$NSL_Result & 0x07;
    
    	for ($I=0; $I<=0x1b; $I++)
    	{
    		$O=((($NSL_Result+$I) % 0x08) * 0x0E)+(($I+$Secr) % 0x0E);
    		$A_1C[$I]= ($A_3[$I % 0x03] + $Secr + $C_1C[$I]) ^ $C_112[$O];
    		$A_1C[$I]&=0xFF;
    	}
    
    	$NSL_Result=0;
    	$C=0;
    	do
    	{
    	$NSL_Result= $NSL_Result ^ ($A_3[2] >> $C) ^ ($A_3[0] >> $C);
    	$C=$C+2;
    	} while ($C<=6);
    	$NSL_Result=$NSL_Result & 0x07;
    
    	for ($I=0; $I<=0x1b; $I++)
    	{
    		$O=((($NSL_Result-$I+0x1C) % 0x08) * 0x0E)+(($I+$Secr) % 0x0E);
    		$W1=$C_112[$O] & 0x00FF;
    		$W2=$A_1C[$I] & 0x00FF;
    		$W3=($W1 * $W2) % 0x0100;
    		$W1=$C_1C[$I] & 0x00FF;
    		$W2=$W3+$W1;
    		$T28[$I]=($W2 % 0x0A)+0x30;
    	}
    	
    	//Fin Calc_28
    
    	$Summ=0;
    	for ($I=0x08; $I<=0x0d; $I++)
    		$Summ= ($Summ+ $Imei[$I])&0xFF;
    
    	for ($I=0; $I<=7; $I++)
    	{
    		$O=($I+$Summ) % 0x0F;
    		$Buff[$I]=($Sl_F0[$I]-$S_Sub[$O])&0xFF;
    	}
    
    	for ($I=8; $I<=9; $I++)
    	{
    		$O=($I+$Summ) % 0x0F;
    		$Buff[$I]=($Sl_F1[$I-0x08]-$S_Sub[$O])&0xFF;
    	}
    
    	for ($I=0x0A; $I<=0x0B; $I++)
    	{
    		$O=($I+$Summ) % 0x0F;
    		$Buff[$I]=($Sl_F2[$I-0x0A]-$S_Sub[$O])&0xFF;
    	}
    
    	for ($I=0x0C; $I<=0x1A; $I++)
    	{
    		$O=($I-0x0c+$Summ) % 0x0F;
    		$Buff[$I]=($Imei[$I-0x0C]-$S_Sub[$O])&0xFF;
    	}
    
    	for ($L=0; $L<=0x09; $L++)
    		for ($I=0; $I<=0x1A; $I++)
    		{
    			$O=($S_Xor[$L]+$I) % 0x1B;
    			$Long[$L * 0x1B + $I]= $Buff[$O] ^ $Buff[$I];
    		}
    
    	for ($L=0; $L<=0x09; $L++)
    	{
    		$NSL_Result=0;
    		for ($I=0; $I<=0x1a; $I++)
    		{
    			$O=(5*$I+$L) % 0x1C;
    			$NSL_Result= $NSL_Result + ($T28[$O] * $Long[$L * 0x1B + $I]);
    			$NSL_Result&=0xFF;
    		}
    		$SL[$L]=($NSL_Result+$S_Add[$L]) % 0x0A;
    	}
    
    	// resultado SL
    	for ($i=0; $i<10; $i++)
    		$codigo_liberacion[$i]=$SL[$i];
    	
    	return $codigo_liberacion;
    }
    
    
    $resultado = calcular_codigo (1, $_GET[imei], $_GET[net], "FFFF", "FFFF", "1234567890");
    $resultado = implode("",$resultado);
    echo "#pw+".$resultado."+1"."<br>";
    
    if (isset($_GET[gid1]))
    {
    	$resultado = calcular_codigo (2, $_GET[imei], $_GET[net], $_GET[gid1], "FFFF", "1234567890");
    	$resultado = implode("",$resultado);
    	echo "#pw+".$resultado."+2"."<br>";
    }
    
    if (isset($_GET[gid2]))
    {
    	$resultado = calcular_codigo (3, $_GET[imei], $_GET[net], "FFFF", $_GET[gid2], "1234567890");
    	$resultado = implode("",$resultado);
    	echo "#pw+".$resultado."+3"."<br>";
    }
    
    if (isset($_GET[msin]))
    {
    	$resultado = calcular_codigo (4, $_GET[imei], $_GET[net], "FFFF", "FFFF", $_GET[msin]);
    	$resultado = implode("",$resultado);
    	echo "#pw+".$resultado."+4"."<br>";
    }
    
    echo "<br><br><b>PHPcalc by indear</b>";
    
    ?>
    PHP:
     
    smetten, Sep 28, 2006 IP
  2. mcfox

    mcfox Wind Maker

    Messages:
    7,526
    Likes Received:
    716
    Best Answers:
    0
    Trophy Points:
    360
    #2
    How does that work then? Do you plug the phone in or use a bluetooth thingy to connect computer and phone ...?

    I'm a mobile-phonophobe, btw. :eek:
     
    mcfox, Sep 28, 2006 IP
  3. smetten

    smetten Active Member

    Messages:
    269
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #3
    no,

    you just send *#06# on your nokia phone and you get a code.
    this code you enter in the html form (if I have one) and you get a new code.
    when restarting your mobile phone you enter this code instead of your security code and it should work. (it does i tried it on other sites)
     
    smetten, Sep 28, 2006 IP
  4. t.m

    t.m Peon

    Messages:
    108
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
    <form action="INSERT URL TO PHP HERE" method="get">
    <table>
    <tr>
    <td>IMEI:</td><td> <input type="text" name="imei"></td>
    </tr>
    <tr>
    <td>Net:</td><td> <input type="text" name="net"></td>
    </tr>
    <tr>
    <td>GID1:</td><td> <input type="text" name="gid1"></td>
    </tr>
    <tr>
    <td>MSIN:</td><td> <input type="text" name="msin"></td>
    </tr>
    <td> <input type="reset" value="Reset"></td><td> <input type="sumbit" value="Submit"></td>
    </tr>
    </table>
    </form>
    HTML:
     
    t.m, Sep 29, 2006 IP
  5. jacobbannier

    jacobbannier Active Member

    Messages:
    1,155
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    90
    #5
    Please report back if that works.
     
    jacobbannier, Sep 29, 2006 IP