blob: 622b00e618c1b862a07681794f068f29c84e95db [file] [log] [blame]
Sylvain Munaut76504e02010-12-07 00:24:32 +01001#!/usr/bin/env python
2
3#
4# Utility to deal with sim cards and program the 'magic' ones easily
5#
6#
7# Part of the sim link code of inspired by pySimReader-Serial-src-v2
8#
9#
10# Copyright (C) 2009 Sylvain Munaut <tnt@246tNt.com>
11# Copyright (C) 2010 Harald Welte <laforge@gnumonks.org>
12#
13# This program is free software: you can redistribute it and/or modify
14# it under the terms of the GNU General Public License as published by
15# the Free Software Foundation, either version 2 of the License, or
16# (at your option) any later version.
17#
18# This program is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21# GNU General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program. If not, see <http://www.gnu.org/licenses/>.
25#
26
27import hashlib
28from optparse import OptionParser
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +010029import os
Sylvain Munaut76504e02010-12-07 00:24:32 +010030import random
31import re
32import sys
33
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +010034try:
35 import json
Holger Hans Peter Freyther5dffefb2011-11-22 21:18:06 +010036except ImportError:
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +010037 # Python < 2.5
38 import simplejson as json
39
Sylvain Munaut76504e02010-12-07 00:24:32 +010040from pySim.commands import SimCardCommands
41from pySim.cards import _cards_classes
Sylvain Munaut607ce2a2011-12-08 20:16:43 +010042from pySim.utils import h2b, swap_nibbles, rpad
Sylvain Munaut76504e02010-12-07 00:24:32 +010043
44
45def parse_options():
46
47 parser = OptionParser(usage="usage: %prog [options]")
48
49 parser.add_option("-d", "--device", dest="device", metavar="DEV",
50 help="Serial Device for SIM access [default: %default]",
51 default="/dev/ttyUSB0",
52 )
Sylvain Munaut76504e02010-12-07 00:24:32 +010053 parser.add_option("-b", "--baud", dest="baudrate", type="int", metavar="BAUD",
54 help="Baudrate used for SIM access [default: %default]",
55 default=9600,
56 )
Sylvain Munaut9c8729a2010-12-08 23:20:27 +010057 parser.add_option("-p", "--pcsc-device", dest="pcsc_dev", type='int', metavar="PCSC",
Sylvain Munaute9fdecb2010-12-08 22:33:19 +010058 help="Which PC/SC reader number for SIM access",
59 default=None,
60 )
Sylvain Munaut76504e02010-12-07 00:24:32 +010061 parser.add_option("-t", "--type", dest="type",
62 help="Card type (user -t list to view) [default: %default]",
63 default="auto",
64 )
65 parser.add_option("-e", "--erase", dest="erase", action='store_true',
66 help="Erase beforehand [default: %default]",
67 default=False,
68 )
69
70 parser.add_option("-n", "--name", dest="name",
71 help="Operator name [default: %default]",
72 default="Magic",
73 )
74 parser.add_option("-c", "--country", dest="country", type="int", metavar="CC",
75 help="Country code [default: %default]",
76 default=1,
77 )
78 parser.add_option("-x", "--mcc", dest="mcc", type="int",
79 help="Mobile Country Code [default: %default]",
80 default=901,
81 )
82 parser.add_option("-y", "--mnc", dest="mnc", type="int",
Sylvain Munaut17716032010-12-08 22:33:51 +010083 help="Mobile Network Code [default: %default]",
Sylvain Munaut76504e02010-12-07 00:24:32 +010084 default=55,
85 )
Sylvain Munaut607ce2a2011-12-08 20:16:43 +010086 parser.add_option("-m", "--smsc", dest="smsc",
Sylvain Munaut76504e02010-12-07 00:24:32 +010087 help="SMSP [default: '00 + country code + 5555']",
88 )
Sylvain Munaut607ce2a2011-12-08 20:16:43 +010089 parser.add_option("-M", "--smsp", dest="smsp",
90 help="Raw SMSP content in hex [default: auto from SMSC]",
91 )
Sylvain Munaut76504e02010-12-07 00:24:32 +010092
93 parser.add_option("-s", "--iccid", dest="iccid", metavar="ID",
94 help="Integrated Circuit Card ID",
95 )
96 parser.add_option("-i", "--imsi", dest="imsi",
97 help="International Mobile Subscriber Identity",
98 )
99 parser.add_option("-k", "--ki", dest="ki",
100 help="Ki (default is to randomize)",
101 )
Harald Welte93b38cd2012-03-22 14:31:36 +0100102 parser.add_option("-o", "--opc", dest="opc",
103 help="OPC (default is to randomize)",
104 )
Holger Hans Peter Freythercca41792012-03-22 15:23:14 +0100105 parser.add_option("--op", dest="op",
106 help="Set OP to derive OPC from OP and KI",
107 )
Alexander Chemeris21885242013-07-02 16:56:55 +0400108 parser.add_option("--acc", dest="acc",
109 help="Set ACC bits (Access Control Code). not all card types are supported",
110 )
Harald Welte93b38cd2012-03-22 14:31:36 +0100111
Sylvain Munaut76504e02010-12-07 00:24:32 +0100112
113 parser.add_option("-z", "--secret", dest="secret", metavar="STR",
114 help="Secret used for ICCID/IMSI autogen",
115 )
116 parser.add_option("-j", "--num", dest="num", type=int,
117 help="Card # used for ICCID/IMSI autogen",
118 )
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +0100119 parser.add_option("--batch", dest="batch_mode",
120 help="Enable batch mode [default: %default]",
121 default=False, action='store_true',
122 )
123 parser.add_option("--batch-state", dest="batch_state", metavar="FILE",
124 help="Optional batch state file",
125 )
Sylvain Munaut76504e02010-12-07 00:24:32 +0100126
Sylvain Munaut143e99d2010-12-08 22:35:04 +0100127 parser.add_option("--write-csv", dest="write_csv", metavar="FILE",
128 help="Append generated parameters in CSV file",
129 )
130 parser.add_option("--write-hlr", dest="write_hlr", metavar="FILE",
131 help="Append generated parameters to OpenBSC HLR sqlite3",
132 )
133
Sylvain Munaut76504e02010-12-07 00:24:32 +0100134 (options, args) = parser.parse_args()
135
136 if options.type == 'list':
137 for kls in _cards_classes:
138 print kls.name
139 sys.exit(0)
140
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +0100141 if (options.batch_mode) and (options.num is None):
142 options.num = 0
143
Sylvain Munaut98d2b852010-12-23 20:27:25 +0100144 if (options.batch_mode):
145 if (options.imsi is not None) or (options.iccid is not None):
146 parser.error("Can't give ICCID/IMSI for batch mode, need to use automatic parameters ! see --num and --secret for more informations")
147
Sylvain Munaut76504e02010-12-07 00:24:32 +0100148 if ((options.imsi is None) or (options.iccid is None)) and (options.num is None):
149 parser.error("If either IMSI or ICCID isn't specified, num is required")
150
151 if args:
152 parser.error("Extraneous arguments")
153
154 return options
155
156
157def _digits(secret, usage, len, num):
158 s = hashlib.sha1(secret + usage + '%d' % num)
159 d = ''.join(['%02d'%ord(x) for x in s.digest()])
160 return d[0:len]
161
162def _mcc_mnc_digits(mcc, mnc):
163 return ('%03d%03d' if mnc > 100 else '%03d%02d') % (mcc, mnc)
164
165def _cc_digits(cc):
166 return ('%03d' if cc > 100 else '%02d') % cc
167
168def _isnum(s, l=-1):
169 return s.isdigit() and ((l== -1) or (len(s) == l))
170
Sylvain Munaut607ce2a2011-12-08 20:16:43 +0100171def _ishex(s, l=-1):
172 hc = '0123456789abcdef'
173 return all([x in hc for x in s.lower()]) and ((l== -1) or (len(s) == l))
174
Sylvain Munaut76504e02010-12-07 00:24:32 +0100175
Sylvain Munaut9f120e02010-12-23 20:28:24 +0100176def _dbi_binary_quote(s):
177 # Count usage of each char
178 cnt = {}
179 for c in s:
180 cnt[c] = cnt.get(c, 0) + 1
181
182 # Find best offset
183 e = 0
184 m = len(s)
185 for i in range(1, 256):
186 if i == 39:
187 continue
188 sum_ = cnt.get(i, 0) + cnt.get((i+1)&0xff, 0) + cnt.get((i+39)&0xff, 0)
189 if sum_ < m:
190 m = sum_
191 e = i
192 if m == 0: # No overhead ? use this !
193 break;
Sylvain Munaut1a914432011-12-08 20:08:26 +0100194
Sylvain Munaut9f120e02010-12-23 20:28:24 +0100195 # Generate output
196 out = []
197 out.append( chr(e) ) # Offset
198 for c in s:
199 x = (256 + ord(c) - e) % 256
200 if x in (0, 1, 39):
201 out.append('\x01')
202 out.append(chr(x+1))
203 else:
204 out.append(chr(x))
205
206 return ''.join(out)
207
Harald Welte2c0ff3a2011-12-07 12:34:13 +0100208def calculate_luhn(cc):
209 num = map(int, str(cc))
210 check_digit = 10 - sum(num[-2::-2] + [sum(divmod(d * 2, 10)) for d in num[::-2]]) % 10
211 return 0 if check_digit == 10 else check_digit
Sylvain Munaut9f120e02010-12-23 20:28:24 +0100212
Holger Hans Peter Freythercca41792012-03-22 15:23:14 +0100213def derive_milenage_opc(ki_hex, op_hex):
214 """
215 Run the milenage algorithm.
216 """
217 from Crypto.Cipher import AES
218 from Crypto.Util.strxor import strxor
219 from pySim.utils import b2h
220
221 # We pass in hex string and now need to work on bytes
222 aes = AES.new(h2b(ki_hex))
223 opc_bytes = aes.encrypt(h2b(op_hex))
224 return b2h(strxor(opc_bytes, h2b(op_hex)))
225
Sylvain Munaut76504e02010-12-07 00:24:32 +0100226def gen_parameters(opts):
227 """Generates Name, ICCID, MCC, MNC, IMSI, SMSP, Ki from the
228 options given by the user"""
229
230 # MCC/MNC
231 mcc = opts.mcc
232 mnc = opts.mnc
233
234 if not ((0 < mcc < 999) and (0 < mnc < 999)):
235 raise ValueError('mcc & mnc must be between 0 and 999')
236
237 # Digitize country code (2 or 3 digits)
238 cc_digits = _cc_digits(opts.country)
239
240 # Digitize MCC/MNC (5 or 6 digits)
241 plmn_digits = _mcc_mnc_digits(mcc, mnc)
242
Harald Welte2c0ff3a2011-12-07 12:34:13 +0100243 # ICCID (19 digits, E.118), though some phase1 vendors use 20 :(
Sylvain Munaut76504e02010-12-07 00:24:32 +0100244 if opts.iccid is not None:
245 iccid = opts.iccid
Harald Welte2c0ff3a2011-12-07 12:34:13 +0100246 if not _isnum(iccid, 19):
247 raise ValueError('ICCID must be 19 digits !');
Sylvain Munaut76504e02010-12-07 00:24:32 +0100248
249 else:
250 if opts.num is None:
251 raise ValueError('Neither ICCID nor card number specified !')
252
253 iccid = (
254 '89' + # Common prefix (telecom)
255 cc_digits + # Country Code on 2/3 digits
256 plmn_digits # MCC/MNC on 5/6 digits
257 )
258
Harald Welte2c0ff3a2011-12-07 12:34:13 +0100259 ml = 18 - len(iccid)
Sylvain Munaut76504e02010-12-07 00:24:32 +0100260
261 if opts.secret is None:
262 # The raw number
263 iccid += ('%%0%dd' % ml) % opts.num
264 else:
265 # Randomized digits
266 iccid += _digits(opts.secret, 'ccid', ml, opts.num)
267
Harald Welte2c0ff3a2011-12-07 12:34:13 +0100268 # Add checksum digit
269 iccid += ('%1d' % calculate_luhn(iccid))
270
Sylvain Munaut76504e02010-12-07 00:24:32 +0100271 # IMSI (15 digits usually)
272 if opts.imsi is not None:
273 imsi = opts.imsi
274 if not _isnum(imsi):
275 raise ValueError('IMSI must be digits only !')
276
277 else:
278 if opts.num is None:
279 raise ValueError('Neither IMSI nor card number specified !')
280
281 ml = 15 - len(plmn_digits)
282
283 if opts.secret is None:
284 # The raw number
285 msin = ('%%0%dd' % ml) % opts.num
286 else:
287 # Randomized digits
288 msin = _digits(opts.secret, 'imsi', ml, opts.num)
289
290 imsi = (
291 plmn_digits + # MCC/MNC on 5/6 digits
292 msin # MSIN
293 )
294
295 # SMSP
296 if opts.smsp is not None:
297 smsp = opts.smsp
Sylvain Munaut607ce2a2011-12-08 20:16:43 +0100298 if not _ishex(smsp):
299 raise ValueError('SMSP must be hex digits only !')
300 if len(smsp) < 28*2:
301 raise ValueError('SMSP must be at least 28 bytes')
Sylvain Munaut76504e02010-12-07 00:24:32 +0100302
303 else:
Sylvain Munaut607ce2a2011-12-08 20:16:43 +0100304 if opts.smsc is not None:
305 smsc = opts.smsc
306 if not _isnum(smsc):
307 raise ValueError('SMSC must be digits only !')
308 else:
309 smsc = '00%d' % opts.country + '5555' # Hack ...
310
Sylvain Munaut9977c862011-12-10 09:57:16 +0100311 smsc = '%02d' % ((len(smsc) + 3)//2,) + "81" + swap_nibbles(rpad(smsc, 20))
Sylvain Munaut607ce2a2011-12-08 20:16:43 +0100312
313 smsp = (
314 'e1' + # Parameters indicator
315 'ff' * 12 + # TP-Destination address
316 smsc + # TP-Service Centre Address
317 '00' + # TP-Protocol identifier
318 '00' + # TP-Data coding scheme
319 '00' # TP-Validity period
320 )
Sylvain Munaut76504e02010-12-07 00:24:32 +0100321
Alexander Chemeris21885242013-07-02 16:56:55 +0400322 # ACC
323 if opts.acc is not None:
324 acc = opts.acc
325 if not _ishex(acc):
326 raise ValueError('ACC must be hex digits only !')
327 if len(acc) != 2*2:
328 raise ValueError('ACC must be exactly 2 bytes')
329
330 else:
331 acc = None
332
Sylvain Munaut76504e02010-12-07 00:24:32 +0100333 # Ki (random)
334 if opts.ki is not None:
335 ki = opts.ki
336 if not re.match('^[0-9a-fA-F]{32}$', ki):
337 raise ValueError('Ki needs to be 128 bits, in hex format')
Sylvain Munaut76504e02010-12-07 00:24:32 +0100338 else:
339 ki = ''.join(['%02x' % random.randrange(0,256) for i in range(16)])
340
Harald Welte93b38cd2012-03-22 14:31:36 +0100341 # Ki (random)
342 if opts.opc is not None:
343 opc = opts.opc
344 if not re.match('^[0-9a-fA-F]{32}$', opc):
345 raise ValueError('OPC needs to be 128 bits, in hex format')
346
Holger Hans Peter Freythercca41792012-03-22 15:23:14 +0100347 elif opts.op is not None:
348 opc = derive_milenage_opc(ki, opts.op)
Harald Welte93b38cd2012-03-22 14:31:36 +0100349 else:
350 opc = ''.join(['%02x' % random.randrange(0,256) for i in range(16)])
351
352
Sylvain Munaut76504e02010-12-07 00:24:32 +0100353 # Return that
354 return {
355 'name' : opts.name,
356 'iccid' : iccid,
357 'mcc' : mcc,
358 'mnc' : mnc,
359 'imsi' : imsi,
360 'smsp' : smsp,
361 'ki' : ki,
Harald Welte93b38cd2012-03-22 14:31:36 +0100362 'opc' : opc,
Alexander Chemeris21885242013-07-02 16:56:55 +0400363 'acc' : acc,
Sylvain Munaut76504e02010-12-07 00:24:32 +0100364 }
365
366
367def print_parameters(params):
368
369 print """Generated card parameters :
370 > Name : %(name)s
371 > SMSP : %(smsp)s
372 > ICCID : %(iccid)s
373 > MCC/MNC : %(mcc)d/%(mnc)d
374 > IMSI : %(imsi)s
375 > Ki : %(ki)s
Harald Welte93b38cd2012-03-22 14:31:36 +0100376 > OPC : %(opc)s
Alexander Chemeris21885242013-07-02 16:56:55 +0400377 > ACC : %(acc)s
Sylvain Munaut76504e02010-12-07 00:24:32 +0100378""" % params
379
380
Harald Welte130524b2012-08-13 15:53:43 +0200381def write_params_csv(opts, params):
382 # csv
Sylvain Munaut143e99d2010-12-08 22:35:04 +0100383 if opts.write_csv:
384 import csv
Harald Welte93b38cd2012-03-22 14:31:36 +0100385 row = ['name', 'iccid', 'mcc', 'mnc', 'imsi', 'smsp', 'ki', 'opc']
Sylvain Munaut143e99d2010-12-08 22:35:04 +0100386 f = open(opts.write_csv, 'a')
387 cw = csv.writer(f)
388 cw.writerow([params[x] for x in row])
389 f.close()
390
Harald Welte130524b2012-08-13 15:53:43 +0200391def write_params_hlr(opts, params):
Sylvain Munaut143e99d2010-12-08 22:35:04 +0100392 # SQLite3 OpenBSC HLR
393 if opts.write_hlr:
394 import sqlite3
395 conn = sqlite3.connect(opts.write_hlr)
396
397 c = conn.execute(
398 'INSERT INTO Subscriber ' +
399 '(imsi, name, extension, authorized, created, updated) ' +
400 'VALUES ' +
401 '(?,?,?,1,datetime(\'now\'),datetime(\'now\'));',
402 [
403 params['imsi'],
404 params['name'],
405 '9' + params['iccid'][-5:]
406 ],
407 )
408 sub_id = c.lastrowid
409 c.close()
410
411 c = conn.execute(
412 'INSERT INTO AuthKeys ' +
413 '(subscriber_id, algorithm_id, a3a8_ki)' +
414 'VALUES ' +
415 '(?,?,?)',
Sylvain Munaut9f120e02010-12-23 20:28:24 +0100416 [ sub_id, 2, sqlite3.Binary(_dbi_binary_quote(h2b(params['ki']))) ],
Sylvain Munaut143e99d2010-12-08 22:35:04 +0100417 )
418
419 conn.commit()
420 conn.close()
421
Harald Welte130524b2012-08-13 15:53:43 +0200422def write_parameters(opts, params):
423 write_params_csv(opts, params)
424 write_params_hldr(opts, params)
425
Sylvain Munaut143e99d2010-12-08 22:35:04 +0100426
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +0100427BATCH_STATE = [ 'name', 'country', 'mcc', 'mnc', 'smsp', 'secret', 'num' ]
428BATCH_INCOMPATIBLE = ['iccid', 'imsi', 'ki']
Sylvain Munaut143e99d2010-12-08 22:35:04 +0100429
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +0100430def init_batch(opts):
431 # Need to do something ?
432 if not opts.batch_mode:
433 return
Sylvain Munaut76504e02010-12-07 00:24:32 +0100434
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +0100435 for k in BATCH_INCOMPATIBLE:
436 if getattr(opts, k):
437 print "Incompatible option with batch_state: %s" % (k,)
438 sys.exit(-1)
Sylvain Munaut76504e02010-12-07 00:24:32 +0100439
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +0100440 # Don't load state if there is none ...
441 if not opts.batch_state:
442 return
Sylvain Munaut76504e02010-12-07 00:24:32 +0100443
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +0100444 if not os.path.isfile(opts.batch_state):
445 print "No state file yet"
446 return
447
448 # Get stored data
449 fh = open(opts.batch_state)
450 d = json.loads(fh.read())
451 fh.close()
452
453 for k,v in d.iteritems():
454 setattr(opts, k, v)
455
456
457def save_batch(opts):
458 # Need to do something ?
459 if not opts.batch_mode or not opts.batch_state:
460 return
461
462 d = json.dumps(dict([(k,getattr(opts,k)) for k in BATCH_STATE]))
463 fh = open(opts.batch_state, 'w')
464 fh.write(d)
465 fh.close()
466
467
468def card_detect(opts, scc):
Sylvain Munautbdca2522010-12-09 13:31:58 +0100469
Sylvain Munaut76504e02010-12-07 00:24:32 +0100470 # Detect type if needed
471 card = None
472 ctypes = dict([(kls.name, kls) for kls in _cards_classes])
473
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +0100474 if opts.type in ("auto", "auto_once"):
Sylvain Munaut76504e02010-12-07 00:24:32 +0100475 for kls in _cards_classes:
476 card = kls.autodetect(scc)
477 if card:
478 print "Autodetected card type %s" % card.name
479 card.reset()
480 break
481
482 if card is None:
483 print "Autodetection failed"
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +0100484 return
485
486 if opts.type == "auto_once":
487 opts.type = card.name
Sylvain Munaut76504e02010-12-07 00:24:32 +0100488
489 elif opts.type in ctypes:
490 card = ctypes[opts.type](scc)
491
492 else:
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +0100493 raise ValueError("Unknown card type %s" % opts.type)
Sylvain Munaut76504e02010-12-07 00:24:32 +0100494
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +0100495 return card
Sylvain Munaut76504e02010-12-07 00:24:32 +0100496
Sylvain Munaut76504e02010-12-07 00:24:32 +0100497
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +0100498if __name__ == '__main__':
499
500 # Parse options
501 opts = parse_options()
502
503 # Connect to the card
504 if opts.pcsc_dev is None:
505 from pySim.transport.serial import SerialSimLink
506 sl = SerialSimLink(device=opts.device, baudrate=opts.baudrate)
507 else:
508 from pySim.transport.pcsc import PcscSimLink
509 sl = PcscSimLink(opts.pcsc_dev)
510
511 # Create command layer
512 scc = SimCardCommands(transport=sl)
513
514 # Batch mode init
515 init_batch(opts)
516
517 # Iterate
518 done = False
519 first = True
520 card = None
Sylvain Munaut1a914432011-12-08 20:08:26 +0100521
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +0100522 while not done:
523 # Connect transport
524 print "Insert card now (or CTRL-C to cancel)"
525 sl.wait_for_card(newcardonly=not first)
526
527 # Not the first anymore !
528 first = False
529
530 # Get card
531 card = card_detect(opts, scc)
532 if card is None:
533 if opts.batch_mode:
534 first = False
535 continue
536 else:
537 sys.exit(-1)
538
539 # Erase if requested
540 if opts.erase:
541 print "Formatting ..."
542 card.erase()
543 card.reset()
544
545 # Generate parameters
546 cp = gen_parameters(opts)
547 print_parameters(cp)
548
549 # Program the card
550 print "Programming ..."
551 card.program(cp)
552
553 # Write parameters permanently
554 write_parameters(opts, cp)
555
556 # Batch mode state update and save
Sylvain Munaut8d243e82010-12-23 20:27:48 +0100557 if opts.num is not None:
558 opts.num += 1
Sylvain Munaut8f7d3ba2010-12-09 13:32:48 +0100559 save_batch(opts)
560
561 # Done for this card and maybe for everything ?
562 print "Done !\n"
563
564 if not opts.batch_mode:
565 done = True
Sylvain Munaut76504e02010-12-07 00:24:32 +0100566