如何以编程方式访问 SIM 卡?

发布于 2024-09-01 03:03:34 字数 373 浏览 10 评论 0原文

只需任何旧的 GSM 兼容 SIM 卡(3G USIM 的奖励)。

我想我需要一些硬件?有人可以推荐一些适合业余爱好者的便宜的东西和更专业的东西吗?

我认为会有完整的 API 文档和硬件,所以也许应该标记为“与编程无关”?抱歉,如果是的话。

任何好的 URL 或书籍(我熟悉 3GPP 标准)。

我不是(黑帽)黑客,别担心,只是对 SIM 卡秘书、数据医生恢复等不满意,所以想编写自己的代码,但可能会将其商业化,或提供 SIM 卡编程服务(从损坏的卡中恢复数据等)作为副业。


更新:虽然我主要感兴趣的是阅读我的短信进行备份,但如果有人知道便宜的 SIM 卡写入器,这可能会是一个额外的好处(这样我就可以备份全部或部分 SIM 并在以后恢复)

Just any old GSM compatible SIM card (bonus for 3G USIM).

I presume I need some hardware? Can anyone recommend something cheap for hobbyist, and something more professional?

I presume that there will be full docs of an API with the h/w, so maybe this should be tagged "no-programming-related"? Sorry, if so.

Any good URLs or books (I am conversant with the 3GPP standards).

I'm not (black hat) hacking, don't worry, just not pleased with the likes of SIM Card Secretary, Data Doctor Recovery, etc, so would like to code my own, but might turn it commercial, or offer SIM card programming services (data recover from damaged card, etc) as a sideline.


Update: while I am primarily interested just reading my SMS for backup, it might be a bonus if someone knows of a cheap SIM card writer (so that I can back up all or part of the SIM and restore it later)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

浅笑轻吟梦一曲 2024-09-08 03:03:34

您可以使用任何 PC/SC 智能卡读卡器(和写入器,正如其他人指出的那样)以及可以为您读取和解析数据的程序来完成此操作。

  • 与卡的对话是通过 APDU 命令(在 ISO-7816 中定义)
  • 完成的 SIM (2G) 和 USIM (3G) 卡使用的命令集不同,因此您必须牢记
  • 文件系统的结构和格式SIM 卡的定义在 GSM 11.11(针对 2G)和 ETSI TS 131.102(针对 3G)中 - 所有这些文档都是公开的并且免费提供
  • SMS 保存在名为 EF SMS 的文件中,其名称为 0x6F3C,其结构在 GSM 11.11 第 10.5.3 节中定义

直接回答您的问题:

  • 这里是购买的地方SIM 卡读卡器,点击“照片”即可查看设备图片和软件屏幕截图
  • SIM Manager 是一个可以执行您想要的所有操作的程序(包括读取短信、恢复短信,它甚至可以尝试恢复已删除的短信 - 如果它们仍然物理地位于卡上)
  • 还提供 SIM 卡 SDK。它是一个 DLL,您可以在程序中加载和应用它。这个东西为你做了所有艰苦的工作,你所需要的只是在它上面创建一个 GUI

我是创建 SIM Manager 和上述 SDK 的团队的成员之一。

You can do that with any PC/SC smart card reader (and writer, as others pointed out) and a program that can read and parse the data for you.

  • Talking to a card is done via APDU commands (defined in ISO-7816)
  • The command set used by SIM (2G) and USIM (3G) cards is different, so you have to keep that in mind
  • The structure and format of the file system of a SIM card is defined in GSM 11.11 (for 2G) and ETSI TS 131.102 (for 3G) - all this documentation is public and available free of charge
  • The SMS are kept in a file called EF SMS, its name is 0x6F3C, its structure is defined in section 10.5.3 of GSM 11.11

