Package: coronacheck-tools
coronacheck-toolsThis is an unofficial tool that is in no way affiliated with CoronaCheck.nl or the Ministry of VWS. You have been warned!coronacheck-tools is a python package and cli tool that allows you to validate, convert and dump the contents of the domestic coronacheck qr code generated athttps://coronacheck.nleither through the app or the website. This tool is useful to get some insight into the data stored in these QR Codes, to fuzz the fields or to create your own QR validator.InstallationPython# Install the package through pip# This package requires python 3.6 or higher# Depending on your Operating System you might need to install some extra dependencies.# E.g. ubuntu linux: apt install ffmpeg libsm6 libxext6 zbar-tools#      OSX: brew install zbar#      Windows: choco install zbar>pipinstallcoronacheck-tools# Example: dumping QR code data to JSON>coronacheck-toolsdumpjson/path/to/qrcode.jpg/path/to/output/directory# Example: validate QR Code>coronacheck-toolsverifyqr/path/to/qrcode.jpg# Example: convert QR to ASN1 DER>coronacheck-toolsconvertqr/path/to/qrcode.jpgasn1/path/to/output/directory# Example: convert ASN1 DER to QR>coronacheck-toolsconvertasn1/path/to/asn1.derqr/path/to/output/directoryDocker# Running the tool through docker is quite easy.# Just docker run sikerdebaard/coronacheck-tools:latest# Optional: add --user `id -u` to change the uid/group of output files to the current user# Example: dumping QR code data to JSON>dockerrun--rm-v/path/to/your/data:/datasikerdebaard/coronacheck-tools:latestdumpjson/data/qrcode.jpg/data# Example: validate QR Code>dockerrun--rm-v/path/to/your/data:/datasikerdebaard/coronacheck-tools:latestverifyqr/data/qrcode.jpg# Example: convert QR to ASN1 DER>dockerrun--rm-v/path/to/your/data:/datasikerdebaard/coronacheck-tools:latestconvertqr/data/qrcode.jpgasn1/data# Example: convert ASN1 DER to QR>dockerrun--rm-v/path/to/your/data:/datasikerdebaard/coronacheck-tools:latestconvertasn1/data/asn1.derqr/dataUsageThe tools main commands are as follows: verify, dump, convert, denylist and asn1spec.verifyThis command is used for verifying a QR code. It supports a QR image,
RAW, ASN1 DER and JSON as input for verification. This tool uses a thin
wrapper around the official mobilecore verifier as used by the
CoronaCheck.nl app.>coronacheck-toolsverify--help

ThisisanunofficialtoolthatisinnowayaffiliatedwithCoronaCheck.nlortheMinistryofVWS
USAGEcoronacheck-toolsverify<input-format><input>

ARGUMENTS<input-format>Inputformat.QR,RAW,ASN1,JSON.<input>Inputfile.

GLOBALOPTIONS-h(--help)Displaythishelpmessage-q(--quiet)Donotoutputanymessage-v(--verbose)Increasetheverbosityofmessages:"-v"fornormaloutput,"-vv"formoreverboseoutputand"-vvv"fordebug-V(--version)Displaythisapplicationversion--ansiForceANSIoutput--no-ansiDisableANSIoutput-n(--no-interaction)DonotaskanyinteractivequestiondumpDump is for converting and image with a QR code to RAW, ASN1 DER or JSON.>coronacheck-toolsdump--help

ThisisanunofficialtoolthatisinnowayaffiliatedwithCoronaCheck.nlortheMinistryofVWS
USAGEcoronacheck-toolsdump<format><image><output>

ARGUMENTS<format>Outputformat.RAW,ASN1,JSON.<image>PathtoanimagefilewithoneormoreQRcodes.<output>Outputdirectory.Willoverwriteexistingfiles.

GLOBALOPTIONS-h(--help)Displaythishelpmessage-q(--quiet)Donotoutputanymessage-v(--verbose)Increasetheverbosityofmessages:"-v"fornormaloutput,"-vv"formoreverboseoutputand"-vvv"fordebug-V(--version)Displaythisapplicationversion--ansiForceANSIoutput--no-ansiDisableANSIoutput-n(--no-interaction)DonotaskanyinteractivequestionconvertThe convert command helps in converting one format into another.
Supported formats are QR image, RAW, ASN1 DER and JSON. The tools
can upconvert or downconvert. E.g. QR -> JSON or JSON -> QR, but it can
also be used for cloning QR -> QR. This is usefull for convert a QR in
a fuzzy image to a crisp clean QR.>coronacheck-toolsconvert--help

ThisisanunofficialtoolthatisinnowayaffiliatedwithCoronaCheck.nlortheMinistryofVWS
USAGEcoronacheck-toolsconvert<input-format><input><output-format><output>

