aboutsummaryrefslogtreecommitdiffstats
path: root/pySim-read.py
AgeCommit message (Collapse)AuthorFilesLines
2020-08-28Add support for ADF_USIM/EF_EHPLMNHarald Welte1-0/+7
If the EF.EHPLMN exists, it contains the "Equivalent Home PLMN List". The odd part of that list is that it is not just a list of additional PLMN identities, but if the first digits of the IMSI are *not* listed in EF.EHPLMN, then the MCC/MNC of the IMSI prefix is suddently no longer considered the home network, but the subscriber is roaming. See TS 23.122: "If the HPLMN code derived from the IMSI is not present in the EHPLMN list, then it shall be treated as a Visited PLMN for PLMN selection purposes." Change-Id: I22d96ab4a424ec5bc1fb02f5e80165c646a748d3
2020-06-23pySim-read.py: Enable parsing of Home ePDG Identifier in USIMSupreeth Herle1-1/+12
As per TS 31.102, version 13.4.0 Release 13, this EF can found under ADF.USIM at File Id 6ff3. Also, if service n°106 and service n°107 are available, this file shall be present. Change-Id: I68114d328d1af5682a5bc1fa7642882e80b5de4d
2020-06-03ts_31_102.py: add EF_ADF_mapSebastian Viviani1-2/+2
the EF files in the USIM ADF are different to the ones int the GSM dir so added the dictionary to avoid conflicts and hardcoded values the 'DIR' one was added in ts_51_011.py, not sure if it should be there as it's not in that standard, but did it for simplicity Change-Id: I458380bf46b2986662ecdede2551c22cd9be92ba
2020-06-02Implement Generic SIM Access interface as per 3GPP TS 27.007Vadim Yanitskiy1-0/+8
According to 3GPP TS 27.007, sections 8.17 and 8.18, the modem may *optionally* provide Generic and/or Restricted SIM Access to the TE (Terminal Equipment) by means of the AT commands. This basically means that a modem can act as a card reader. Generic SIM Access allows the TE to send raw PDUs in the format as described in 3GPP TS 51.011 directly to the SIM card, while Restricted SIM Access is more limited, and thus is not really interesting to us. This change implements a new transport called ModemATCommandLink, so using it a SIM card can be read and/or programmed without the need to remove it from the modem's socket. A downside of this approach is relatively slow I/O speed compared to PC/SC readers. Tested with Quectel EC20: $ ./pySim-read.py --modem-dev /dev/ttyUSB2 Change-Id: I20bc00315e2c7c298f46283852865c1416047bc6 Signed-off-by: Vadim Yanitskiy <axilirator@gmail.com>
2020-05-12pySim-prog, pySim-read, do not echo reader idPhilipp Maier1-17/+3
pySim-prog and pySim-read currently echo back the pcsc reader id (or baudrate/socket, depending on the interface used). This makes the output unecessarly undeterministic, which becomes a problem when verifying the putput in tests. Lets not echo those variable, user supplied parameters back. Also lets move the code that does the initalization to utils, so that it can be used from pySim-prog and from pySim-read (code dup). Change-Id: I243cc332f075d007b1c111292effcc610e874eb3 Related: OS#4503
2020-04-27Enable parsing of ISIM Service table (IST)Supreeth Herle1-0/+13
As per TS 31.103, This EF indicates which ISIM services are available. If a service is not indicated as available in the ISIM, the ME shall not select this service. Parsing of IST is achieved by first selecting the ISIM application using its AID. This is followed by selecting EF.IST with File ID - 6f07 in ADF.ISIM Change-Id: I3f0a7227360b72a707dc1bcc4cc9c8a4ec7ad2b2
2020-04-27Enable parsing of USIM Service table (UST)Supreeth Herle1-0/+13
As per TS.31.102, This EF indicates which USIM services are available. If a service is not indicated as available in the USIM, the ME shall not select this service. Parsing of UST is achieved by first selecting the USIM application using its AID. This is followed by selecting EF.UST with File ID - 6f38 in ADF.USIM Change-Id: I54dbbd40bd3d22cee81f7c32e58cd946f8564257
2020-04-27Use helper method to print available service in EF.SSTSupreeth Herle1-9/+4
Change-Id: I375475e9f7210dae4e8da7258d6824dc2d54cf4c
2020-04-27pySim-read.py: Add ability to read Cards with correct CLA, P1 and P2 bytesSupreeth Herle1-1/+11
Initially the Card is read assuming a UICC SIM, but in case its not, an error 6e00 will be thrown indicating CLA not supported and Card has just Classic SIM application. Ref: https://web.archive.org/web/20090630004017/http://cheef.ru/docs/HowTo/APDU.info The above link provides the bytes to use for CLA, P1, P2 in APDU Change-Id: Ifea328eff3a381d7b82118e22d2bc0ec5f8a87e4
2020-04-16cards.py: Added method to select ADF by its full AIDSupreeth Herle1-0/+1
If AID of the desired ADF is in the list of AIDs of the Card/Card subclass object then ADF is selected or else None is returned Change-Id: Ie5f29eec14f099add1d0978e3e7d4ed3c9130854
2020-04-16Populate AIDs present on the UICCSupreeth Herle1-0/+3
Change-Id: I4d0d8f5f1e8cb252be55a2995b730927cfa7004d
2020-04-16Add ability to parse SIM Service Table (EF.SST)Supreeth Herle1-1/+15
As per TS.51.011, This EF indicates which services in the SIM are allocated, and whether, if allocated, the service is activated .If a service is not indicated as available in the SIM, the ME shall not select this service. Change-Id: Id28a35727adbaaa9df19b1adc621a0c51ad0e51b
2020-04-01Use the generic method read_binary of card class to read ADSupreeth Herle1-1/+1
Change-Id: Ie7f62913caed95f482445962954857bb69b58078
2020-04-01Move parsing of MSISDN to generic Card classSupreeth Herle1-6/+4
Change-Id: I5b726bc0dc8c8e5eb42f209b1fe0f35a46ac91be
2020-04-01Use the generic method read_binary of card class to read ACCSupreeth Herle1-1/+1
Change-Id: I92a02c74d64b3120055163548fc128ed6e0650a4
2020-04-01Move parsing of HPLMNAcT to generic Card classSupreeth Herle1-2/+2
Change-Id: I46c863c118dcbef89455c34289ed25e5a342f35b
2020-04-01Move parsing of OPLMNwAcT to generic Card classSupreeth Herle1-2/+2
Change-Id: I8050bd103a7085b2631ddc4e567d15e05f9428f2
2020-04-01Move parsing of PLMNwAcT to generic Card classSupreeth Herle1-2/+2
Change-Id: I14d7c2dc51fac6d5cf4a708a77ad23d252ba6094
2020-04-01Use the generic method read_binary of card class to read PLMNselSupreeth Herle1-1/+1
Change-Id: I0a683c479cd41ccc6a93c23434c73793cb5dc186
2020-04-01pySim-read.py: Use the method declared in cards.py to read SPNSupreeth Herle1-5/+4
Change-Id: I71c29e2d9d62c50d352556710e63ba398269a5c7
2020-04-01Use the generic method read_record of card class to read SMSPSupreeth Herle1-1/+1
Change-Id: I911c5339a739fbdd9d41e61b63f2410c8358815b
2020-04-01Use read_binary function of card class to read GID2 and reduce code duplicationSupreeth Herle1-1/+1
Change-Id: I5d80fcc1446a6691b8e2a09bcec558148fa31ab2
2020-03-22Move parsing of GID2 to generic Card classSupreeth Herle1-1/+1
Change-Id: I3fe4b08c888a39cda7e7fce7a467f17908bdc3ad
2020-03-22Move parsing of GID1 to generic Card classSupreeth Herle1-1/+1
Change-Id: Ie96408b1eecd6fc2595d619f6f0e3af851dacecb
2020-03-22pySim-read.py: Use the method declared in cards.py to read IMSISupreeth Herle1-2/+2
Change-Id: I2709b040d956a3a2b9210aa78c82a6ccf482f761
2020-03-22pySim-read.py: Use the method declared in cards.py to read ICCIDSupreeth Herle1-2/+2
Change-Id: I0dcda1ea617f3febe246b360b95887c04e5d2629
2020-03-22pySim-read.py: Added a common card detection function for both pySim-prog.py ↵Supreeth Herle1-0/+4
and pySim-read.py This function is used to detect the card type and return Card class/Card subclasses object if its a know card or else None. Also, an initial step towards refactoring of code. Change-Id: I71f57c6403dc933bd9d54f90df3d3fe105b4f66f
2020-03-13pySim-read.py: support for reading GID2 from SIMSupreeth Herle1-0/+10
Change-Id: I0e893c3929aa1be6b55af296484811a7b94db560
2020-03-13pySim-read.py: support for reading GID1 from SIMSupreeth Herle1-0/+10
Change-Id: I15d061daed20f770b9041977a0b1fc4fe44a8f95
2020-02-15pySim-read.py: do not import json, it is not neededVadim Yanitskiy1-6/+0
Change-Id: I4ae1d71c5695c9cd8ddebea514847b0be6a24c6c
2020-02-15pySim-read.py: fix reading and parsing of EF.MSISDNSupreeth Herle1-3/+5
This change implements parsing of EF.MSISDN (and thus EF.ADN) as per 3GPP TS 31.102, sections 4.2.26 and 4.4.2.3. Example (commercial SIM card from 401/02): EF.MSISDN: ffffffffffffffffffffffffffff07917787028982f7ffffffffffff Decoded (NPI=1 ToN=1): +77782098287 Note that sysmoUSIM-SJS1 in the test setup has malformed EF.MSISDN, so that's why the test output is changed. Change-Id: Ie914ae83d787e3f1a90f9f305bffd45053b8c863
2020-02-15pySim-read.py: print meaningful message when SPN is not setSupreeth Herle1-1/+3
Change-Id: I1d98520f33a8564c7d69f50a0811204f138f9dca
2020-02-14pySim-read.py: fix copy-paste: s/HPLMNAcT/PLMNsel/Vadim Yanitskiy1-1/+1
Change-Id: I4a452a2e439cb713621a028cf0046339f50864b6
2020-02-14Fix compatibility with Python 3: print() is a functionVadim Yanitskiy1-6/+6
Change-Id: I5dd8e5daf420fc8667c5156bfacc8763d8895993
2020-01-21Fix file permissionSupreeth Herle1-0/+0
Change-Id: I893869329e9547e06386baf4d16a18e545042d62
2020-01-21Added feature to read Service Provider Name (SPN) from the SIM cardSupreeth Herle1-1/+12
Change-Id: I8dc599a76c260ec2823ba5c9b22375b04a50daa8
2019-09-15python3 conversion: fix tabs and spaces inconsistencyDenis 'GNUtoo' Carikli1-23/+23
Without that fix we have: $ python3 pySim-read.py File "pySim-read.py", line 135 try: ^ TabError: inconsistent use of tabs and spaces in indentation The following command was used to do the conversion: sed 's# #\t#g' -i $(find -name "*.py") Then the remaining spaces spotted during the review were addressed manually. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> Change-Id: I83f76a8e9b6e36098f16552a0135a8c22dde545f
2019-05-10pySim-*.py: print info about selected reader interfaceVadim Yanitskiy1-0/+6
Change-Id: Idd791d7ef635e15915aab13274aefc15e70777b0
2019-05-10Use reference array for reading ICCIDMax1-1/+1
Change-Id: Iad0a328c6f0c9a4ab678efe068801849be48d8fc
2019-05-10utils: add EF [H|O]PLMNwAcT decoding.Daniel Laszlo Sitzer1-4/+4
Allow decoding and pretty printing of PLMNwAcT, HPLMNwAcT and OPLMNwAct. Includes unit tests for the added functions. Change-Id: I9b8ca6ffd98f665690b84239d9a228e2c72c6ff9
2019-04-01sysmo-usim-sjs1: update EF.AD with correct MNC lengthPhilipp Maier1-0/+7
At the moment EF.AD, which contains the length of the MNC is not updated. For two digit MNC (the usual case) this is fine since the length is set to 2 by default. However, when one wants to set an MNC with 3 digit length the file must be updated, otherwise the third digit of the MNC is recognized as part of the MSIN. Change-Id: I827092b2c7f7952f54b2d9f8dbda419a0dbfaf65 Related: OS#3850
2018-10-29pySim-*.py: add command line option for Calypso readerVadim Yanitskiy1-0/+7
Change-Id: Ia895ced62d29e06ae8af05cd95c9d181fb53b9df
2018-10-29pySim-*.py: refactor card reader driver initializationVadim Yanitskiy1-5/+5
This would facilitate adding new card reader drivers. Change-Id: Ia893537786c95a6aab3a51fb1ba7169023d5ef97
2018-07-13pySim-read: read contents of PLMN related files.Philipp Maier1-8/+40
The files EF.PLMNsel, EF.PLMNwAcT, EF.OPLMNwAcT, EF.HPLMNAcT are not yet printed by pysim-read. Lets add support for those files. Change-Id: Ice802033adfa6fc1bccc76da47495eb29c3aef6c Related: SYS#4245
2018-07-13pySim-read: Print exception when reading of EF.MSISDN failsPhilipp Maier1-2/+2
At the moment the exception is catched, but there is only a vague error message printed. However, the exception string usually tells us the status word, so it is very valuable to see it. Lets make sure that the exception string is printed here. Change-Id: Icb30470b1c0eee6a15fc028da820e92bf9ded27a
2017-12-29pySim-*.py: Set shebang to use python v2Pau Espin Pedrol1-1/+1
Nowadays bin/python usually points to python3, and this script is written in python2, which means if run directly from terminal it will fail with some print syntax errors. Change-Id: I6ab4e9edc44a8045915d4828c6de2fa98027fb7e
2013-07-18pySim-read: MISDN is not mandatorySylvain Munaut1-8/+11
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2013-07-13Add an utility to read data from a SIM card.Alexander Chemeris1-0/+138