Skip to main content

convert secret patterns to gf compatible

Project description

secpat2gf

convert secret patterns to gf compatible.

Install

from PyPI

$ pip3 install secpat2gf

from Source

$ git clone https://github.com/dwisiswant0/secpat2gf
$ cd secpat2gf/
$ pip3 install -r requirements.txt
$ python3 -m build
$ pip3 install dist/secpat2gf-*.whl --force-reinstall

Usage

$ secpat2gf --help
usage: secpat2gf [-h] -r RULE_FILE [-e ENGINE] [-f FLAGS] [-s]

options:
  -h, --help            show this help message and exit
  -r RULE_FILE, --rule-file RULE_FILE
                        path to rule file/URL
  -e ENGINE, --engine ENGINE
                        set custom engine (default: grep)
  -f FLAGS, --flags FLAGS
                        grep flags (default: -aHnoPr)
  -s, --save            save to /home/dw1/.gf instead of stdout

Example

Converting YAML-based rule URL to gf compatible

$ secpat2gf -r https://github.com/mazen160/secrets-patterns-db/raw/master/datasets/generic.yml
[02/10/2023 08:56:55 AM] Slack Token pattern
{
  "flags": "-aHnPr",
  "pattern": "(xox[pborsa]-[0-9]{12}-[0-9]{12}-[0-9]{12}-[a-z0-9]{32})"
}
[02/10/2023 08:56:55 AM] test pattern
{
  "flags": "-aHnPr",
  "pattern": "test"
}
[02/10/2023 08:56:55 AM] generic password pattern
{
  "flags": "-aHnPr",
  "pattern": "password.+"
}
[02/10/2023 08:56:55 AM] Generic secret pattern
{
  "flags": "-aHnPr",
  "pattern": "secret.+"
}
...

Converting YAML-based rule file to gf & save the results

$ secpat2gf --save -r generic.yaml
[02/10/2023 10:30:56 AM] directory '$HOME/.gf' created successfully
[02/10/2023 10:30:57 AM] Saving Slack Token pattern to $HOME/.gf/slack-token_secrets.json
[02/10/2023 10:30:57 AM] Saving test pattern to $HOME/.gf/test_secrets.json
[02/10/2023 10:30:57 AM] Saving generic password pattern to $HOME/.gf/generic-password_secrets.json
[02/10/2023 10:30:57 AM] Saving Generic secret pattern to $HOME/.gf/generic-secret_secrets.json
[02/10/2023 10:30:57 AM] Saving Generic token pattern to $HOME/.gf/generic-token_secrets.json
...

Then we can see that the pattern can be successfully compiled to gf:

$ gf -list
admin-password_secrets
aws-client-id_secrets
aws-mws-id_secrets
aws-secret-key_secrets
basic-auth-credentials_secrets
basic-token_secrets
bearer-token_secrets
$ gf -dump admin-password_secrets # dump pattern
grep -aHnPr "(admin).+(secret|token|key).+" .

Weaponizing

See workaround from gf-secrets to weaponize those patterns.

Resources

  • secrets-patterns-db - Secrets Patterns DB: The largest open-source Database for detecting secrets, API keys, passwords, tokens, and more.
  • gf - A wrapper around grep, to help you grep for things.
  • gfx - Improved version of gf by @tomnomnom.
  • gf-secrets - Secret and/or credential patterns used for gf.

License

secpat2gf is distributed under MIT. See LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

secpat2gf-1.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

secpat2gf-1.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file secpat2gf-1.1.0.tar.gz.

File metadata

  • Download URL: secpat2gf-1.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for secpat2gf-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e02952747bc7147dc19a5b49fb0f07abec8e9ea8e737bb8d9e4cecddf3b28e28
MD5 2478630e9fe127a2487799f5216525a6
BLAKE2b-256 d8b8a325b9c5bd83b2e1bbc9d490aaafcac8889295bac08b945716d36bbe5092

See more details on using hashes here.

File details

Details for the file secpat2gf-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: secpat2gf-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for secpat2gf-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a54fbe7779e2c0658fec8f19034253ded1bc4aefd04e4c1315c9a8b5809ed71
MD5 c94db7d4350db34689ee2909423cab98
BLAKE2b-256 a662d20f0b960a1cedf5bd979c5e6b9eb014c7c317c26fe36bf44ce4662460df

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page