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

Search This thread

vache

Recognized Developer
Jun 12, 2009
1,137
3,712
Paris
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://xdaforums.com/showthread.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

618479sbcalc.png
 

Attachments

  • SBCalc.zip
    8.9 KB · Views: 20,245
  • SBCalc_v1.1.zip
    8.9 KB · Views: 55,180
Last edited:

manu33xtro

Senior Member
Nov 23, 2008
496
66
Bordeaux : wine... Hum...
Hi Guy,

Thanks for this great tool !

Cheers.

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://xdaforums.com/showthread.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.


618479sbcalc.png
 

lcd047

Member
Nov 8, 2011
31
12
Samsung Galaxy S23 Ultra
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";
}
 
Last edited:

blackthund3r

Senior Member
Feb 27, 2012
594
493
London
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! :)
 

sanjayayogi

Member
Dec 31, 2010
18
0
Thank you Vache! Works great!

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://xdaforums.com/showthread.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.


618479sbcalc.png

Thank you Vache, works great!

:good:
 
Oct 21, 2011
30
2
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
 
Last edited:

cyclone77

Member
Apr 30, 2016
5
0
can u help me sir

i have my cpuid but when i use this tool i got the warning "please check your cpuid"....can u help get sbk code from my cpuid???here my cpuid no (0xa74420244808057)
 

Top Liked Posts

  • There are no posts matching your filters.
  • 47
    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://xdaforums.com/showthread.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

    618479sbcalc.png
    7
    Hi Guy,

    Thanks for this great tool !

    Cheers.

    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://xdaforums.com/showthread.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.


    618479sbcalc.png
    5
    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";
    }
    3
    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! :)
    3
    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. :)