comparison atsc.c @ 65:3890c2672fe0

atsc hack written
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 02 Feb 2014 08:45:56 +0000
parents
children 39f2ccd06b57
comparison
equal deleted inserted replaced
64:b8753e705e1a 65:3890c2672fe0
1 /*
2 * It is known that some GSM devices have undocumented AT commands for
3 * changing the IMEI. There is no standard syntax for such an AT command
4 * (by the "proper rules" one is not supposed to exist at all), and instead
5 * there seem to be several different ad hoc syntaxes. This source file,
6 * found on a Chinese site, implements one of these numerous ad hoc
7 * IMEI-changing AT commands:
8 *
9 * ftp://ftp.ifctf.org/pub/GSM/TI_src/ati_sc.c
10 *
11 * Notice that this particular incarnation of the "set IMEI" AT command
12 * is called AT@SC; there just happens to be an identically-named AT@SC
13 * command on Openmoko's GSM modems. Might it perchance be the same
14 * IMEI changing command?
15 *
16 * This program constructs what should be a valid input to the decoding
17 * logic in the ati_sc.c source above, for the purpose of testing whether
18 * or not such a command would indeed effect an IMEI change on a GTA02 modem.
19 */
20
21 #include <stdio.h>
22 #include <ctype.h>
23 #include <string.h>
24 #include <strings.h>
25 #include <stdlib.h>
26
27 static char hexdigits[] = "0123456789abcdef";
28
29 main(argc, argv)
30 char **argv;
31 {
32 char hexout[16];
33 unsigned n1, n2, cksum;
34 int i, c;
35
36 if (argc != 2) {
37 usage: fprintf(stderr, "usage: %s 15-IMEI-digits\n", argv[0]);
38 exit(1);
39 }
40 if (strlen(argv[1]) != 15)
41 goto usage;
42 n1 = n2 = 0;
43 for (i = 0; i < 15; i++) {
44 c = argv[1][i];
45 if (!isdigit(c))
46 goto usage;
47 c -= '0';
48 hexout[i] = hexdigits[c ^ 5];
49 if (i < 7)
50 n1 = n1 * 10 + c;
51 else
52 n2 = n2 * 10 + c;
53 }
54 hexout[15] = '\0';
55 cksum = (n1 + n2) % 1973;
56 printf("AT@SC=%s%04u\n", hexout, cksum);
57 exit(0);
58 }