keysnare 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- keysnare-0.1.0/.gitignore +21 -0
- keysnare-0.1.0/CONTRIBUTING.md +67 -0
- keysnare-0.1.0/LICENSE +202 -0
- keysnare-0.1.0/PKG-INFO +165 -0
- keysnare-0.1.0/README.md +133 -0
- keysnare-0.1.0/SECURITY.md +47 -0
- keysnare-0.1.0/docs/credential-locations.md +264 -0
- keysnare-0.1.0/docs/design-traps.md +734 -0
- keysnare-0.1.0/docs/detection-rules.md +224 -0
- keysnare-0.1.0/docs/usage.md +356 -0
- keysnare-0.1.0/pyproject.toml +95 -0
- keysnare-0.1.0/src/keysnare/__init__.py +3 -0
- keysnare-0.1.0/src/keysnare/__main__.py +3 -0
- keysnare-0.1.0/src/keysnare/cli.py +249 -0
- keysnare-0.1.0/src/keysnare/detect.py +314 -0
- keysnare-0.1.0/src/keysnare/guidance.py +437 -0
- keysnare-0.1.0/src/keysnare/json_report.py +48 -0
- keysnare-0.1.0/src/keysnare/locations.py +287 -0
- keysnare-0.1.0/src/keysnare/masking.py +13 -0
- keysnare-0.1.0/src/keysnare/readers.py +169 -0
- keysnare-0.1.0/src/keysnare/report.py +78 -0
- keysnare-0.1.0/src/keysnare/risk.py +265 -0
- keysnare-0.1.0/src/keysnare/rules.py +178 -0
- keysnare-0.1.0/src/keysnare/sarif_report.py +102 -0
- keysnare-0.1.0/src/keysnare/scanner.py +296 -0
- keysnare-0.1.0/src/keysnare/terminal.py +186 -0
- keysnare-0.1.0/src/keysnare/trap/__init__.py +1 -0
- keysnare-0.1.0/src/keysnare/trap/admin.py +251 -0
- keysnare-0.1.0/src/keysnare/trap/alert.py +302 -0
- keysnare-0.1.0/src/keysnare/trap/commands.py +242 -0
- keysnare-0.1.0/src/keysnare/trap/decoys.py +173 -0
- keysnare-0.1.0/src/keysnare/trap/identity.py +98 -0
- keysnare-0.1.0/src/keysnare/trap/manager.py +276 -0
- keysnare-0.1.0/src/keysnare/trap/placement.py +196 -0
- keysnare-0.1.0/src/keysnare/trap/state.py +111 -0
- keysnare-0.1.0/src/keysnare/trap/task.py +62 -0
- keysnare-0.1.0/src/keysnare/trap/windows.py +279 -0
- keysnare-0.1.0/src/keysnare/winpath.py +86 -0
- keysnare-0.1.0/tests/conftest.py +10 -0
- keysnare-0.1.0/tests/fakes.py +51 -0
- keysnare-0.1.0/tests/integration/trap_harness.ps1 +332 -0
- keysnare-0.1.0/tests/resources/sarif-schema-2.1.0.json +3389 -0
- keysnare-0.1.0/tests/test_cli.py +335 -0
- keysnare-0.1.0/tests/test_detect.py +272 -0
- keysnare-0.1.0/tests/test_guidance.py +45 -0
- keysnare-0.1.0/tests/test_json_report.py +68 -0
- keysnare-0.1.0/tests/test_locations.py +165 -0
- keysnare-0.1.0/tests/test_masking.py +30 -0
- keysnare-0.1.0/tests/test_package.py +29 -0
- keysnare-0.1.0/tests/test_readers.py +174 -0
- keysnare-0.1.0/tests/test_report.py +87 -0
- keysnare-0.1.0/tests/test_risk.py +71 -0
- keysnare-0.1.0/tests/test_rules.py +129 -0
- keysnare-0.1.0/tests/test_sarif_report.py +113 -0
- keysnare-0.1.0/tests/test_scanner.py +336 -0
- keysnare-0.1.0/tests/test_terminal.py +187 -0
- keysnare-0.1.0/tests/test_trap_admin.py +84 -0
- keysnare-0.1.0/tests/test_trap_alert.py +267 -0
- keysnare-0.1.0/tests/test_trap_commands.py +229 -0
- keysnare-0.1.0/tests/test_trap_decoys.py +98 -0
- keysnare-0.1.0/tests/test_trap_identity.py +79 -0
- keysnare-0.1.0/tests/test_trap_manager.py +235 -0
- keysnare-0.1.0/tests/test_trap_no_decoy_reads.py +110 -0
- keysnare-0.1.0/tests/test_trap_placement.py +160 -0
- keysnare-0.1.0/tests/test_trap_state.py +88 -0
- keysnare-0.1.0/tests/test_trap_task.py +44 -0
- keysnare-0.1.0/tests/test_trap_windows.py +95 -0
- keysnare-0.1.0/tests/test_winpath.py +111 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Python build and cache files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
*.egg-info/
|
|
7
|
+
|
|
8
|
+
# Virtual environment
|
|
9
|
+
.venv/
|
|
10
|
+
|
|
11
|
+
# Tool caches
|
|
12
|
+
.pytest_cache/
|
|
13
|
+
.mypy_cache/
|
|
14
|
+
.ruff_cache/
|
|
15
|
+
.coverage
|
|
16
|
+
htmlcov/
|
|
17
|
+
|
|
18
|
+
# Never commit real secrets
|
|
19
|
+
.env
|
|
20
|
+
.env.*
|
|
21
|
+
!.env.example
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Contributing to KeySnare
|
|
2
|
+
|
|
3
|
+
Thanks for helping. KeySnare protects developers from credential-stealing malware, so it holds
|
|
4
|
+
itself to a few rules that every change must keep.
|
|
5
|
+
|
|
6
|
+
## Rules every change keeps
|
|
7
|
+
|
|
8
|
+
- **Offline.** No network calls, no telemetry, ever.
|
|
9
|
+
- **Zero runtime dependencies.** Standard library only. Every third-party package is a
|
|
10
|
+
supply-chain risk, which is exactly what KeySnare defends against. Development tools are fine.
|
|
11
|
+
- **Never a full secret.** Output, logs and errors show masked values only (`AKIA****WXYZ`).
|
|
12
|
+
- **Never elevated.** No administrator or SYSTEM context may run code from a user-writable path.
|
|
13
|
+
KeySnare's Python code always runs as the normal user. Text from events, files or other
|
|
14
|
+
programs is data, never code or command arguments.
|
|
15
|
+
- **Never browser stores or VS Code extension storage.**
|
|
16
|
+
- **Few false positives.** Every finding says why it is risky and how to fix it.
|
|
17
|
+
- **Never touch real credentials** without the user's explicit confirmation.
|
|
18
|
+
|
|
19
|
+
## Setup
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
git clone https://github.com/Morello77/keysnare.git
|
|
23
|
+
cd keysnare
|
|
24
|
+
python -m venv .venv
|
|
25
|
+
.venv\Scripts\activate # macOS/Linux: source .venv/bin/activate
|
|
26
|
+
python -m pip install -e ".[dev]"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Checks
|
|
30
|
+
|
|
31
|
+
All four must pass before a pull request is merged. CI runs them on Windows, macOS and Linux, on
|
|
32
|
+
Python 3.10 and 3.13.
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
ruff check .
|
|
36
|
+
black --check .
|
|
37
|
+
mypy
|
|
38
|
+
pytest
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Tests
|
|
42
|
+
|
|
43
|
+
- Write the test first, then the code.
|
|
44
|
+
- **Fake secrets are built from pieces at runtime** (`"ghp_" + "a1B2" * 9`), never written as
|
|
45
|
+
complete strings, so the repository never trips GitHub push protection or other scanners.
|
|
46
|
+
- **Never run trap tests on your own machine.** `keysnare trap install` changes the audit policy,
|
|
47
|
+
scheduled tasks and file permissions. The trap integration test
|
|
48
|
+
(`tests/integration/trap_harness.ps1`) runs only on disposable GitHub Actions Windows runners,
|
|
49
|
+
and refuses to start anywhere else.
|
|
50
|
+
- Changes to the admin command templates (`src/keysnare/trap/admin.py`) must update
|
|
51
|
+
`docs/design-traps.md` and `docs/usage.md` to match; a test checks that they are identical.
|
|
52
|
+
|
|
53
|
+
## Style
|
|
54
|
+
|
|
55
|
+
- Clear names over comments. Comments explain *why*, never repeat *what*.
|
|
56
|
+
- Short docstrings on public functions.
|
|
57
|
+
- No unused code and no speculative features.
|
|
58
|
+
- Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/):
|
|
59
|
+
`feat:`, `fix:`, `docs:`, `test:`, `ci:`, `refactor:`, `chore:`.
|
|
60
|
+
|
|
61
|
+
## Releases
|
|
62
|
+
|
|
63
|
+
Releases are built only by the release workflow; never upload locally built packages.
|
|
64
|
+
|
|
65
|
+
## Security issues
|
|
66
|
+
|
|
67
|
+
Do not open a public issue for a vulnerability. See [SECURITY.md](SECURITY.md).
|
keysnare-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Morello Developers
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
keysnare-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: keysnare
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Find plain-text credentials on developer machines and trap credential stealers.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Morello77/keysnare
|
|
6
|
+
Project-URL: Documentation, https://github.com/Morello77/keysnare/blob/main/docs/usage.md
|
|
7
|
+
Project-URL: Issues, https://github.com/Morello77/keysnare/issues
|
|
8
|
+
Project-URL: Security, https://github.com/Morello77/keysnare/security/policy
|
|
9
|
+
Author: Morello Developers
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: credentials,honeytoken,scanner,secrets,security,supply-chain
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Topic :: Security
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: black; extra == 'dev'
|
|
25
|
+
Requires-Dist: jsonschema; extra == 'dev'
|
|
26
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
30
|
+
Requires-Dist: types-jsonschema; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# KeySnare
|
|
34
|
+
|
|
35
|
+
[](https://github.com/Morello77/keysnare/actions/workflows/ci.yml)
|
|
36
|
+
[](LICENSE)
|
|
37
|
+
|
|
38
|
+
Poisoned npm and PyPI packages, malicious VS Code extensions and compromised GitHub Actions all
|
|
39
|
+
want the same thing: the credentials sitting in plain text on developer machines. KeySnare shows
|
|
40
|
+
you exactly what a credential stealer would grab from your computer, plants clearly marked decoy
|
|
41
|
+
credentials that alert you the moment a program reads them, and tells you, step by step, how to
|
|
42
|
+
move each real secret somewhere safer. It runs entirely offline, has zero runtime dependencies,
|
|
43
|
+
and never prints a full secret.
|
|
44
|
+
|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
## Why I built this
|
|
48
|
+
|
|
49
|
+
I’m Morello, a developer in Nigeria. For the better part of this year, most of the cybersecurity news I read pointed to the same thing: exposed keys. Poisoned npm packages, and, most interesting to me, PyPI packages stealing developers’ keys. How do you protect yourself from attacks like that? So I decided to build a tool and see if it helps. It’s called KeySnare. When I first ran it on my PC, it found three tokens I didn’t know were there.
|
|
50
|
+
|
|
51
|
+
What I wanted was simple: show me what a stealer would grab from my machine, tell me how to fix it, and warn me if something tries to take it. That’s what KeySnare does:
|
|
52
|
+
|
|
53
|
+
- It looks at your machine, not just your code. Most secret scanners are built to check code before you push it. Stealers don’t care about your repo. They go straight for the files on your computer: .env files, cloud logins, npm and PyPI tokens, SSH keys, AI tool keys, even your shell history. KeySnare checks those.
|
|
54
|
+
- It sets traps. On Windows, KeySnare can plant fake keys where stealers look. If any program reads one, you get a notification with the name of that program. It all happens on your machine, with no online service involved.
|
|
55
|
+
- It tells you how to fix things. Every finding says why it matters and gives steps for your operating system.
|
|
56
|
+
- It’s built so you can trust it. It works fully offline and has no dependencies. It never runs as administrator, never shows a full secret, and never touches your browser passwords. A tool that protects your keys shouldn’t become a risk itself.
|
|
57
|
+
|
|
58
|
+
It doesn’t block attacks, and I say that openly in the limits section below. But knowing what’s exposed, and knowing fast when something goes after it, is a big step. I hope it helps you the way it helped me.
|
|
59
|
+
|
|
60
|
+
## Install
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
pip install keysnare
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Python 3.10 or newer. Windows, macOS and Linux for scanning; decoy traps are Windows-only for now.
|
|
67
|
+
|
|
68
|
+
## Quick start
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
keysnare scan # scan your home folder
|
|
72
|
+
keysnare scan ~/code/my-project # scan one folder or file
|
|
73
|
+
keysnare scan --brief # one line per finding, no fix steps
|
|
74
|
+
keysnare scan --sarif --output keysnare.sarif # report for code-scanning tools
|
|
75
|
+
keysnare trap install # Windows: plant decoys (see below)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Your home folder is shown as `~` in every report, so screenshots are safe to share. Exit codes
|
|
79
|
+
make it usable in CI: `0` nothing at or above `--fail-on` (default `high`), `1` findings, `2`
|
|
80
|
+
error. Full details: [docs/usage.md](docs/usage.md).
|
|
81
|
+
|
|
82
|
+
## What it scans
|
|
83
|
+
|
|
84
|
+
- `.env` files in your projects
|
|
85
|
+
- Cloud and cluster credentials: AWS, Azure, Google Cloud, Kubernetes
|
|
86
|
+
- Package registry tokens: npm, Yarn, PyPI, pip, Poetry, NuGet
|
|
87
|
+
- Docker registry logins, Git credentials, GitHub CLI tokens, tokens inside Git remote URLs
|
|
88
|
+
- AI tool keys and logins: OpenAI, Anthropic, Google, Hugging Face, Claude Code, Codex, Gemini
|
|
89
|
+
CLI, GitHub Copilot, MCP server configs
|
|
90
|
+
- Service keys: Stripe, Slack, SendGrid
|
|
91
|
+
- SSH and other private keys **without** a passphrase
|
|
92
|
+
- Secrets typed into shell history (bash, zsh, PowerShell)
|
|
93
|
+
|
|
94
|
+
Every finding has a severity, says why it is risky, and gives fix steps for your operating
|
|
95
|
+
system. The locations and rules are documented in
|
|
96
|
+
[docs/credential-locations.md](docs/credential-locations.md) and
|
|
97
|
+
[docs/detection-rules.md](docs/detection-rules.md).
|
|
98
|
+
|
|
99
|
+
## How traps work (Windows)
|
|
100
|
+
|
|
101
|
+
`keysnare trap install` creates fake credentials where stealers look, for example
|
|
102
|
+
`~\.ssh\id_rsa_backup` or `~\.aws\credentials.old`, only where no real tool will ever read them.
|
|
103
|
+
Each decoy is clearly marked as a KeySnare decoy and works nowhere. KeySnare then prints a short
|
|
104
|
+
list of administrator commands **for you to run yourself**: they turn on Windows file auditing
|
|
105
|
+
for the decoys and register a small relay task that uses only built-in Windows programs. When any
|
|
106
|
+
program reads a decoy, Windows records it, and you get a notification naming that program.
|
|
107
|
+
|
|
108
|
+
No KeySnare program runs in the background, and KeySnare never runs as administrator.
|
|
109
|
+
`keysnare trap test` simulates a theft so you see an alert, and `keysnare trap remove` undoes
|
|
110
|
+
everything. The full design, including every system change and how it is undone:
|
|
111
|
+
[docs/design-traps.md](docs/design-traps.md).
|
|
112
|
+
|
|
113
|
+
## Principles
|
|
114
|
+
|
|
115
|
+
- **Offline.** No network calls, no telemetry, ever.
|
|
116
|
+
- **Zero runtime dependencies.** Only the Python standard library, because every third-party
|
|
117
|
+
package is a supply-chain risk.
|
|
118
|
+
- **Never elevated.** KeySnare's own code never runs as administrator or SYSTEM. The admin steps
|
|
119
|
+
are short, published commands that you read and run yourself.
|
|
120
|
+
- **Never prints a full secret.** Reports show `AKIA****WXYZ`, never the value.
|
|
121
|
+
- **Never reads browser password stores or VS Code extension storage.** That would make it behave
|
|
122
|
+
like the malware it fights.
|
|
123
|
+
|
|
124
|
+
## Honest limits
|
|
125
|
+
|
|
126
|
+
- It finds credentials at the [documented locations](docs/credential-locations.md) and in the
|
|
127
|
+
documented formats. A secret in an unusual place or format can be missed.
|
|
128
|
+
- Traps **detect** a theft; they do not block it. When you get an alert, rotate your real
|
|
129
|
+
credentials.
|
|
130
|
+
- Traps are Windows-only for now, need administrator rights once for setup, and notify you only
|
|
131
|
+
while you are logged in (Windows still records every read).
|
|
132
|
+
- Malware already running as you could disable your alert task before stealing. Windows' own
|
|
133
|
+
record of the read survives, but the notification would not come.
|
|
134
|
+
- Fewer decoys are possible on machines where the matching tools are installed, because
|
|
135
|
+
KeySnare never puts a decoy where a real tool would read it.
|
|
136
|
+
- Anyone who opens a decoy by hand can see it is a KeySnare decoy. That is deliberate.
|
|
137
|
+
|
|
138
|
+
## Verify a release
|
|
139
|
+
|
|
140
|
+
Every release is built by GitHub Actions from a tagged commit, with signed build provenance.
|
|
141
|
+
|
|
142
|
+
GitHub artifact attestations, with the [GitHub CLI](https://cli.github.com/):
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
pip download keysnare --no-deps --dest keysnare-download
|
|
146
|
+
gh attestation verify keysnare-download/keysnare-*.whl --repo Morello77/keysnare
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
PyPI attestations: each file on [pypi.org/project/keysnare](https://pypi.org/project/keysnare/)
|
|
150
|
+
shows its verified source repository and workflow. To check one yourself, use the
|
|
151
|
+
`pypi-attestations` tool in a separate, throwaway environment:
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
python -m pip install pypi-attestations
|
|
155
|
+
pypi-attestations verify pypi --repository https://github.com/Morello77/keysnare pypi:keysnare-0.1.0-py3-none-any.whl
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Contributing and security
|
|
159
|
+
|
|
160
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). Please report vulnerabilities privately, as described in
|
|
161
|
+
[SECURITY.md](SECURITY.md).
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
[Apache-2.0](LICENSE). Copyright 2026 Morello Developers.
|
keysnare-0.1.0/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# KeySnare
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Morello77/keysnare/actions/workflows/ci.yml)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
Poisoned npm and PyPI packages, malicious VS Code extensions and compromised GitHub Actions all
|
|
7
|
+
want the same thing: the credentials sitting in plain text on developer machines. KeySnare shows
|
|
8
|
+
you exactly what a credential stealer would grab from your computer, plants clearly marked decoy
|
|
9
|
+
credentials that alert you the moment a program reads them, and tells you, step by step, how to
|
|
10
|
+
move each real secret somewhere safer. It runs entirely offline, has zero runtime dependencies,
|
|
11
|
+
and never prints a full secret.
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
## Why I built this
|
|
16
|
+
|
|
17
|
+
I’m Morello, a developer in Nigeria. For the better part of this year, most of the cybersecurity news I read pointed to the same thing: exposed keys. Poisoned npm packages, and, most interesting to me, PyPI packages stealing developers’ keys. How do you protect yourself from attacks like that? So I decided to build a tool and see if it helps. It’s called KeySnare. When I first ran it on my PC, it found three tokens I didn’t know were there.
|
|
18
|
+
|
|
19
|
+
What I wanted was simple: show me what a stealer would grab from my machine, tell me how to fix it, and warn me if something tries to take it. That’s what KeySnare does:
|
|
20
|
+
|
|
21
|
+
- It looks at your machine, not just your code. Most secret scanners are built to check code before you push it. Stealers don’t care about your repo. They go straight for the files on your computer: .env files, cloud logins, npm and PyPI tokens, SSH keys, AI tool keys, even your shell history. KeySnare checks those.
|
|
22
|
+
- It sets traps. On Windows, KeySnare can plant fake keys where stealers look. If any program reads one, you get a notification with the name of that program. It all happens on your machine, with no online service involved.
|
|
23
|
+
- It tells you how to fix things. Every finding says why it matters and gives steps for your operating system.
|
|
24
|
+
- It’s built so you can trust it. It works fully offline and has no dependencies. It never runs as administrator, never shows a full secret, and never touches your browser passwords. A tool that protects your keys shouldn’t become a risk itself.
|
|
25
|
+
|
|
26
|
+
It doesn’t block attacks, and I say that openly in the limits section below. But knowing what’s exposed, and knowing fast when something goes after it, is a big step. I hope it helps you the way it helped me.
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
pip install keysnare
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Python 3.10 or newer. Windows, macOS and Linux for scanning; decoy traps are Windows-only for now.
|
|
35
|
+
|
|
36
|
+
## Quick start
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
keysnare scan # scan your home folder
|
|
40
|
+
keysnare scan ~/code/my-project # scan one folder or file
|
|
41
|
+
keysnare scan --brief # one line per finding, no fix steps
|
|
42
|
+
keysnare scan --sarif --output keysnare.sarif # report for code-scanning tools
|
|
43
|
+
keysnare trap install # Windows: plant decoys (see below)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Your home folder is shown as `~` in every report, so screenshots are safe to share. Exit codes
|
|
47
|
+
make it usable in CI: `0` nothing at or above `--fail-on` (default `high`), `1` findings, `2`
|
|
48
|
+
error. Full details: [docs/usage.md](docs/usage.md).
|
|
49
|
+
|
|
50
|
+
## What it scans
|
|
51
|
+
|
|
52
|
+
- `.env` files in your projects
|
|
53
|
+
- Cloud and cluster credentials: AWS, Azure, Google Cloud, Kubernetes
|
|
54
|
+
- Package registry tokens: npm, Yarn, PyPI, pip, Poetry, NuGet
|
|
55
|
+
- Docker registry logins, Git credentials, GitHub CLI tokens, tokens inside Git remote URLs
|
|
56
|
+
- AI tool keys and logins: OpenAI, Anthropic, Google, Hugging Face, Claude Code, Codex, Gemini
|
|
57
|
+
CLI, GitHub Copilot, MCP server configs
|
|
58
|
+
- Service keys: Stripe, Slack, SendGrid
|
|
59
|
+
- SSH and other private keys **without** a passphrase
|
|
60
|
+
- Secrets typed into shell history (bash, zsh, PowerShell)
|
|
61
|
+
|
|
62
|
+
Every finding has a severity, says why it is risky, and gives fix steps for your operating
|
|
63
|
+
system. The locations and rules are documented in
|
|
64
|
+
[docs/credential-locations.md](docs/credential-locations.md) and
|
|
65
|
+
[docs/detection-rules.md](docs/detection-rules.md).
|
|
66
|
+
|
|
67
|
+
## How traps work (Windows)
|
|
68
|
+
|
|
69
|
+
`keysnare trap install` creates fake credentials where stealers look, for example
|
|
70
|
+
`~\.ssh\id_rsa_backup` or `~\.aws\credentials.old`, only where no real tool will ever read them.
|
|
71
|
+
Each decoy is clearly marked as a KeySnare decoy and works nowhere. KeySnare then prints a short
|
|
72
|
+
list of administrator commands **for you to run yourself**: they turn on Windows file auditing
|
|
73
|
+
for the decoys and register a small relay task that uses only built-in Windows programs. When any
|
|
74
|
+
program reads a decoy, Windows records it, and you get a notification naming that program.
|
|
75
|
+
|
|
76
|
+
No KeySnare program runs in the background, and KeySnare never runs as administrator.
|
|
77
|
+
`keysnare trap test` simulates a theft so you see an alert, and `keysnare trap remove` undoes
|
|
78
|
+
everything. The full design, including every system change and how it is undone:
|
|
79
|
+
[docs/design-traps.md](docs/design-traps.md).
|
|
80
|
+
|
|
81
|
+
## Principles
|
|
82
|
+
|
|
83
|
+
- **Offline.** No network calls, no telemetry, ever.
|
|
84
|
+
- **Zero runtime dependencies.** Only the Python standard library, because every third-party
|
|
85
|
+
package is a supply-chain risk.
|
|
86
|
+
- **Never elevated.** KeySnare's own code never runs as administrator or SYSTEM. The admin steps
|
|
87
|
+
are short, published commands that you read and run yourself.
|
|
88
|
+
- **Never prints a full secret.** Reports show `AKIA****WXYZ`, never the value.
|
|
89
|
+
- **Never reads browser password stores or VS Code extension storage.** That would make it behave
|
|
90
|
+
like the malware it fights.
|
|
91
|
+
|
|
92
|
+
## Honest limits
|
|
93
|
+
|
|
94
|
+
- It finds credentials at the [documented locations](docs/credential-locations.md) and in the
|
|
95
|
+
documented formats. A secret in an unusual place or format can be missed.
|
|
96
|
+
- Traps **detect** a theft; they do not block it. When you get an alert, rotate your real
|
|
97
|
+
credentials.
|
|
98
|
+
- Traps are Windows-only for now, need administrator rights once for setup, and notify you only
|
|
99
|
+
while you are logged in (Windows still records every read).
|
|
100
|
+
- Malware already running as you could disable your alert task before stealing. Windows' own
|
|
101
|
+
record of the read survives, but the notification would not come.
|
|
102
|
+
- Fewer decoys are possible on machines where the matching tools are installed, because
|
|
103
|
+
KeySnare never puts a decoy where a real tool would read it.
|
|
104
|
+
- Anyone who opens a decoy by hand can see it is a KeySnare decoy. That is deliberate.
|
|
105
|
+
|
|
106
|
+
## Verify a release
|
|
107
|
+
|
|
108
|
+
Every release is built by GitHub Actions from a tagged commit, with signed build provenance.
|
|
109
|
+
|
|
110
|
+
GitHub artifact attestations, with the [GitHub CLI](https://cli.github.com/):
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
pip download keysnare --no-deps --dest keysnare-download
|
|
114
|
+
gh attestation verify keysnare-download/keysnare-*.whl --repo Morello77/keysnare
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
PyPI attestations: each file on [pypi.org/project/keysnare](https://pypi.org/project/keysnare/)
|
|
118
|
+
shows its verified source repository and workflow. To check one yourself, use the
|
|
119
|
+
`pypi-attestations` tool in a separate, throwaway environment:
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
python -m pip install pypi-attestations
|
|
123
|
+
pypi-attestations verify pypi --repository https://github.com/Morello77/keysnare pypi:keysnare-0.1.0-py3-none-any.whl
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Contributing and security
|
|
127
|
+
|
|
128
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). Please report vulnerabilities privately, as described in
|
|
129
|
+
[SECURITY.md](SECURITY.md).
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
[Apache-2.0](LICENSE). Copyright 2026 Morello Developers.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
KeySnare is a security tool, so a weakness in KeySnare itself matters. Thank you for reporting
|
|
4
|
+
one privately.
|
|
5
|
+
|
|
6
|
+
## Reporting a vulnerability
|
|
7
|
+
|
|
8
|
+
Use GitHub's private vulnerability reporting: open the repository's **Security** tab and click
|
|
9
|
+
**Report a vulnerability**. Only the maintainers see the report.
|
|
10
|
+
|
|
11
|
+
Please do not open a public issue, pull request or discussion for a vulnerability until a fix is
|
|
12
|
+
released.
|
|
13
|
+
|
|
14
|
+
Include:
|
|
15
|
+
|
|
16
|
+
- what an attacker can do, and what they need first (for example "malware running as the user
|
|
17
|
+
without admin rights");
|
|
18
|
+
- steps to reproduce, ideally on a fresh Windows VM;
|
|
19
|
+
- the KeySnare version (`keysnare --version`) and your operating system.
|
|
20
|
+
|
|
21
|
+
**Never include real secrets** in a report. If a finding involves a credential, use a fake one.
|
|
22
|
+
|
|
23
|
+
The maintainer aims to acknowledge reports within 7 days and will keep you updated until a fix
|
|
24
|
+
is released. With your permission, you will be credited in the release notes.
|
|
25
|
+
|
|
26
|
+
## Supported versions
|
|
27
|
+
|
|
28
|
+
Only the latest release receives security fixes.
|
|
29
|
+
|
|
30
|
+
## What counts as a vulnerability
|
|
31
|
+
|
|
32
|
+
KeySnare makes promises that a vulnerability would break. Reports are especially welcome for:
|
|
33
|
+
|
|
34
|
+
- any way for code running **without** administrator rights to make KeySnare's admin commands,
|
|
35
|
+
the SYSTEM relay task or anything else run code **as administrator or SYSTEM**;
|
|
36
|
+
- writing to, or redirecting, `C:\ProgramData\KeySnare` as a standard user (junctions, symlinks,
|
|
37
|
+
pre-created folders);
|
|
38
|
+
- KeySnare printing, logging or writing a full secret anywhere (terminal, JSON, SARIF, logs);
|
|
39
|
+
- event text or file content being treated as code or command arguments;
|
|
40
|
+
- any network connection made by KeySnare;
|
|
41
|
+
- KeySnare reading browser password stores or VS Code extension storage;
|
|
42
|
+
- a decoy that is a working credential anywhere;
|
|
43
|
+
- `trap remove` deleting or changing a file KeySnare did not create.
|
|
44
|
+
|
|
45
|
+
Known, documented limits (see "Remaining risks" in
|
|
46
|
+
[docs/design-traps.md](docs/design-traps.md)) are not vulnerabilities, but ideas to reduce them
|
|
47
|
+
are welcome as normal issues.
|