# HG changeset patch # User Michael Spacefalcon # Date 1391330756 0 # Node ID 3890c2672fe0756cb81a1129deab8afe99771422 # Parent b8753e705e1a55888451f2a90d659c040ed92115 atsc hack written diff -r b8753e705e1a -r 3890c2672fe0 .hgignore --- a/.hgignore Thu Jan 16 01:22:32 2014 +0000 +++ b/.hgignore Sun Feb 02 08:45:56 2014 +0000 @@ -2,6 +2,7 @@ \.[oa]$ +^atsc$ ^factdiff$ ^imeibrute$ ^mokosrec2bin$ diff -r b8753e705e1a -r 3890c2672fe0 Makefile --- a/Makefile Thu Jan 16 01:22:32 2014 +0000 +++ b/Makefile Sun Feb 02 08:45:56 2014 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -STD= factdiff mokosrec2bin rfcap-grep +STD= atsc factdiff mokosrec2bin rfcap-grep CRYPTO= imeibrute pirimei PROGS= ${STD} ${CRYPTO} @@ -12,6 +12,7 @@ ${CRYPTO}: ${CC} ${CFLAGS} -o $@ $@.c -lcrypto +atsc: atsc.c factdiff: factdiff.c imeibrute: imeibrute.c mokosrec2bin: mokosrec2bin.c diff -r b8753e705e1a -r 3890c2672fe0 atsc.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atsc.c Sun Feb 02 08:45:56 2014 +0000 @@ -0,0 +1,58 @@ +/* + * It is known that some GSM devices have undocumented AT commands for + * changing the IMEI. There is no standard syntax for such an AT command + * (by the "proper rules" one is not supposed to exist at all), and instead + * there seem to be several different ad hoc syntaxes. This source file, + * found on a Chinese site, implements one of these numerous ad hoc + * IMEI-changing AT commands: + * + * ftp://ftp.ifctf.org/pub/GSM/TI_src/ati_sc.c + * + * Notice that this particular incarnation of the "set IMEI" AT command + * is called AT@SC; there just happens to be an identically-named AT@SC + * command on Openmoko's GSM modems. Might it perchance be the same + * IMEI changing command? + * + * This program constructs what should be a valid input to the decoding + * logic in the ati_sc.c source above, for the purpose of testing whether + * or not such a command would indeed effect an IMEI change on a GTA02 modem. + */ + +#include +#include +#include +#include +#include + +static char hexdigits[] = "0123456789abcdef"; + +main(argc, argv) + char **argv; +{ + char hexout[16]; + unsigned n1, n2, cksum; + int i, c; + + if (argc != 2) { +usage: fprintf(stderr, "usage: %s 15-IMEI-digits\n", argv[0]); + exit(1); + } + if (strlen(argv[1]) != 15) + goto usage; + n1 = n2 = 0; + for (i = 0; i < 15; i++) { + c = argv[1][i]; + if (!isdigit(c)) + goto usage; + c -= '0'; + hexout[i] = hexdigits[c ^ 5]; + if (i < 7) + n1 = n1 * 10 + c; + else + n2 = n2 * 10 + c; + } + hexout[15] = '\0'; + cksum = (n1 + n2) % 1973; + printf("AT@SC=%s%04u\n", hexout, cksum); + exit(0); +}