# Whispers | Identify Hardcoded Secrets In Static Structured Text

**URL:** <https://onehack.st/t/whispers-identify-hardcoded-secrets-in-static-structured-text/207666>\
**Category:** Tools & Scripts\
**Tags:** tools, programming\
**Created:** [November 24, 2021, 12:51am UTC](https://onehack.st/t/whispers-identify-hardcoded-secrets-in-static-structured-text/207666 "2021-11-24T00:51:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prometheus](https://onehack.st/user_avatar/onehack.st/prometheus/32/34950_2.png) [@Prometheus](https://onehack.st/u/Prometheus)\
**Post date:** [November 24, 2021, 12:51am UTC](https://onehack.st/t/whispers-identify-hardcoded-secrets-in-static-structured-text/207666/1 "2021-11-24T00:51:08Z")

</div>

![image](https://onehack.st/uploads/default/original/3X/7/0/70533402a337e6033d8d3637df955913db2e8493.png)

[![](https://camo.githubusercontent.com/cb3fd5608224c2ffd26573faff865d2880fe9abfe4b85f65404a1b7b8d2f34a2/68747470733a2f2f696d672e736869656c64732e696f2f707970692f762f77686973706572732e737667)](https://pypi.python.org/pypi/whispers/) [![](https://github.com/Skyscanner/whispers/workflows/build/badge.svg)](https://github.com/Skyscanner/whispers/actions) [![](https://github.com/Skyscanner/whispers/raw/master/coverage.svg)](https://github.com/Skyscanner/whispers/blob/master/coverage.svg) [![](https://camo.githubusercontent.com/b9703a18e38d32c7f2bba1ede86f66ae0b28f4bafb2caf6554d663b46465a658/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f536b797363616e6e65722f7768697370657273)](https://github.com/Skyscanner/whispers/issues) [![](https://camo.githubusercontent.com/ba64495eecc33fb48d5e3c244d149679febbc9c9a85d9a33771e25e674ae962d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f536b797363616e6e65722f7768697370657273)](https://github.com/Skyscanner/whispers/pulls) [![](https://camo.githubusercontent.com/57f166a6b1f1e2a58a59de4cc1159e7dcb33163e764c7b231b4d46dfbf260463/68747470733a2f2f696d672e736869656c64732e696f2f707970692f646d2f7768697370657273)](https://img.shields.io/pypi/dm/whispers)

> “My little birds are everywhere, even in the North, they whisper to me the strangest stories.” - _Lord Varys_

Whispers is a static code analysis tool designed for parsing various common data formats in search of hardcoded credentials and dangerous functions. Whispers can run in the CLI or you can integrate it in your CI/CD pipeline.

## Detects

- Passwords
- API tokens
- AWS keys
- Private keys
- Hashed credentials
- Authentication tokens
- Dangerous functions
- Sensitive files

## Supported Formats

Whispers is intended to be a **structured text** parser, not a code parser.

The following commonly used formats are currently supported:

- YAML
- JSON
- XML
- .npmrc
- .pypirc
- .htpasswd
- .properties
- pip.conf
- conf / ini
- Dockerfile
- Dockercfg
- Shell scripts
- Python3

Python3 files are parsed as ASTs because of native language support.

## Declaration & Assignment Formats

The following language files are parsed as text, and checked for common variable declaration and assignment patterns:

- JavaScript
- Java
- Go
- PHP

## Special Formats

- AWS credentials files
- JDBC connection strings
- Jenkins config files
- SpringFramework Beans config files
- Java Properties files
- Dockercfg private registry auth files
- Github tokens

## Installation

### From PyPI

```auto
pip3 install whispers

```

### From GitHub

```auto
git clone https://github.com/Skyscanner/whispers
cd whispers
make install

```

## Usage

### CLI

```auto
whispers --help
whispers --info
whispers source/code/fileOrDir
whispers --config config.yml source/code/fileOrDir
whispers --output /tmp/secrets.yml source/code/fileOrDir
whispers --rules aws-id,aws-secret source/code/fileOrDir
whispers --severity BLOCKER,CRITICAL source/code/fileOrDir
whispers --exitcode 7 source/code/fileOrDir

```

### Python

from whispers.cli import parse\_args from whispers.core import run src = “tests/fixtures” configfile = “whispers/config.yml” args = parse\_args([“-c”, configfile, src]) for secret in run(args): print(secret)

## Config

There are several configuration options available in Whispers. It’s possible to include/exclude results based on file path, key, or value. File path specifications are interpreted as globs. Keys and values accept regular expressions and several other parameters. There is a default configuration file built-in that will be used if you don’t provide a custom one.

`config.yml` should have the following structure:

include: files: - “ **/\*.yml" exclude: files: - "** /test/ **/\*" - "** /tests/\*\*/\*” keys: - ^foo values: - bar$ rules: starks: message: Whispers from the North severity: CRITICAL value: regex: (Aria|Ned) Stark ignorecase: True

The fastest way to tweak detection (ie: remove false positives and unwanted results) is to copy the default [config.yml](https://github.com/Skyscanner/whispers/blob/master/whispers/config.yml) into a new file, adapt it, and pass it as an argument to Whispers.

`whispers --config config.yml --rules starks src/file/or/dir`

## Custom Rules

Rules specify the actual things that should be pulled out from key-value pairs. There are several common ones that come built-in, such as AWS keys and passwords, but the tool is made to be easily expandable with new rules.

- Custom rules can be defined in the main config file under `rules:`
- Custom rules can be added to [whispers/rules](https://github.com/Skyscanner/whispers/blob/master/whispers/rules)

rule-id: # unique rule name description: Values formatted like AWS Session Token message: AWS Session Token # report will show this message severity: BLOCKER # one of BLOCKER, CRITICAL, MAJOR, MINOR, INFO key: # specify key format regex: (aws.?session.?token)? ignorecase: True # case-insensitive matching value: # specify value format regex: ^(?=._[a-z])(?=._[A-Z])[A-Za-z0-9+/]{270,450}$ ignorecase: False # case-sensitive matching minlen: 270 # value is at least this long isBase64: True # value is base64-encoded isAscii: False # value is binary data when decoded isUri: False # value is not formatted like a URI similar: 0.35 # maximum allowed similarity between key and value # (1.0 being exactly the same)

## Plugins

All parsing functionality is implemented via plugins. Each plugin implements a class with the `pairs()` method that runs through files and returns the key-value pairs to be checked with rules.

class PluginName: def pairs(self, file): yield “key”, “value”

## GitHub:

> **[GitHub - Skyscanner/whispers: Identify hardcoded secrets in static structured...](https://github.com/Skyscanner/whispers)**
>
> Identify hardcoded secrets in static structured text
