FORUMS
Remove All Ads from XDA

[TOOL] SBCalc - Generate your SBK (v1.1)

1,021 posts
Thanks Meter: 3,506
 
Post Reply Email Thread
Hey there,

Since i had many requests about SBK because i had to stop my webserver, i decided to write a small Windows tool to generate easilly your SBK if you already have your CPUID. (Infos about getting your CPUID -> http://forum.xda-developers.com/show....php?t=1624645)


Easy to use :

Extract both exe and dll in the same folder.
Launch SBCalc.exe, type your CPUID, clic "Generate", and it will return your SBK.


Update :

v1.1 : Support 15 or 16 digits for CPUID

Attached Files
File Type: zip SBCalc.zip - [Click for QR Code] (8.9 KB, 18267 views)
File Type: zip SBCalc_v1.1.zip - [Click for QR Code] (8.9 KB, 50834 views)
The Following 47 Users Say Thank You to vache For This Useful Post: [ View ]
 
 
2nd August 2012, 09:40 AM |#2  
Digil's Avatar
Senior Member
Flag Washington, DC
Thanks Meter: 63
 
More
Quote:
Originally Posted by vache

Hey there,

Since i had many requests about SBK because i had to stop my webserver, i decided to write a small Windows tool to generate easilly your SBK if you already have your CPUID. (Infos about getting your CPUID -> http://forum.xda-developers.com/show....php?t=1624645)]

You're the man (or woman, sorry, I don't actually know you)! TY much!
2nd August 2012, 10:00 AM |#3  
manu33xtro's Avatar
Senior Member
Flag Bordeaux : wine... Hum...
Thanks Meter: 66
 
More
Thumbs up
Hi Guy,

Thanks for this great tool !

Cheers.

Quote:
Originally Posted by vache

Hey there,

Since i had many requests about SBK because i had to stop my webserver, i decided to write a small Windows tool to generate easilly your SBK if you already have your CPUID. (Infos about getting your CPUID -> http://forum.xda-developers.com/show....php?t=1624645)


Easy to use :

Extract both exe and dll in the same folder.
Launch SBCalc.exe, type your CPUID, clic "Generate", and it will return your SBK.


The Following 7 Users Say Thank You to manu33xtro For This Useful Post: [ View ] Gift manu33xtro Ad-Free
2nd August 2012, 11:42 AM |#4  
Junior Member
Thanks Meter: 10
 
More
For Linux fans, the following piece of code (adapted from Skrilax_CZ's boot menu) seems to work too:
Code:
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <arpa/inet.h>

int
main (int argc, char *argv[])
{
  char uid[16], *p;
  uint32_t sbk[4];
  int i, j, mult;

  while (--argc)
  {
    p = argv[argc];
    if (p[0] == '0' && p[1] == 'x')
      p += 2;
    if (strlen (p) != 16)
      continue;
    strncpy (uid, p + 8, 8);
    strncpy (uid + 8, p, 8);
    for (i = 0; i < 16; i++)
      uid[i] = toupper (uid[i]);

    memset (sbk, 0, sizeof (sbk));

    for (i = 0; i < 4; i++)
    {
      sbk[i] = 0;
      mult = 1;
      for (j = 3; j >= 0; j--)
      {
        sbk[i] += uid[4*i+j] * mult;
        mult *= 100;
      }
    }
    for (i = 0; i < 4; i++)
      sbk[i] ^= sbk[3 - i];

    printf ("0x%08X 0x%08X 0x%08X 0x%08X\n",
        htonl (sbk[0]), htonl (sbk[1]), htonl (sbk[2]), htonl (sbk[3]));
  }

  exit (0);
}
Same thing in Perl:

Code:
#! /usr/bin/perl

sub chunk
{
  my ($mult, $res);

  $mult = 1;
  $res = 0;
  for (reverse unpack 'C4', uc shift)
  {
    $res += $_ * $mult;
    $mult *= 100;
  }
  $res;
}


for (@ARGV)
{
  my (@sbk, $i);

  s/^0x//;
  next
    if (! m/^[[:xdigit:]]{16}$/);

  @sbk = map { chunk $_ } unpack 'x8 (A4)4', $_ . $_;
  for ($i = 0; $i < @sbk; $i++)
    { $sbk[$i] ^= $sbk[-$i-1]; }
  @sbk = map { unpack 'N', pack 'L', $_ } @sbk;

  print +(join ' ', map { sprintf '0x%08X', $_ } @sbk), "\n";
}
The Following 5 Users Say Thank You to lcd047 For This Useful Post: [ View ] Gift lcd047 Ad-Free
2nd August 2012, 12:44 PM |#5  
Skrilax_CZ's Avatar
Inactive Recognized Developer
Thanks Meter: 2,403
 
More
Yes, I reverse engineered the SBK generating function in Pica_Func.dll, no need to use it anymore.
The Following 2 Users Say Thank You to Skrilax_CZ For This Useful Post: [ View ] Gift Skrilax_CZ Ad-Free
2nd August 2012, 12:48 PM |#6  
blackthund3r's Avatar
Senior Member
Flag London
Thanks Meter: 492
 
Donate to Me
More
Quote:
Originally Posted by lcd047

For Linux fans, the following piece of code (adapted from Skrilax_CZ's boot menu) seems to work too:

Code:
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>


uint32_t
swab32 (uint32_t src)
{
  uint32_t dst;
  int i;

  dst = 0;
  for (i = 0; i < 4; i++)
  {
    dst = (dst << 8) + (src & 0xFF);
    src >>= 8;
  }
  return dst;
}


int
main (int argc, char *argv[])
{
  char uid[16], *p;
  uint32_t sbk[4];
  int i, j, mult;

  while (--argc)
  {
    p = argv[argc];
    if (p[0] == '0' && p[1] == 'x')
      p += 2;
    if (strlen (p) != 16)
      continue;
    strncpy (uid, p + 8, 8);
    strncpy (uid + 8, p, 8);
    for (i = 0; i < 16; i++)
      uid[i] = toupper (uid[i]);

    memset (sbk, 0, sizeof (sbk));

    for (i = 0; i < 4; i++)
    {
      sbk[i] = 0;
      mult = 1;
      for (j = 3; j >= 0; j--)
      {
        sbk[i] += uid[4*i+j] * mult;
        mult *= 100;
      }
    }
    for (i = 0; i < 4; i++)
      sbk[i] ^= sbk[3 - i];

    printf ("0x%08X 0x%08X 0x%08X 0x%08X\n",
        swab32 (sbk[0]), swab32 (sbk[1]), swab32 (sbk[2]), swab32 (sbk[3]));
  }

  exit (0);
}
Same thing in Perl:

Code:
#! /usr/bin/perl

sub chunk
{
  my ($mult, $res);

  $mult = 1;
  $res = 0;
  for (reverse unpack 'C4', uc shift)
  {
    $res += $_ * $mult;
    $mult *= 100;
  }
  $res;
}


for (@ARGV)
{
  my (@sbk, $i);

  s/^0x//;
  next
    if (! m/^[[:xdigit:]]{16}$/);

  @sbk = map { chunk $_ } unpack 'x8 (A4)4', $_ . $_;
  for ($i = 0; $i < @sbk; $i++)
    { $sbk[$i] ^= $sbk[-$i-1]; }
  @sbk = map { unpack 'N', pack 'V', $_ } @sbk;

  print +(join ' ', map { sprintf '0x%08X', $_ } @sbk), "\n";
}

Thanks so much for the Perl code! You can see it in action at my new SBK Calculator site: http://a500bootloaderflash.tk/sbkcalc/
I hope you don't mind me using it in the true spirit of Open Source!
The Following 3 Users Say Thank You to blackthund3r For This Useful Post: [ View ] Gift blackthund3r Ad-Free
2nd August 2012, 01:05 PM |#7  
Junior Member
Thanks Meter: 10
 
More
Quote:
Originally Posted by blackthund3r

Thanks so much for the Perl code! You can see it in action at my new SBK Calculator site: http://a500bootloaderflash.tk/sbkcalc/
I hope you don't mind me using it in the true spirit of Open Source!

By all means, I posted it for people to use it.
The Following 3 Users Say Thank You to lcd047 For This Useful Post: [ View ] Gift lcd047 Ad-Free
2nd August 2012, 01:10 PM |#8  
blackthund3r's Avatar
Senior Member
Flag London
Thanks Meter: 492
 
Donate to Me
More
Quote:
Originally Posted by lcd047

By all means, I posted it for people to use it.

Thank you!
3rd August 2012, 08:35 PM |#9  
Junior Member
Thanks Meter: 0
 
More
Thank you Vache! Works great!
Quote:
Originally Posted by vache

Hey there,

Since i had many requests about SBK because i had to stop my webserver, i decided to write a small Windows tool to generate easilly your SBK if you already have your CPUID. (Infos about getting your CPUID -> http://forum.xda-developers.com/show....php?t=1624645)


Easy to use :

Extract both exe and dll in the same folder.
Launch SBCalc.exe, type your CPUID, clic "Generate", and it will return your SBK.


Thank you Vache, works great!

5th August 2012, 07:16 PM |#10  
Member
Thanks Meter: 2
 
More
Hello vache,

great tool, but i've got a problem...
if i get my cpuid with "adb devices" it is just 11 digits long...
your tool said that it have to be 15 digits.

and if i use your a500 manager there are 16 digits and characters in my serial number
5th August 2012, 09:42 PM |#11  
vache's Avatar
OP Recognized Developer
Flag Paris
Thanks Meter: 3,506
 
Donate to Me
More
Quote:
Originally Posted by IncredibleHero

Hello vache,

great tool, but i've got a problem...
if i get my cpuid with "adb devices" it is just 11 digits long...
your tool said that it have to be 15 digits.

and if i use your a500 manager there are 16 digits and characters in my serial number

Remove the 1st digit if it's a zero.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes