checksec-py


Namechecksec-py JSON
Version 0.7.3 PyPI version JSON
download
home_pagehttps://github.com/Wenzel/checksec.py
SummaryChecksec tool implemented in Python
upload_time2024-05-31 22:18:42
maintainerNone
docs_urlNone
authorMathieu Tarral
requires_python<3.13,>=3.10
licenseGPL-3.0-only
keywords checksec security elf pe binary
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">
  <br>checksec.py</br>
</h1>

<h3 align="center">
Checksec tool in Python, Rich output, based on LIEF
</h3>

<p align="center">
  <strong>
  <a href="https://asciinema.org/a/363216">
    Demo
  </a>
  </strong>
</p>

<p align="center">
  <a href="https://github.com/Wenzel/checksec.py/actions?query=workflow%3ACI">
    <img src="https://github.com/Wenzel/checksec.py/workflows/CI/badge.svg" alt="CI badge"/>
  </a>
  <a href="https://pypi.org/project/checksec.py/">
    <img src="https://img.shields.io/pypi/v/checksec.py?color=blue" alt="PyPI package badge"/>
  </a>
  <a href="https://pypi.org/project/checksec.py/">
    <img src="https://img.shields.io/pypi/pyversions/checksec.py" alt="Python version badge"/>
  </a>
  <a href="https://gitter.im/checksec-py/community?utm_source=share-link&utm_medium=link&utm_campaign=share-link">
    <img src="https://badges.gitter.im/checksec-py/community.svg" />
  </a>
</p>
<p align="center">
  <a href="https://pepy.tech/project/checksec.py">
    <img src="https://pepy.tech/badge/checksec-py" />  
  </a>
  <a href="https://pepy.tech/project/checksec.py">
    <img src="https://img.shields.io/pypi/dm/checksec.py?color=blue&label=downloads&style=flat-square" />
  </a>
</p>

<p align="center">
  <a href="https://asciinema.org/a/363216">
    <img src="https://user-images.githubusercontent.com/964610/94983280-9d007c80-0541-11eb-8462-3da5b7bce35b.png" />
  </a>
</p>

## Table of Contents

