Pycrate is a free Python library for encoding and decoding the signalling messages used in mobile networks, released under the LGPL v2.1. Its author, Benoit Michau, first published it in 2017 as the successor to libmich, a project started in 2009 and retired in 2017.
For years the code was hosted under P1 Security’s GitHub account, P1sec. Since February 2024 it has lived in a dedicated collaborative organisation, pycrate-org, and the old repository is archived with a pointer to the new one. Version 0.8.1 reached PyPI on 11 May 2026, and the repository keeps receiving changes.
What Pycrate is for
The centrepiece is an ASN.1 compiler written in Python. ASN.1 is the notation that the 3GPP and the ITU use to describe the structure of many telecom messages, such as those of the S1AP, NGAP and RRC protocols. Pycrate reads these specifications and generates Python modules that encode and decode messages using aligned and unaligned PER as well as BER, CER, DER, OER and JER. A large set of precompiled specifications ships with the library, so most users never have to compile them from scratch.
Pycrate also handles CSN.1, a less common notation used for some GSM and GPRS radio messages, and implements most NAS formats directly, meaning the messages exchanged between a handset and the core network from 2G through 5G. The list goes on with GTP in its various versions, PFCP, Diameter, SCCP, ISUP, SMS, SIM card secured packets and even a few media formats such as JPEG, GIF and TIFF. Command-line tools are included, among them pycrate_asn1compile.py for compiling a specification and pycrate_shownas.py for printing the content of a NAS message.
The library also contains a small core network, pycrate_corenet, which can drive 3G femtocells over Iuh and LTE base stations over S1. Its documentation states that it mainly supports text messages and data connectivity, with neither voice calls nor handovers. For running a real 4G or 5G core, Open5GS, also covered in our software library, is far more mature.
Pycrate sits close to Scapy, already in our software library. Scapy shines at building IP, TCP or UDP packets, whereas Pycrate focuses on the deeply nested structures found in mobile telephony. A developer can use it to check that messages produced by their own stack are compliant, an engineer to decode a trace captured on an S1 or N2 interface, and a security auditor to craft deliberately malformed messages and watch how a device reacts.
Who is it for?
Pycrate is meant for protocol stack developers, mobile security researchers, test teams at equipment vendors and advanced students who would rather handle real messages than read specification tables. Solid Python skills are a must.
This is not a ready-to-use tool for a general audience. There is no graphical interface, and using it well means knowing what a 3GPP standard contains and how it is organised. Documentation consists of a wiki and docstrings, and the author warns in the repository that one-to-one support takes time and is not always possible. To simply browse a capture, an analyser such as Wireshark is more comfortable, and to build a working network you should look at Open5GS or Osmocom instead.
Download Pycrate safely
The easiest route is pip install pycrate, which fetches the official package from PyPI, an archive of roughly 13 MB. You can also clone github.com/pycrate-org/pycrate and install it with the bundled setup.py script, which gives access to the most recent fixes. No dependency is mandatory. Some features rely on optional modules, such as CryptoMobile for encrypting 4G and 5G NAS messages or pysctp for the core network component.
Pycrate is completely free. The LGPL v2.1 allows it to be embedded in proprietary software, provided that changes made to the library itself are shared. The old P1sec repository is archived and no longer receives fixes. On PyPI, check that the package page links to the pycrate-org organisation before installing anything, since lookalike package names are a well-known trap in the Python ecosystem.
Frequently asked questions
Is Pycrate free?
Yes. The library is distributed under the LGPL v2.1, which is compatible with later versions of the LGPL. There is no paid edition.
What is the difference between the P1sec and pycrate-org repositories?
Both refer to one and the same library. The historical repository under P1sec has been archived since the 2024 move, and development continues in the pycrate-org organisation, which also publishes the PyPI packages.
Does Pycrate run on Windows?
Yes. According to the repository, the library is tested on Linux, macOS and Windows with Python 3.5 or later. Python 2 support ended with version 0.5.5.