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.
Metadata
Release files for secpat2gf 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| secpat2gf-1.1.0.tar.gz | 4.1 kB | Without provenance | Details for secpat2gf-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| secpat2gf-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for secpat2gf-1.1.0-py3-none-any.whl |
Total release size: 9.8 kB
Release files / secpat2gf-1.1.0.tar.gz
| Download URL | secpat2gf-1.1.0.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e02952747bc7147dc19a5b49fb0f07abec8e9ea8e737bb8d9e4cecddf3b28e28
|
|
BLAKE2b-256 checksum How to use checksums |
d8b8a325b9c5bd83b2e1bbc9d490aaafcac8889295bac08b945716d36bbe5092
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / secpat2gf-1.1.0-py3-none-any.whl
| Download URL | secpat2gf-1.1.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6a54fbe7779e2c0658fec8f19034253ded1bc4aefd04e4c1315c9a8b5809ed71
|
|
BLAKE2b-256 checksum How to use checksums |
a662d20f0b960a1cedf5bd979c5e6b9eb014c7c317c26fe36bf44ce4662460df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Security for secpat2gf 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.