{"id":19378813,"url":"https://github.com/linbit/generate-cat-file","last_synced_at":"2025-04-23T19:32:30.754Z","repository":{"id":228256270,"uuid":"690468018","full_name":"LINBIT/generate-cat-file","owner":"LINBIT","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-17T18:22:03.000Z","size":83,"stargazers_count":8,"open_issues_count":2,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-02T19:11:32.911Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LINBIT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-12T08:54:07.000Z","updated_at":"2025-02-11T12:00:13.000Z","dependencies_parsed_at":"2024-03-17T22:11:28.182Z","dependency_job_id":"c9c8e669-766b-4668-9c67-796107b9b809","html_url":"https://github.com/LINBIT/generate-cat-file","commit_stats":null,"previous_names":["linbit/generate-cat-file"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINBIT%2Fgenerate-cat-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINBIT%2Fgenerate-cat-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINBIT%2Fgenerate-cat-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINBIT%2Fgenerate-cat-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LINBIT","download_url":"https://codeload.github.com/LINBIT/generate-cat-file/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250499922,"owners_count":21440715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T09:07:29.478Z","updated_at":"2025-04-23T19:32:30.437Z","avatar_url":"https://github.com/LINBIT.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Generate Microsoft Security Catalog (.cat) files\n\nWhen building Windows drivers for 64 bit versions of Windows\na Microsoft Security Catalog (``.cat``) file is required when\nthe driver is added to the driver store. This file contains\nSHA1 hashes of other files used by the driver (usually the\n``mydriver.sys`` and the ``mydriver.inf`` file). To date as of my\nknowledge there is no open source implementation that does\nnot depend on the ``wintrust.dll`` library (which would require\neither a Windows build machine or wine which unfortunately\ndoes not implement this particular feature). So I wrote\na small C program from scratch that creates the ``.cat``\nfile.\n\n## Usage\n\nYou would normally use the utility via the gencat.sh\n(bash) shell script as follows:\n\n    ./gencat.sh -o mydriver.cat -h myhardwareID mydriver.inf mydriver.sys\n\nSo for (example) WinDRBD the command line would be:\n\n    generate-cat-file/gencat.sh -o windrbd.cat-unsigned -h windrbd windrbd.inf windrbd.sys\n\nNote that the gencat just generates the cat file with the\nSHA1 hashes of the files you specify on the command line\n(``mydriver``.inf and ``mydriver.sys`` in our example). It does\nnot sign the ``.cat`` file. Signing a cat file (and also a\n``.sys`` file) can be done with the ``osslsigncode`` utility,\nwhich is also open source and runs on Linux. Be sure to\npick a modern (2022) version of ``osslsigncode`` since\n``.cat`` file support was only added recently.\n\n## Building the C programs\n\nThere are two C programs: ``generate-cat-file.c`` and\n``strip-pe-image``. To compile them any C compiler\nthat supports the C99 standard (required for the\nbool datatype) should be sufficient. There are no\nlibrary dependencies for the C programs. To build\nthem run (from the project root file):\n\n    make\n\nTo install them on your system, do\n\n    sudo make install\n\nwhich would install it into ``/usr/local/bin``.\n\nThe only other dependency that comes to my mind is\nthat the ``sha1sum`` utility must be installed on\nyour system which is usually the case.\n\n## About the .cat file format\n\nCat files are at least in theory PKCS7 encoded\nbinary files which are described in ASN.1 syntax.\nASN.1 is a meta language for data structures that\noriginates in the early 1980's when every single\nbyte counted. Therefore it is a rather complex\ndata structure. Furthermore there are different\nencodings on the binary level for this data\nstructure. ``.cat`` files use the ASN.1 DER format.\n\nInstead of reading through the various definitions\nI used a (publically available) ASN.1 DER parser\nwritten in Java script to understand the format.\nThe URL of this parser is:\n\n    http://lapo.it/asn1js/\n\nFurthermore this introduction to the DER encoding\nwas very useful:\n\n    https://letsencrypt.org/docs/a-warm-welcome-to-asn1-and-der/\n\nAs a last step it was neccessary to strip existing\nsignatures and their checksums from a ``.sys`` file\n(which is similar to an ``.exe`` file) when the\nSHA1 checksum was computed. This allows for changing\nsignatures in the ``.sys`` file later without having\nto rebuild the ``.cat`` file.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinbit%2Fgenerate-cat-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinbit%2Fgenerate-cat-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinbit%2Fgenerate-cat-file/lists"}