ARGUMENTS<input-format>Inputformat.QR,RAW,ASN1,JSON.<input>Inputfile.<output-format>Outputformat.QR,RAW,ASN1,JSON.<output>Outputdirectory.Existingfileswillbeoverwrittenwithoutwarning.

GLOBALOPTIONS-h(--help)Displaythishelpmessage-q(--quiet)Donotoutputanymessage-v(--verbose)Increasetheverbosityofmessages:"-v"fornormaloutput,"-vv"formoreverboseoutputand"-vvv"fordebug-V(--version)Displaythisapplicationversion--ansiForceANSIoutput--no-ansiDisableANSIoutput-n(--no-interaction)DonotaskanyinteractivequestiondenylistThis tool lists all entries on the deny list and optionally checks if a given QR code is on the denylist if such a parameter is given.>coronacheck-toolsdenylist--help
ThisisanunofficialtoolthatisinnowayaffiliatedwithCoronaCheck.nlortheMinistryofVWS
USAGEcoronacheck-toolsdenylist[<input-format>][<input>]ARGUMENTS<input-format>Optionalinputformat(mustbecombinedwith<input>)<input>OptionalinputQRcodedata(mustbecombinedwith<input-format>)GLOBALOPTIONS-h(--help)Displaythishelpmessage-q(--quiet)Donotoutputanymessage-v(--verbose)Increasetheverbosityofmessages:"-v"fornormaloutput,"-vv"formoreverboseoutputand"-vvv"fordebug-V(--version)Displaythisapplicationversion--ansiForceANSIoutput--no-ansiDisableANSIoutput-n(--no-interaction)Donotaskanyinteractivequestionasn1specThis tool shows the ASN1 specification as used for
deserializing the QR code data.>coronacheck-toolsasn1spec--help

ThisisanunofficialtoolthatisinnowayaffiliatedwithCoronaCheck.nlortheMinistryofVWS
USAGEcoronacheck-toolsasn1spec[<version>]ARGUMENTS<version>Currentlysupportedversions:2"2"GLOBALOPTIONS-h(--help)Displaythishelpmessage-q(--quiet)Donotoutputanymessage-v(--verbose)Increasetheverbosityofmessages:"-v"fornormaloutput,"-vv"formoreverboseoutputand"-vvv"fordebug-V(--version)Displaythisapplicationversion--ansiForceANSIoutput--no-ansiDisableANSIoutput-n(--no-interaction)DonotaskanyinteractivequestionPython APIThis package requires python 3.6 or higherThe python library allows for a little bit more control over how the qr-code is decoded. Here's an example script on how to dump a qr-code to ASN.1 and then read the ASN.1 and convert it to a dict. Finally the script wil re-encode the whole thing back to a QR code.fromcoronacheck_toolsimportdecode_qr,decode_raw,decode_asn1_der,decode_to_dict,encode_dict,raw_to_qr,validate_raw# An image can contain multiple QR codes. As such, this function always returns an array with decoded data.# Format can be the following:#  RAW = Just grab the raw data from the QR code(s) in the image#  ASN1_DER = Decoded QR Code data. The raw data is confiks and then base45 decoded. This results in a ASN.1 DER blob.#  ASN1 = Uses the ASN.1 specification to decode the ASN.1 DER data. This is then represented as a dict. Some of the fields in this data#         are still encoded. Mainly the aDisclosed records still need some decoding. The data is almost usable at this point.#  DICT = Decode everything, even the records within aDisclosed, and output a dict.# Let's first convert the qr-code to an ASN1 DER.asn1s=decode_qr('test/testdata/qrtest.png',format='asn1_der')# Store the first QR code's ASN.1 DER to diskwithopen('/tmp/asn1der.asn','wb')asfh:fh.write(asn1s[0])# This ASN1 blob can be read by tools like openssl# E.g.: openssl asn1parse -in /tmp/test/asn1blob.asn -inform DER# Let's read the ASN.1 DER data from diskwithopen('/tmp/asn1der.asn','rb')asfh:asn1_der=fh.read()# Since it's an ASN.1 DER we have to use decode_asn1_der to deserialize it.# Like all of these functions it allows for a desired format parameter.# Data can always be converted to the next step in the pipeline but# never backwards. It always happens in this order:# RAW -> ASN1_DER -> ASN1 -> DICT## Lets convert the blob to a DICTdata=decode_asn1_der(asn1_der,format='dict')# Now lets re-encode the dict back to RAW and dump it as a QR code# As it's a dict, we have to use encode_dictrawdata=encode_dict(data,'RAW')# Now convert RAW to a QR code imageraw_to_qr('/tmp/qrcode.png',rawdata)# Finally let's validate the QR Code!validity=validate_raw(rawdata)Example scriptsYou can find someexample python scripts here. E.g. how to fuzz some of the QR code fields or how to read (and validate) the QR from a webcam.LicenseThe program is licensed under theMIT License.