Direct answers to your questions:

  • Here's where to buy a SIM reader, click on 'photos' to see pics of the device and screenshots of the software
  • SIM Manager is the program that does everything you want (including reading SMS, restoring SMS, it can even attempt to recover deleted SMS - if they're still physically on the card)
  • A SIM card SDK is available too. It is a DLL you can load and apply in your program. This thing does all the hard work for you, all you need is to create a GUI on top of it

I am one of the people from the team that created SIM Manager and the aforementioned SDK.

街道布景 2024-09-08 03:03:34

您肯定需要一个智能卡读卡器,据我所知,几乎任何一个都可以,因为它们都必须支持标准功能。它们也恰好很便宜。我的是 OmniKey(不确定是什么型号,因为我现在没有)。

假设您在 Windows 下进行开发,Windows API 具有可以访问智能卡的函数。 这里是 CodeProject 上的一篇文章,作为一组文章的一部分更详细地讨论了这一点几个 C# 类,让您可以访问大量此类内容,而无需纠结于具体细节。我认为这个人的示例应用程序是专门针对 SIM 卡的,所以这可能会有所帮助。

You'll certainly need a smartcard reader and from what I've been able to find out, pretty much any one will do because they all have to support the standard functionality. They also happen to be pretty cheap. Mine is an OmniKey (not sure what model because I don't have it here right now).

Presuming that you're developing under Windows, the Windows API has functions that make it possible to access smartcards. Here is an article on CodeProject that discussees this in greater detail as part of a set of several C# classes that give you access to a bunch of this stuff without having to tangle with the nuts and bolts. I think that the guy's example app is specifically for SIM cards, so that'll probably help.

只是偏爱你 2024-09-08 03:03:34

有很多用于读写 SIM 卡的产品和硬件,请查看 http://forum.gsmhosting .com/vbb/f500/ 在这个论坛中,您会发现大量有关 SIM 卡、手机的信息。自 1999 年以来最大的资源之一!
对于硬件程序员,您可以构建自己的,例如 JDM 或 ICprog.. 检查 kiscan.net 以获取一些信息..

There's lots of products and hardware to read and write SIM cards, have a look at http://forum.gsmhosting.com/vbb/f500/ in this forum you will find plenty of info concerning sim cards, mobile phones.. one of the bigest resource since 1999!
for hardware programmers, you can build your own like JDM or ICprog.. check kiscan.net for some info..

心如狂蝶 2024-09-08 03:03:34
  1. pySim

    <块引用>

    在下面的示例中,我们将卡的 IMSI 更改为
    901700000003080(选项-i),我们指定一组新的-n NAME
    (运营商名称), -t TYPE (卡类型), -c CC (国家代码), -x MCC
    (移动国家代码)、-y MNC(移动网络代码)和 -s ID
    (集成电路卡 ID)值。

    $ ./pySim-prog.py -p 0 -n OpenBSC -t sysmosim-gr1 -i 901700000003080 -c 001 -x 001 -y 02 -s 1791198229180000075

只需将新的元数据填充到新的 SIM 卡中就足够了吗?它的工作方式是否与原始卡相同? pyusb

以下是完整的选项列表:

$ ./pySim-prog.py -help
  Usage: pySim-prog.py [options]  Options:   
  -h, --help            show this help message and exit
  -d DEV, --device=DEV  Serial Device for SIM access [default: /dev/ttyUSB0]
  -b BAUD, --baud=BAUD  Baudrate used for SIM access [default: 9600]
  -p PCSC, --pcsc-device=PCSC
                        Which PC/SC reader number for SIM access
  -t TYPE, --type=TYPE  Card type (user -t list to view) [default: auto]
  -a PIN_ADM, --pin-adm=PIN_ADM
                        ADM PIN used for provisioning (overwrites default)
  -e, --erase           Erase beforehand [default: False]   
  -S SOURCE, --source=SOURCE
                        Data Source[default: cmdline]
  -n NAME, --name=NAME  Operator name [default: Magic]
  -c CC, --country=CC   Country code [default: 1]
  -x MCC, --mcc=MCC     Mobile Country Code [default: 901]
  -y MNC, --mnc=MNC     Mobile Network Code [default: 55]
  -m SMSC, --smsc=SMSC  SMSP [default: '00 + country code + 5555']
  -M SMSP, --smsp=SMSP  Raw SMSP content in hex [default: auto from SMSC]
  -s ID, --iccid=ID     Integrated Circuit Card ID
  -i IMSI, --imsi=IMSI  International Mobile Subscriber Identity
  -k KI, --ki=KI        Ki (default is to randomize)
  -o OPC, --opc=OPC     OPC (default is to randomize)
  --op=OP               Set OP to derive OPC from OP and KI
  --acc=ACC             Set ACC bits (Access Control Code). not all card types are supported
  -z STR, --secret=STR  Secret used for ICCID/IMSI autogen
  -j NUM, --num=NUM     Card # used for ICCID/IMSI autogen
  --batch               Enable batch mode [default: False]
  --batch-state=FILE    Optional batch state file
  --read-csv=FILE       Read parameters from CSV file rather than command line
  --write-csv=FILE      Append generated parameters in CSV file
  --write-hlr=FILE      Append generated parameters to OpenBSC HLR sqlite3
  --dry-run             Perform a 'dry run', don't actually program the card

源代码可用。

  1. SIM 卡也只是一张智能卡。您可以使用 pyscardpyusb 对其进行操作。我发现此问答很有帮助。
  1. pySim

    In the below example, we are changing the card’s IMSI to
    901700000003080 (option -i) and we are specifying a new set of -n NAME
    (Operator name), -t TYPE (Card type), -c CC (Country code), -x MCC
    (Mobile Country Code), -y MNC (Mobile Network Code) and -s ID
    (Integrated Circuit Card ID) values.

    $ ./pySim-prog.py -p 0 -n OpenBSC -t sysmosim-gr1 -i 901700000003080 -c 001 -x 001 -y 02 -s 1791198229180000075
    

Is it enough just filling the new SIM card with new meta and will it working the same way as original? pyusb

Here is the full list of options:

$ ./pySim-prog.py -help
  Usage: pySim-prog.py [options]  Options:   
  -h, --help            show this help message and exit
  -d DEV, --device=DEV  Serial Device for SIM access [default: /dev/ttyUSB0]
  -b BAUD, --baud=BAUD  Baudrate used for SIM access [default: 9600]
  -p PCSC, --pcsc-device=PCSC
                        Which PC/SC reader number for SIM access
  -t TYPE, --type=TYPE  Card type (user -t list to view) [default: auto]
  -a PIN_ADM, --pin-adm=PIN_ADM
                        ADM PIN used for provisioning (overwrites default)
  -e, --erase           Erase beforehand [default: False]   
  -S SOURCE, --source=SOURCE
                        Data Source[default: cmdline]
  -n NAME, --name=NAME  Operator name [default: Magic]
  -c CC, --country=CC   Country code [default: 1]
  -x MCC, --mcc=MCC     Mobile Country Code [default: 901]
  -y MNC, --mnc=MNC     Mobile Network Code [default: 55]
  -m SMSC, --smsc=SMSC  SMSP [default: '00 + country code + 5555']
  -M SMSP, --smsp=SMSP  Raw SMSP content in hex [default: auto from SMSC]
  -s ID, --iccid=ID     Integrated Circuit Card ID
  -i IMSI, --imsi=IMSI  International Mobile Subscriber Identity
  -k KI, --ki=KI        Ki (default is to randomize)
  -o OPC, --opc=OPC     OPC (default is to randomize)
  --op=OP               Set OP to derive OPC from OP and KI
  --acc=ACC             Set ACC bits (Access Control Code). not all card types are supported
  -z STR, --secret=STR  Secret used for ICCID/IMSI autogen
  -j NUM, --num=NUM     Card # used for ICCID/IMSI autogen
  --batch               Enable batch mode [default: False]
  --batch-state=FILE    Optional batch state file
  --read-csv=FILE       Read parameters from CSV file rather than command line
  --write-csv=FILE      Append generated parameters in CSV file
  --write-hlr=FILE      Append generated parameters to OpenBSC HLR sqlite3
  --dry-run             Perform a 'dry run', don't actually program the card

The source code is available.

  1. Also the SIM card is just a smart card. You can use pyscard or pyusb to operate on it. I found this Q&A helpful.
情徒 2024-09-08 03:03:34

您可以使用 simLAB 工具来读取和编辑几乎任何 SIM 文件。
它适用于所有 PC/SC 智能卡读卡器。该工具还允许您备份 SIM 文件系统。

看看 https://github.com/kamwar/simLAB

You can use simLAB tool for reading and editing almost any SIM file.
It works with every PC/SC smartcard reader. The tool also allows you to backup SIM file system.

Have a look at https://github.com/kamwar/simLAB

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文