- [Overview](#overview)
- [Requirements](#requirements)
- [Setup](#setup)
    - [Windows](#windows)
    - [Linux](#linux)
- [Usage](#usage)
- [FAQ](#faq)
- [References](#references)
- [License](#license)
- [Contributors](#contributors)

## Overview

A simple tool to verify the security properties of your binaries.

These properties can be enabled by your compiler to enforce the security of your executables, and mitigate exploits.
However it can be challenging to apply them on a whole system.

Check the level of security your Linux distro / Windows release is providing you !

Supported formats:

- [x] `ELF`
- [x] `PE`
- [ ] `Mach-O`

Based on:
- [Rich](https://github.com/willmcgugan/rich): Beautiful terminal output formatting
- [LIEF](https://github.com/lief-project/LIEF): Cross-platform library to parse, modify and abstract ELF, PE and Mach-O formats

## Requirements

![](https://img.shields.io/pypi/pyversions/checksec.py)

## Setup

### Windows

You find the `checksec.exe` on the latest Github releases:

<a href="https://github.com/Wenzel/checksec.py/releases/latest">
  <img src="https://img.shields.io/badge/Windows%20release-download-blue?style=for-the-badge"/>
</a>

### Linux

<a href="https://pypi.org/project/checksec.py/">
  <img src="https://img.shields.io/pypi/v/checksec.py?color=blue&label=PyPI%20package&style=for-the-badge" />
</a>

~~~
python3 -m venv venv
source venv/bin/activate
(venv) pip install checksec.py
~~~

## Usage

~~~
(venv) checksec <file_or_directory>...
~~~

Check `--help` for more options (_JSON output_, _recursive walk_, _workers count_)

## FAQ

1️⃣ What's the difference between [`checksec.py`](https://github.com/Wenzel/checksec.py) and [`checksec.sh`](https://github.com/slimm609/checksec.sh) ?

|                            | checksec.py | checksec.sh |
|----------------------------|:-----------:|:-----------:|
| Cross-Platform support      |     ✔       |     ❌      |
| Distributed workload        |     ✔       |     ❌      |
| Scan file                  |      ✔      |      ✔      |
| Scan directory             |      ✔      |      ✔      |
| Scan directory recursively |      ✔      |      ❌     |
| Specify libc path          |      ✔      |      ❌     |
| Scan process               |      ❌     |     ✔       |
| Scan process libs          |      ❌     |     ✔       |
| Scan kernel config         |      ❌     |     ✔       |
| Output Cli                 |      ✔      |      ✔      |
| Output JSON                |      ✔      |      ✔      |
| Output CSV                 |      ❌     |     ✔       |
| Output XML                 |      ❌     |     ✔       |
| ELF: Relro                 |     ✔       |     ✔       |
| ELF: Canary                |      ✔      |      ✔      |
| ELF: NX                    |      ✔      |      ✔      |
| ELF: PIE                   |      ✔      |      ✔      |
| ELF: RPATH                 |      ✔      |      ✔      |
| ELF: RUNPATH               |      ✔      |      ✔      |
| ELF: Symbols               |      ✔      |      ✔      |
| ELF: Fortify               |      ✔      |      ✔      |
| ELF: Fortified             |      ✔      |      ✔      |
| ELF: Fortifable            |      ✔      |      ✔      |
| ELF: Fortify Score         |      ✔      |      ❌       |


2️⃣ What's the difference between [`checksec.py`](https://github.com/Wenzel/checksec.py) and [`winchecksec`](https://github.com/trailofbits/winchecksec) ?

|                             | checksec.py | winchecksec |
|-----------------------------|:-----------:|:-----------:|
| Cross-Platform support      |     ✔       |     ✔      |
| Distributed workload        |     ✔       |     ❌       |
| Scan file                   |     ✔       |     ✔       |
| Scan directory              |     ✔       |     ❌      |
| Scan directory recursively  |     ✔       |     ❌      |
| Output CLI                  |     ✔       |    ✔        |
| Output JSON                 |     ✔       |    ✔        |
| PE: ASLR - DYNAMIC_BASE     |     ✔       |    ✔        |
| PE: ASLR - HIGHENTROPYVA    |     ✔       |    ✔        |
| PE: INTEGRITYCHECK          |     ✔       |    ✔        |
| PE: Authenticode signed     |     ✔       |    ✔        |
| PE: DEP                     |     ✔       |   ✔         |
| PE: Manifest Isolation      |     ✔       |    ✔        |
| PE: SEH                     |     ✔       |    ✔        |
| PE: SafeSEH                 |     ✔       |    ✔        |
| PE: Control Flow Guard      |     ✔       |    ✔        |
| PE: Return Flow Guard       |     ❌      |      ✔      |
| PE: Stack Cookie            |     ✔       |      ✔      |

3️⃣ `checksec` is slow on some huge binaries ! What's happening ?!

`checksec.py` relies on the [`LIEF`](https://github.com/lief-project/LIEF) library to parse `PE/ELF/MachO` formats.

➡️The library doesn't offer at this point _on-demand_ parsing, so it will parse and fetch unnecessary data.

➡️Retrieving symbols can be slow (ex: `pandoc`, `118M`, `+300 000` symbols, `+2m 20sec`). See this [issue](https://github.com/Wenzel/checksec.py/issues/52)

4️⃣ I sent a `CTRL-C` to cancel `checksec.py` processing, the app doesn't want to quit

`checksec.py` is working with multiple process workers to parallelize its execution and binary processing.
When a `CRTL-C` is received, `checksec.py` will [wait](https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Executor.shutdown) for them to stop.

Sometimes, this is not working, and I don't know why at this point.
You can kill the remaining Python workers afterwards.

## References

- [@apogiatzis](https://github.com/apogiatzis) [Gist checksec.py](https://gist.github.com/apogiatzis/fb617cd118a9882749b5cb167dae0c5d)
- [checksec.sh](https://github.com/slimm609/checksec.sh)
- [winchecksec](https://github.com/trailofbits/winchecksec)

## License

[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

## Contributors

[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/0)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/0)[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/1)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/1)[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/2)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/2)[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/3)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/3)[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/4)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/4)[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/5)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/5)[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/6)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/6)[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/7)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/7)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Wenzel/checksec.py",
    "name": "checksec-py",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13,>=3.10",
    "maintainer_email": null,
    "keywords": "checksec, security, ELF, PE, binary",
    "author": "Mathieu Tarral",
    "author_email": "mathieu.tarral@protonmail.com",
    "download_url": "https://files.pythonhosted.org/packages/94/4b/2ffc21e32f8fc34f18abb6e0193f01733bcffa944d6127b9fc7f6d4e8a3c/checksec_py-0.7.3.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">\n  <br>checksec.py</br>\n</h1>\n\n<h3 align=\"center\">\nChecksec tool in Python, Rich output, based on LIEF\n</h3>\n\n<p align=\"center\">\n  <strong>\n  <a href=\"https://asciinema.org/a/363216\">\n    Demo\n  </a>\n  </strong>\n</p>\n\n<p align=\"center\">\n  <a href=\"https://github.com/Wenzel/checksec.py/actions?query=workflow%3ACI\">\n    <img src=\"https://github.com/Wenzel/checksec.py/workflows/CI/badge.svg\" alt=\"CI badge\"/>\n  </a>\n  <a href=\"https://pypi.org/project/checksec.py/\">\n    <img src=\"https://img.shields.io/pypi/v/checksec.py?color=blue\" alt=\"PyPI package badge\"/>\n  </a>\n  <a href=\"https://pypi.org/project/checksec.py/\">\n    <img src=\"https://img.shields.io/pypi/pyversions/checksec.py\" alt=\"Python version badge\"/>\n  </a>\n  <a href=\"https://gitter.im/checksec-py/community?utm_source=share-link&utm_medium=link&utm_campaign=share-link\">\n    <img src=\"https://badges.gitter.im/checksec-py/community.svg\" />\n  </a>\n</p>\n<p align=\"center\">\n  <a href=\"https://pepy.tech/project/checksec.py\">\n    <img src=\"https://pepy.tech/badge/checksec-py\" />  \n  </a>\n  <a href=\"https://pepy.tech/project/checksec.py\">\n    <img src=\"https://img.shields.io/pypi/dm/checksec.py?color=blue&label=downloads&style=flat-square\" />\n  </a>\n</p>\n\n<p align=\"center\">\n  <a href=\"https://asciinema.org/a/363216\">\n    <img src=\"https://user-images.githubusercontent.com/964610/94983280-9d007c80-0541-11eb-8462-3da5b7bce35b.png\" />\n  </a>\n</p>\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Requirements](#requirements)\n- [Setup](#setup)\n    - [Windows](#windows)\n    - [Linux](#linux)\n- [Usage](#usage)\n- [FAQ](#faq)\n- [References](#references)\n- [License](#license)\n- [Contributors](#contributors)\n\n## Overview\n\nA simple tool to verify the security properties of your binaries.\n\nThese properties can be enabled by your compiler to enforce the security of your executables, and mitigate exploits.\nHowever it can be challenging to apply them on a whole system.\n\nCheck the level of security your Linux distro / Windows release is providing you !\n\nSupported formats:\n\n- [x] `ELF`\n- [x] `PE`\n- [ ] `Mach-O`\n\nBased on:\n- [Rich](https://github.com/willmcgugan/rich): Beautiful terminal output formatting\n- [LIEF](https://github.com/lief-project/LIEF): Cross-platform library to parse, modify and abstract ELF, PE and Mach-O formats\n\n## Requirements\n\n![](https://img.shields.io/pypi/pyversions/checksec.py)\n\n## Setup\n\n### Windows\n\nYou find the `checksec.exe` on the latest Github releases:\n\n<a href=\"https://github.com/Wenzel/checksec.py/releases/latest\">\n  <img src=\"https://img.shields.io/badge/Windows%20release-download-blue?style=for-the-badge\"/>\n</a>\n\n### Linux\n\n<a href=\"https://pypi.org/project/checksec.py/\">\n  <img src=\"https://img.shields.io/pypi/v/checksec.py?color=blue&label=PyPI%20package&style=for-the-badge\" />\n</a>\n\n~~~\npython3 -m venv venv\nsource venv/bin/activate\n(venv) pip install checksec.py\n~~~\n\n## Usage\n\n~~~\n(venv) checksec <file_or_directory>...\n~~~\n\nCheck `--help` for more options (_JSON output_, _recursive walk_, _workers count_)\n\n## FAQ\n\n1\ufe0f\u20e3 What's the difference between [`checksec.py`](https://github.com/Wenzel/checksec.py) and [`checksec.sh`](https://github.com/slimm609/checksec.sh) ?\n\n|                            | checksec.py | checksec.sh |\n|----------------------------|:-----------:|:-----------:|\n| Cross-Platform support      |     \u2714       |     \u274c      |\n| Distributed workload        |     \u2714       |     \u274c      |\n| Scan file                  |      \u2714      |      \u2714      |\n| Scan directory             |      \u2714      |      \u2714      |\n| Scan directory recursively |      \u2714      |      \u274c     |\n| Specify libc path          |      \u2714      |      \u274c     |\n| Scan process               |      \u274c     |     \u2714       |\n| Scan process libs          |      \u274c     |     \u2714       |\n| Scan kernel config         |      \u274c     |     \u2714       |\n| Output Cli                 |      \u2714      |      \u2714      |\n| Output JSON                |      \u2714      |      \u2714      |\n| Output CSV                 |      \u274c     |     \u2714       |\n| Output XML                 |      \u274c     |     \u2714       |\n| ELF: Relro                 |     \u2714       |     \u2714       |\n| ELF: Canary                |      \u2714      |      \u2714      |\n| ELF: NX                    |      \u2714      |      \u2714      |\n| ELF: PIE                   |      \u2714      |      \u2714      |\n| ELF: RPATH                 |      \u2714      |      \u2714      |\n| ELF: RUNPATH               |      \u2714      |      \u2714      |\n| ELF: Symbols               |      \u2714      |      \u2714      |\n| ELF: Fortify               |      \u2714      |      \u2714      |\n| ELF: Fortified             |      \u2714      |      \u2714      |\n| ELF: Fortifable            |      \u2714      |      \u2714      |\n| ELF: Fortify Score         |      \u2714      |      \u274c       |\n\n\n2\ufe0f\u20e3 What's the difference between [`checksec.py`](https://github.com/Wenzel/checksec.py) and [`winchecksec`](https://github.com/trailofbits/winchecksec) ?\n\n|                             | checksec.py | winchecksec |\n|-----------------------------|:-----------:|:-----------:|\n| Cross-Platform support      |     \u2714       |     \u2714      |\n| Distributed workload        |     \u2714       |     \u274c       |\n| Scan file                   |     \u2714       |     \u2714       |\n| Scan directory              |     \u2714       |     \u274c      |\n| Scan directory recursively  |     \u2714       |     \u274c      |\n| Output CLI                  |     \u2714       |    \u2714        |\n| Output JSON                 |     \u2714       |    \u2714        |\n| PE: ASLR - DYNAMIC_BASE     |     \u2714       |    \u2714        |\n| PE: ASLR - HIGHENTROPYVA    |     \u2714       |    \u2714        |\n| PE: INTEGRITYCHECK          |     \u2714       |    \u2714        |\n| PE: Authenticode signed     |     \u2714       |    \u2714        |\n| PE: DEP                     |     \u2714       |   \u2714         |\n| PE: Manifest Isolation      |     \u2714       |    \u2714        |\n| PE: SEH                     |     \u2714       |    \u2714        |\n| PE: SafeSEH                 |     \u2714       |    \u2714        |\n| PE: Control Flow Guard      |     \u2714       |    \u2714        |\n| PE: Return Flow Guard       |     \u274c      |      \u2714      |\n| PE: Stack Cookie            |     \u2714       |      \u2714      |\n\n3\ufe0f\u20e3 `checksec` is slow on some huge binaries ! What's happening ?!\n\n`checksec.py` relies on the [`LIEF`](https://github.com/lief-project/LIEF) library to parse `PE/ELF/MachO` formats.\n\n\u27a1\ufe0fThe library doesn't offer at this point _on-demand_ parsing, so it will parse and fetch unnecessary data.\n\n\u27a1\ufe0fRetrieving symbols can be slow (ex: `pandoc`, `118M`, `+300 000` symbols, `+2m 20sec`). See this [issue](https://github.com/Wenzel/checksec.py/issues/52)\n\n4\ufe0f\u20e3 I sent a `CTRL-C` to cancel `checksec.py` processing, the app doesn't want to quit\n\n`checksec.py` is working with multiple process workers to parallelize its execution and binary processing.\nWhen a `CRTL-C` is received, `checksec.py` will [wait](https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Executor.shutdown) for them to stop.\n\nSometimes, this is not working, and I don't know why at this point.\nYou can kill the remaining Python workers afterwards.\n\n## References\n\n- [@apogiatzis](https://github.com/apogiatzis) [Gist checksec.py](https://gist.github.com/apogiatzis/fb617cd118a9882749b5cb167dae0c5d)\n- [checksec.sh](https://github.com/slimm609/checksec.sh)\n- [winchecksec](https://github.com/trailofbits/winchecksec)\n\n## License\n\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n\n## Contributors\n\n[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/0)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/0)[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/1)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/1)[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/2)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/2)[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/3)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/3)[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/4)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/4)[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/5)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/5)[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/6)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/6)[![](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/images/7)](https://sourcerer.io/fame/Wenzel/Wenzel/checksec.py/links/7)\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-only",
    "summary": "Checksec tool implemented in Python",
    "version": "0.7.3",
    "project_urls": {
        "Homepage": "https://github.com/Wenzel/checksec.py",
        "Repository": "https://github.com/Wenzel/checksec.py"
    },
    "split_keywords": [
        "checksec",
        " security",
        " elf",
        " pe",
        " binary"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bbf7e6846ffc08f192c6ab4b531df94851133a71023cdf40d81e56d5b25949dd",
                "md5": "1289d6ecae8c5d37779e36a82c3c84ab",
                "sha256": "db51a2a1357a66b558d91b3923718efefa515a3fabb9fba2a40031858c9c0a45"
            },
            "downloads": -1,
            "filename": "checksec_py-0.7.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1289d6ecae8c5d37779e36a82c3c84ab",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.10",
            "size": 27587,
            "upload_time": "2024-05-31T22:18:40",
            "upload_time_iso_8601": "2024-05-31T22:18:40.476121Z",
            "url": "https://files.pythonhosted.org/packages/bb/f7/e6846ffc08f192c6ab4b531df94851133a71023cdf40d81e56d5b25949dd/checksec_py-0.7.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "944b2ffc21e32f8fc34f18abb6e0193f01733bcffa944d6127b9fc7f6d4e8a3c",
                "md5": "c9487a5adb1f52ee173e63eac3a691bb",
                "sha256": "e62f25e4d62f48a1f3231ad55d7df0158de7e134fd472e6e351eae5a8dd23fe5"
            },
            "downloads": -1,
            "filename": "checksec_py-0.7.3.tar.gz",
            "has_sig": false,
            "md5_digest": "c9487a5adb1f52ee173e63eac3a691bb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.10",
            "size": 27185,
            "upload_time": "2024-05-31T22:18:42",
            "upload_time_iso_8601": "2024-05-31T22:18:42.382827Z",
            "url": "https://files.pythonhosted.org/packages/94/4b/2ffc21e32f8fc34f18abb6e0193f01733bcffa944d6127b9fc7f6d4e8a3c/checksec_py-0.7.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-31 22:18:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Wenzel",
    "github_project": "checksec.py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "checksec-py"
}
        
Elapsed time: 0.24899s